rcaloras / bash-preexec

⚡ preexec and precmd functions for Bash just like Zsh.
MIT License
876 stars 93 forks source link

Install fails when bash is in POSIX mode #92

Closed mohd-akram closed 4 years ago

mohd-akram commented 5 years ago

I run my bash in POSIX mode and noticed that the install step fails due to how trap is used (see Bash POSIX Mode).

To fix it, I did something like this:

case :$SHELLOPTS: in *:posix:*) posix=1;; esac
if [ "$posix" ]; then pre="set +o posix"; post="set -o posix"; fi
. bash-preexec.sh
PROMPT_COMMAND="$pre
$PROMPT_COMMAND
$post"

Maybe it would be useful to incorporate this into the script.

dimo414 commented 4 years ago

This should be fixed now, see #106.

That said, POSIX-compatibility is hard to maintain, and shouldn't be expected of a project that doesn't commit to doing so. If you choose to run your shell in POSIX mode you should expect that numerous "standard" Bash features, and libraries that depend on those features, will not work.

rcaloras commented 4 years ago

@mohd-akram can you confirm latest master fixes this? Closing feel free to reopen otherwise.