* David Christensen <dpchr...@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 \$?\\\$" > > Interesting. > > This is my daily driver: > > 2022-06-02 17:38:55 dpchrist@laalaa ~ > $ cat /etc/debian_version ; uname -a ; dpkg-query -W bash > 11.3 > Linux laalaa 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 > GNU/Linux > bash 5.1-2+b3 > > This is my PS1. '\u' does not work on all of Debian, FreeBSD, > Cygwin, and macOS, so the expansion of ${USER} is inserted > between two string literals when .profile runs and sets PS1: > > 2022-06-02 17:39:09 dpchrist@laalaa ~ > $ grep PS1 .profile > export PS1='\n\D{%Y-%m-%d %H:%M:%S} '${USER}'@\h \w\n\$ ' > #export PS1='\n\D{%Y-%m-%d %H:%M:%S} \u@\h \w\n\$ ' > > Testing your PS1: > > 2022-06-02 17:45:03 dpchrist@laalaa ~ > $ PS1="\\h/${TTY#/dev/} \\s$SHLVL \\w \\A \$?\\\$" > laalaa/ -bash1 ~ 17:45 0$ > > 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.