-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix error setting PROMPT_COMMAND in bash #84
Conversation
The PROMPT_COMMAND environmental variable is setup incorrectly by `pazi`: ```bash $ unset PROMPT_COMMAND $ eval "$(pazi init bash)" $ echo $PROMPT_COMMAND __pazi_add_dir;$PROMPT_COMMMAND # should be __pazi_add_dir; $ PROMPT_COMMAND="__pazi_add_dir;" eval "$(pazi init bash)" $ echo $PROMPT_COMMAND __pazi_add_dir;$PROMPT_COMMMAND # should be __pazi_add_dir; ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious what specific issue you ran into. Did your shell actually give you an error with things as they are?
It would be nice to add a regression test for what you ran into.
It might also be worth fixing upstream (since those couple lines were taken from fasd): https://github.com/whjvenyl/fasd/blob/3e6fd486b182224369ac312435fc02fc8c6c2f09/fasd#L172-L176
*__pazi_add_dir\;*) ;; | ||
*) PROMPT_COMMAND="__pazi_add_dir;\$PROMPT_COMMMAND" ;; | ||
case "${PROMPT_COMMAND}" in | ||
*__pazi_add_dir;*) ;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that escape is still needed.
With this change, it prints the error:
bash: eval: line 47: syntax error near unexpected token `;'
bash: eval: line 47: ` *__pazi_add_dir;*) ;;'
After poking around a bit more, I think there's a deeper problem that this doesn't fix. Any existing stuff in prompt command appears to just be being overwritten regardless. I'm basing this specifically on the following:
In the above, the |
@euank The problem is that the script returned by $ echo $PROMPT_COMMAND
history -a; history -n;
$ eval "$(pazi init bash)"
$ echo $PROMPT_COMMAND
__pazi_add_dir;$PROMPT_COMMAND |
@rocha Does this change actually end up fixing the issue for you, as in does it sill execute your existing prompt command's contents as you expect? Per my previous comment, on my system ( I'm a bit confused as to exactly why this PR doesn't work for me since it seems right. Before diving too far into that, I want to make sure we're at least observing the same thing. |
While attempting to reproduce all this with pure bash, I discovered why |
@euank yes, the fix works for me, provided I remove the extra M 😅 I am running bash 4.4.12. I have found that following this guide and using the associated linter helps avoiding bash quoting headaches: |
Indeed, it turns out that extra M was tripping me up here too. Thanks for catching the other issue here and submitting a pr! I hope you don't mind that @LinuxMercedes is picking this up... Trust me, you probably don't actually want to wade into the integ test harness |
The PROMPT_COMMAND environmental variable is setup incorrectly by
pazi
: