Opened 3 years ago
Last modified 2 years ago
#17652 assigned enhancement
Exporting PS1 considered as a bad practice
Reported by: | miqlas | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Applications/Terminal | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Currently Haiku exports PS1 in the /etc/profile file, and i assume it have something to do with the setarch support, however exporting the PS1 in profile breaks the zsh prompt: see the attached screenshot.
The zsh people warned me: exporting PS1 in the profile is a bad practice and they recommends to do it in the bashrc. They said it should be possible to move the logic to the bashrc without any functional change.
Attachments (1)
Change History (6)
by , 3 years ago
Attachment: | screenshot217.png added |
---|
comment:1 by , 3 years ago
comment:2 by , 3 years ago
comment:3 by , 2 years ago
Owner: | removed |
---|---|
Status: | new → assigned |
comment:4 by , 2 years ago
The zsh people warned me: exporting PS1 in the profile is a bad practice and they recommends to do it in the bashrc.
Doing it in the bashrc won't do much on Haiku's Terminal, as it always opens bash as a login shell (so it loads profile
instead of bashrc
).
comment:5 by , 2 years ago
In https://github.com/haikuports/haikuports/commit/3d303f66fa61a7680105e8b47609b4e1abbf38d6 I have patched zsh so that it sets itself with an usable prompt by default.
Do we consider that a good enough of a fix for this issue?
In addition to setarch, this is to make the prompt green or red depending on wether the previous command succeeded.
This should be written in a way that's compatible with any POSIX shell, not just bash. Is it not? I have initially written this code with mksh, but maybe the version in Haiku was changed a bit since then.
If written in standard POSIX shell, there is no reason to not have it in /etc/profile. Any shell parsing that file should be happy with it.