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
bash PROMPT_COMMAND syntax error #4645
Comments
|
I've noticed this before and I thought it had no effect. |
|
@kovidgoyal I am using 0.24.2 and with hstr I am getting the same error: |
|
and? The fix will be in 0.24.3 |
Ah - I misunderstood. I thought the fix was already in 0.24.2 - thanks for clarifying. |
kitty 0.24.4, bash 5.1 (from homebrew)Unfortunately I've run into a nearly identical bug, when using powerline. Fortunately, I found a workaround:
# BEGIN_KITTY_SHELL_INTEGRATION
# This part was not present when reproducing the bug
if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
fi
# END_KITTY_SHELL_INTEGRATION
# Enable Powerline
# This was also present to produce the bug
if [ -f "$(command -v powerline-daemon)" ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
# This is terrible. There must be a better way than hard-coding this path.
. /usr/local/lib/python3.9/site-packages/powerline/bindings/bash/powerline.sh
fiThis produces I'm not sure if this is a bug in kitty or powerline, but I'm posting here since I found it as a related issue in my searching; let me know if I should report it to powerline, too (or in its own issue here). |
|
Minimal reproducer # This works fine
PROMPT_COMMAND=":; "
# Error when more than one space.
PROMPT_COMMAND=":; "
# or when using newline
PROMPT_COMMAND=":"$'\n'
# syntax error near unexpected token `;'Patch # kitty.bash
# Remove all trailing whitespace chars
PROMPT_COMMAND="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}"
PROMPT_COMMAND="${PROMPT_COMMAND%%;}"
# Or use a newline
PROMPT_COMMAND+=$'\n'"$pc" |
Does not work when there is more than one whitespace character, is it worth removing? |
|
I have used exglob to handle multiple chars. |
|
Thank you both for the better reproduction and exceptionally quick fix :) |
Intro
It seems the the Kitty bash shell integration script is inserting a semicolon on the
PROMPT_COMMANDcausing it to conflict with what another program is doing withPROMPT_COMMAND. It this case it is with the z program.Both kitty and z have been installed from the Arch Linux official repositories.
To Reproduce
Steps to reproduce the behavior:
~/bashrc, source/usr/share/z/z.sh(this could change depending on the distro or if installed manually in~/binor something like it);~/.bashrc:Note the two semicolons.
Environment details
I redacted the debug part that seemed to be irrelevant for this topic. The config seems not useful here either. I can provide both if requested.
Additional context
As we see, there are two semicolons (
;;) before_ksi_prompt_command.Here's an excerpt from
/usr/lib/kitty/shell-integration/bash/kitty.bash:If I remove the semicolon highlighted in the screenshot, or if I refrain from sourcing
z.sh, the problem disappears.I have been using
zfor about 5 years and Kitty for about two years. Both have always worked fine and not interfering with one another. Also,zhas not had an upgrade for years. I guess a recent Kitty upgrade added that part of the bash script and the problem came into existence.Here's an excerpt of
/usr/share/z/z.shbash script:So,
zbash script adds a trailing semicolon, while Kitty bash script prepends a semicolon (perhaps defensively in theelsecase). Note that if I remove that trailing semicolon fromz.sh, it simply stops working. That is, if I doz dotfiles, it simply does nothing (it does not change directory to mydotfilesdirectory). So, it seems it is not a matter of simply removing that semicolon fromz.sh.If I remove the leading semicolon before
_ksi_prompt_command, I get no errors, butzdoesn't work either. I get no syntax errors, but it seemsPROMPT_COMMANDis somehow messed up nonetheless.I'm not sure if there is a wrong one here. Perhaps it is just a case of bad luck — an unforeseeable situation — or if one of the programs should really change their addition of that specific semicolon something else.
I can create the same syntax error with this:
The text was updated successfully, but these errors were encountered: