Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unset, initialized / unbound vars behavior in bash 5 vs 3 differs #34

Open
spacedub opened this issue Aug 3, 2022 · 0 comments
Open

Comments

@spacedub
Copy link

spacedub commented Aug 3, 2022

Title says all.

Furthermore, such an error condition does not trigger ERR...

#!/usr/bin/env bash
set -o errexit -o errtrace -o functrace -o nounset -o pipefail

trap::exit(){
        echo exit
        echo "$@"
}

trap::err(){
        echo err
        echo "$@"
}

trap 'trap::exit            "$LINENO" "$?" "$BASH_COMMAND"' EXIT
trap 'trap::err             "$LINENO" "$?" "$BASH_COMMAND"' ERR


foo(){
        local bar
        echo "foo: $bar"
}


foo

echo out of it

Works fine with bash3 - but face-plants with bash5.

Furthermore, since this is an unbound variable issue, it does not trip ERR...

Sometimes, bash really sucks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant