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

Re: Weird set -u error



On Sat, Aug 27, 2022 at 10:21:08AM +1000, David wrote:
> 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

I get these results as well, with Debian 11's packaged bash.

Has anyone managed to reproduce the OP's results, either getting
"interactive" from a bash -c call, or seeing *any* evidence that
/etc/bash.bashrc or ~/.bashrc is sourced from a bash -c call?


Reply to: