On 6/2/22 18:35, Will Mengarini wrote:
* David Christensen <dpchrist@holgerdanske.com> [22-06/02=Th 18:01 -0700]:On 6/2/22 17:12, Will Mengarini wrote:* David Christensen [22-06/02=Th 15:50 -0700]:On 6/2/22 15:13, Will Mengarini wrote:In this transcript, the number before the prompt-ending '$' is $?: -------------------------------- debian/pts/4 bash3 ~ 14:56 0$perl -e 'open "gweeblefleep" || die' debian/pts/4 bash3 ~ 14:57 0$perl -e 'open "gweeblefleep" or die' Died at -e line 1. debian/pts/4 bash3 ~ 14:57 2$ --------------------------------What is your shell? PS1?The shell is Bash 5.1.4. PS1="\\h/${TTY#/dev/} \\s$SHLVL \\w \\A \$?\\\$"
The snippet '${TTY#/dev/}' seems to produce ' -' on my computer. How does your computer produce 'pts/4 ' and what does it mean?'pts/4' is an abbreviation of '/dev/pts/4', pseudoterminal 4. TTY is `tty`; it's been so long I'd forgotten that's not available in all shells. You should have the 'tty' program; it's in coreutils.Is there a reason why you are using double quotes, rather than single quotes?So I can interpolate stuff like ${TTY#/dev/}. In your case, you'll need to set TTY=`tty` before setting PS1, so Bash can use string substitution to remove '/dev/' from it.
Okay. That explains TTY and bash(1) -> Parameter Expansion -> When not performing substring expansion -> Remove matching prefix pattern:
2022-06-02 19:04:45 dpchrist@laalaa ~ $ TTY=`tty` 2022-06-02 19:04:53 dpchrist@laalaa ~ $ echo "'$TTY'" '/dev/pts/8' 2022-06-02 19:04:58 dpchrist@laalaa ~ $ echo "'${TTY#/dev/}'" 'pts/8' Now I can almost match your prompt -- there is a dash before 'bash': 2022-06-02 19:05:10 dpchrist@laalaa ~ $ PS1="\\h/${TTY#/dev/} \\s$SHLVL \\w \\A \$?\\\$" laalaa/pts/8 -bash1 ~ 19:08 0$The dash seems to be coming from the '\s' bash(1) -> PROMPTING -> backslash-escaped special characters:
2022-06-02 19:12:58 dpchrist@laalaa ~ $ PS1="\\s" -bash David