Opened 2 years ago

Last modified 17 months 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)

screenshot217.png (464.9 KB ) - added by miqlas 2 years ago.

Download all attachments as: .zip

Change History (6)

by miqlas, 2 years ago

Attachment: screenshot217.png added

comment:1 by pulkomandy, 2 years ago

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.

comment:3 by jackburton, 23 months ago

Owner: jackburton removed
Status: newassigned

comment:4 by bipolar, 19 months 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 pulkomandy, 17 months 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?

Note: See TracTickets for help on using tickets.