speedenator / agnoster-bash

Agnoster Theme for Bash
MIT License
217 stars 52 forks source link

Setting `nullglob` breaks color escaping. #9

Open joeygravlin opened 6 years ago

joeygravlin commented 6 years ago

Apparently ANSI color escaping breaks when setting shopt -s nullglob. Not necessarily an issue with this codebase per se, in fact it's probably not an option most bash users should set unless they're really adamant about it. All the same, I figure others may run into the same issue I did, and so find this tidbit of information useful.

See: Why is nullglob not default? for why it's generally a bad idea to set this option in bash...

Another oddity I noticed: try running the following in an interactive shell.

echo -e $PR
DEBUG=1
echo -e $PR
DEBUG=0
shopt -s nullglob
shopt -s failglob
echo -e $PR
DEBUG=1
echo -e $PR

With only nullglob set, colors don't work, except for background jobs icon in prompt_status(). With both nullglob and failglob set, things are rather peculiar... A number of globs fail and no colors are in the prompt initially, but with DEBUG=1, prompt colors seem to work (mostly) and less globs fail. Also, the contents of $PR are not as you'd likely expect with DEBUG=1, when both {null,fail}glob are set vs just nullglob. I would spend more time on this if I had it right now. Might return with a pull-request, if I figure out a fix for this, after my semester settles down.