[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Document m=1 m=2; echo $m result
From: |
Robert Elz |
Subject: |
Re: Document m=1 m=2; echo $m result |
Date: |
Mon, 03 Jul 2023 19:41:07 +0700 |
Date: Sun, 2 Jul 2023 21:04:38 -0400
From: Greg Wooledge <greg@wooledge.org>
Message-ID: <ZKIepsrizkqZeSf+@wooledge.org>
| The first assignment is done before the value of "m" is used in the second
| assignment.
Note that that is a shell specific feature, applies to bash, but
not necessarily to other shells (some will do it that way, others won't).
| This feature is commonly used in the following constructs:
| extract=${input#*<} extract=${extract%>*}
| data=$(cat file; printf x) data=${data%x}
which would be made truly portable if written
extract=${input#*<}; extract=${extract%>*}
data=$(cat file; printf x); data=${data%x}
Is there really that much to be gained by omitting a semicolon
in a sequence like that? The only time it matters if if the
assignments in question are prefixes to some other command. Rather
than relying upon that kind of non-portable construct, you'd be better
to restructure the code, and avoid the issue, but this is very rare
except when someone is deliberately trying to make things non-portable.
kre
- Document m=1 m=2; echo $m result, Dan Jacobson, 2023/07/02
- Re: Document m=1 m=2; echo $m result, Lawrence Velázquez, 2023/07/02
- Re: Document m=1 m=2; echo $m result, Greg Wooledge, 2023/07/02
- Re: Document m=1 m=2; echo $m result, Dan Jacobson, 2023/07/02
- Re: Document m=1 m=2; echo $m result,
Robert Elz <=
- Re: Document m=1 m=2; echo $m result, alex xmb ratchev, 2023/07/03
- Re: Document m=1 m=2; echo $m result, Dennis Williamson, 2023/07/03
- Re: Document m=1 m=2; echo $m result, alex xmb ratchev, 2023/07/03
- Re: Document m=1 m=2; echo $m result, Dennis Williamson, 2023/07/03
- Re: Document m=1 m=2; echo $m result, alex xmb ratchev, 2023/07/03