Hello.

I was surprised to discover that the following two lines behave
differently:


  f () { a=$(false); echo $?; }; f         # This prints 1 as expected

  f () { local a=$(false); echo $?; }; f   # This prints 0

The way I interpret this is that making the variable local “counts as a
statement”, and overwrites the value of $? with 0, since making the
variable local succeeds.  Is this correct?  Is this the intended
semantics?  I certainly find it counterintuitive, and cannot see it
being documented.

Thanks, and thanks for your precious work on Bash.

--  
Luca Saiu      https://ageinghacker.net
  GNU Jitter     https://www.gnu.org/software/jitter
  GNU epsilon    https://www.gnu.org/software/epsilon
  pEp-mail-tool  https://codeberg.org/pEp/pEp-mail-tool

I support everyone's freedom of mocking any opinion or belief, no
matter how deeply held, with open disrespect and the same unrelented
enthusiasm of a toddler who has just learned the word "poo".

Attachment: sender_key.asc
Description: application/pgp-keys

Reply via email to