|
From: | Léa Gris |
Subject: | Assign read-only variables return code not usable inline |
Date: | Tue, 23 Feb 2021 13:54:53 +0100 |
User-agent: | Telnet/1.0 [tlh] (PDP11/DEC) |
https://ideone.com/iw2pSv
#!/usr/bin/env bashdeclare -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 || exit 2 still there with $?=1, after: if ! r='hello'; then exit; fi declare -r r
-- Léa Gris
[Prev in Thread] | Current Thread | [Next in Thread] |