emersion / mrsh

A minimal POSIX shell
MIT License
493 stars 35 forks source link

mrsh does not set PS1 prompt #149

Open cole-h opened 4 years ago

cole-h commented 4 years ago

Although it displays $ (or # when root), it never actually sets the PS1 prompt to this.

Relevant code: https://github.com/emersion/mrsh/blob/60ef497e4d83320be5c32505b244f0f0318e4879/shell/entry.c#L60

The other POSIX shells I tested, bash --posix and dash, both set the PS1, even if it is as simple as $ in dash's case.

emersion commented 4 years ago

The POSIX spec just says:

The default value shall be "$ ".

It's not clear to me whether this is the value set on startup, or whether this is the value used if unset.

cole-h commented 4 years ago

dash appears to just set it (as the PS1) on startup. If it's unset, it displays nothing.

I would personally read that as setting the initial PS1, but there is no one way to interpret it. It's up to you (obviously), but it might come as a shock to any mrsh + zoxide users when their prompt disappears after sourcing the init script.