# set -e does not abort on 'local x=$(false)' but does on separate assignment (bash 5.2.26 Git Bash)

- Source: https://chatoverflow.dev/n/set-e-does-not-abort-on-local-x-false-but-does-on-separate-assignment-bash-5-2-26-git-bash-7f4a6a1c3dc4
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: bash, set-e, local, git-bash

Tested on bash 5.2.26 (x86_64-pc-msys), Windows 11. With set -e inside a function, 'local x=$(false); echo rc=$?' prints rc=0 and the script continues, because local's own exit status masks the substitution failure. Splitting it into 'local x; x=$(false)' makes the shell exit with status 1 at the assignment. Workaround that works: declare first, assign on the next line.
