Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #244654 > unrolled thread

PS1 and $-, a footnote; was Re: .profile not being src'd at login on uptodate buster

Started byDavid Wright <deblis@lionunicorn.co.uk>
First post2022-01-27 06:00 +0100
Last post2022-01-27 13:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  PS1 and $-, a footnote; was Re: .profile not being src'd at login on  uptodate buster David Wright <deblis@lionunicorn.co.uk> - 2022-01-27 06:00 +0100
    Re: PS1 and $-, a footnote; was Re: .profile not being src'd at  login on uptodate buster Greg Wooledge <greg@wooledge.org> - 2022-01-27 13:40 +0100

#244654 — PS1 and $-, a footnote; was Re: .profile not being src'd at login on uptodate buster

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2022-01-27 06:00 +0100
SubjectPS1 and $-, a footnote; was Re: .profile not being src'd at login on uptodate buster
Message-ID<DK533-2ZT-1@gated-at.bofh.it>
On Mon 12 Apr 2021 at 11:26:49 (-0400), Greg Wooledge wrote:
> On Mon, Apr 12, 2021 at 10:18:19AM -0500, David Wright wrote:
> > I'm not using PS1 to test whether stdout is a terminal, but whether
> > the file is running interactively. From man bash:
> > 
> >   "PS1 is set and $- includes i if bash is interactive, allowing a
> >   shell script or a startup file to test this state.
> 
> The second half of that sentence is referring to the $- part.  That's
> what you're supposed to test to see whether the shell is interactive.
> 
> # bash
> if [[ $- = *i* ]]; then
>   echo "I am an interactive shell"
> echo 
> 
> # sh
> case $- in
>   *i*) echo "I am an interactive shell" ;;
> esac

I happened to come across one place where I might have originally
found the construction I no longer use, and that's in   man lesspipe,
very near the end, where it says:

  if [ -z "$PS1" ]; then

Cheers,
David.

[toc] | [next] | [standalone]


#244677 — Re: PS1 and $-, a footnote; was Re: .profile not being src'd at login on uptodate buster

FromGreg Wooledge <greg@wooledge.org>
Date2022-01-27 13:40 +0100
SubjectRe: PS1 and $-, a footnote; was Re: .profile not being src'd at login on uptodate buster
Message-ID<DKced-7Sx-3@gated-at.bofh.it>
In reply to#244654
On Wed, Jan 26, 2022 at 10:59:28PM -0600, David Wright wrote:
> On Mon 12 Apr 2021 at 11:26:49 (-0400), Greg Wooledge wrote:
> > On Mon, Apr 12, 2021 at 10:18:19AM -0500, David Wright wrote:
> > > I'm not using PS1 to test whether stdout is a terminal, but whether
> > > the file is running interactively. From man bash:
> > > 
> > >   "PS1 is set and $- includes i if bash is interactive, allowing a
> > >   shell script or a startup file to test this state.
> > 
> > The second half of that sentence is referring to the $- part.  That's
> > what you're supposed to test to see whether the shell is interactive.
> > 
> > # bash
> > if [[ $- = *i* ]]; then
> >   echo "I am an interactive shell"
> > echo 
> > 
> > # sh
> > case $- in
> >   *i*) echo "I am an interactive shell" ;;
> > esac
> 
> I happened to come across one place where I might have originally
> found the construction I no longer use, and that's in   man lesspipe,
> very near the end, where it says:
> 
>   if [ -z "$PS1" ]; then

Well, that's not a reliable test.  You could have PS1 set via the
environment in a non-interactive shell.  The number of people who export
PS1 from their profiles or bashrc files is non-negligible.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web