[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"environment:" instead of $0 in front of fatal errors from functions
From: |
Emanuele Torre |
Subject: |
"environment:" instead of $0 in front of fatal errors from functions |
Date: |
Mon, 22 May 2023 14:36:51 +0200 |
User-agent: |
Mutt/2.2.10 (2023-03-25) |
Error messages for fatal error e.g. ${x?foo} or rovar=foo or
$x expanded with nounset, report an error message prefixed by the string
"environment:" instead of "scriptname:" (or "$0:").
$ bash -c '${x?hi}' asd
asd: line 1: x: hi
$ bash -c 'a () { ${x?hi} ;}; a' asd
environment: line 1: x: hi
$ bash -c 'readonly x=x; x=y' asd
asd: line 1: x: readonly variable
$ bash -c 'readonly x=x; a () { x=y ;}; a'
environment: line 1: x: readonly variable
$ bash -uc '$x' asd
asd: line 1: x: unbound variable
$ bash -uc 'a () { $x ;}; a' asd
environment: line 1: x: unbound variable
This bug seems to have been introduced in Bash 4.4:
$ bash43 -c '${x?hi}' asd
asd: x: unbound variable
$ bash43 -c 'a () { ${x?hi} ;}; a' asd
asd: x: unbound variable
$ bash44 -c '${x?hi}' asd
asd: x: unbound variable
$ bash44 -c 'a () { ${x?hi} ;}; a' asd
environment: x: unbound variable
o/
emanuele6
- "environment:" instead of $0 in front of fatal errors from functions,
Emanuele Torre <=