[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: executes statement after "exit"
From: |
Chet Ramey |
Subject: |
Re: executes statement after "exit" |
Date: |
Fri, 15 Apr 2022 13:35:07 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
On 4/15/22 12:57 PM, Frank Heckenbach wrote:
Bash Version: 5.1
Patch Level: 16
Release Status: release
Description:
bash executes statement after "exit".
Happens with or without "set -e".
Doesn't happen with newline instead of ";".
Similar to https://bugs.debian.org/819327, but perhaps not the same
(as that one also happens with newline).
#!/bin/bash
: $((08 + 0)); exit
echo "Should not get here."
It never executes `exit'.
The explanation in
https://lists.gnu.org/archive/html/bug-bash/2022-04/msg00010.html applies here.
The arithmetic syntax error (invalid octal constant) results in a word
expansion error (the $((...)) ), which causes the shell to abort execution
of the current command (the command list) and jump back to the top level
to continue execution with the next command (echo).
But I guess that's also prescribed by POSIX, right?
POSIX requires the shell to exit on a word expansion error, which bash does
in posix mode.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/