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    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to