In Bash, PROMPT_COMMAND array causes a syntax error when an element ends with ;
, &
, etc.
#5219
Open
1 task done
Labels
Bugs
Bugs, Hangs, Crash, and Freezes
Dupe Check
Describe the bug
The bug happens in Bash. Bash 5.1 started to support the array version of
PROMPT_COMMAND
, where each element would be executed before showing a prompt. When an element of the arrayPROMPT_COMMAND
(that is not the last element in the array) ends with;
or&
after the initialization in~/.bashrc
, a syntax error arises.This is caused by the following part of Warp's shell integration:
The problem lies in the line calculating
PROMPT_COMMAND_FLATTENED
. In shell language, commands cannot be always joined by;
. For examplecmd1 &
andcmd2
(which are both valid commands) cannot be combined to becmd1 & ; cmd2
.cmd1 & ; cmd2
is a syntax error. Similarly,cmd1 ;
andcmd2
cannot be combined to becmd1 ;; cmd2
norcmd1 ; ; cmd2
. To join valid commands, a newline character should be used. Here, I suggest the following change:To reproduce
With the following single-line
~/.bashrc
, start Warp Terminal with Bash.Then, the following error message appears:
Expected behavior
The messages
foo
andbar
are printed before every new prompt.Screenshots
No response
Operating system
Linux
Operating system and version
KDE neon 6.0 x86_64
Shell Version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Current Warp version
warp-terminal-v0.2024.08.06.08.01.stable_00-1-x86_64
Regression
No, this bug or issue has existed throughout my experience using Warp
Recent working Warp date
No response
Additional context
No response
Does this block you from using Warp daily?
No
Is this an issue only in Warp?
Yes, I confirmed that this only happens in Warp, not other terminals.
Warp Internal (ignore): linear-label:b9d78064-c89e-4973-b153-5178a31ee54e
None
The text was updated successfully, but these errors were encountered: