-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
bash: fix PS1=abc bash #23161
base: master
Are you sure you want to change the base?
bash: fix PS1=abc bash #23161
Conversation
if the shell already has a name don't change it. this is the same behaviour as bash itself env -u PS1 bash --noprofile --norc echo $PS1 \s-\v\$ PS1=abc bash --noprofile --norc echo $PS1 abc
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 not quite sure what perceived bug you are attempting to fix in this PR.
PS1
is not the name of the shell.
It's the shell prompt.
\s-\v$
is the expected default if no other value is set in the profile
($PREFIX/etc/profile
), system bashrc
file ($PREFIX/etc/bash.bashrc
) or user .bashrc
file (~/.bashrc
).
The relevant section from man 1 bash
1 reads:
PS1 The value of this parameter is expanded (see PROMPTING below)
and used as the primary prompt string. The default value is
``\s-\v\$ ''.
This default \s-\v\$
is evaluates to2: bash-5.2$
While our default assignment of \[\e[0;32m\]\w\[\e[0m\] \[\e[0;97m\]\$\[\e[0m\]
evaluates to2 ~ $
,
with the path in green (and truncated to 2 segments by the PROMPT_DIRTRIM=2
above), and the $
in white.
It is probably worthwhile to allow users to set a PS1
by passing it along to a spawned bash shell,
though this isn't a usecase I have ever encountered before.
Footnotes
@@ -12,7 +12,9 @@ export HISTCONTROL=ignoreboth | |||
|
|||
# Default command line prompt. | |||
PROMPT_DIRTRIM=2 | |||
if test -z "$(env | grep -w PS1)"; then | |||
PS1='\[\e[0;32m\]\w\[\e[0m\] \[\e[0;97m\]\$\[\e[0m\] ' |
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.
Consider using [[ -v PS1 ]]
1 instead to avoid the dependency on grep
.
PS1='\[\e[0;32m\]\w\[\e[0m\] \[\e[0;97m\]\$\[\e[0m\] ' | |
# Allow users to override $PS1 by passing it to the invocation of bash as an environment variable | |
[[ -v PS1 ]] || PS1='\[\e[0;32m\]\w\[\e[0m\] \[\e[0;97m\]\$\[\e[0m\] ' |
Footnotes
termux-packages/packages/bash/build.sh Lines 1 to 7 in 507c890
By the way you'll need to add TERMUX_PKG_REVISION=1 to the bash build.sh.Preferably under the package version. Since this is an update to part of the package it should be recognized by the package manager as such. |
if the shell already has a name don't change it. this is the same behaviour as bash itself
env -u PS1 bash --noprofile --norc
echo $PS1
\s-\v$
PS1=abc bash --noprofile --norc
echo $PS1
abc