[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Weird set -u error



On Sat, 27 Aug 2022 at 08:54, Tim Woodall <debianuser@woodall.me.uk> wrote:
> On Fri, 26 Aug 2022, tomas@tuxteam.de wrote:
> > On Fri, Aug 26, 2022 at 10:57:44AM -0400, Greg Wooledge wrote:

> I modified /etc/bash.bashrc to prove it was only being sourced in the
> second case above (it prints the value of PS1)
>
> And now I can reproduce without -u
> $ bash -c :
> $ ( bash -c : )
> 'PS1='
> $ ( bash -c : ; : )
> $

Just sharing something that I tried, to shed some more light
on this, in case that's useful ...

$ foo() { case "$-" in *i* ) i=interactive ;; * ) i=not-interactive ;;
esac ; echo $BASHPID $i ; }
$ declare -fx foo
$ foo
2415 interactive
$ foo ; ( foo ) ; foo
2415 interactive
2512 interactive
2415 interactive
$ bash -c foo
2515 not-interactive
$ foo ; ( bash -c foo ) ; foo
2415 interactive
2516 not-interactive
2415 interactive
$ foo ; ( foo ; bash -c foo ; foo ) ; foo
2415 interactive
2517 interactive
2518 not-interactive
2517 interactive
2415 interactive
$


Reply to: