Re: Assign read-only variables return code not usable inline

2021-02-23 Thread Chet Ramey
On 2/23/21 7:54 AM, Léa Gris wrote: https://ideone.com/iw2pSv #!/usr/bin/env bash declare -r r r=2 || exit 2 OK, let's pick this one. This is what POSIX calls a "variable assignment error" in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_01 (you've om

Re: Assign read-only variables return code not usable inline

2021-02-23 Thread Oğuz
23 Şubat 2021 Salı tarihinde Léa Gris yazdı: > https://ideone.com/iw2pSv > > #!/usr/bin/env bash >> declare -r r >> r=2 || exit 2 > > There is no command substitution in `r=2', it will either succeed and return zero, or fail and cause the shell to discard the whole command (`r=2 || exit 2'); `e

Assign read-only variables return code not usable inline

2021-02-23 Thread Léa Gris
https://ideone.com/iw2pSv #!/usr/bin/env bash declare -r r r=2 || exit 2 echo 'still there with $?='$?', after: r=2 || exit 2' if ! r='hello'; then exit; fi echo "still there with \$?=$?, after: if ! r='hello'; then exit; fi" typeset -p r Output: still there with $?=1, after: r=2