bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Assign read-only variables return code not usable inline


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 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 || exit 2
still there with $?=1, after: if ! r='hello'; then exit; fi
declare -r r


--
Léa Gris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]