BASH_SUBSHELL count not counting?

2011-08-29 Thread Roger

Within GNU Screen session & VTE:

roger@localhost2 ~ $ bash

0 ;-)
roger@localhost2 ~ $ ps -ax |tail
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
30840 pts/6Ss 0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
30842 pts/5S+ 0:00 bash --noprofile
30844 pts/7Ss+0:00 su -
30845 pts/6S  0:00 bash --noprofile
30848 pts/8Ss 0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
30849 pts/8S+ 0:00 bash --noprofile
30920 ?S  0:00 [kworker/1:2]
30981 pts/6S  0:00 bash <-- New bash shell within a bash shell
30995 pts/6R+ 0:00 ps -ax
30996 pts/6S+ 0:00 tail

0 ;-)
roger@localhost2 ~ $ echo $BASH_SUBSHELL
0

0 ;-)
roger@localhost2 ~ $ exit
exit

0 ;-)
roger@localhost2 ~ $

-- 
Roger
http://rogerx.freeshell.org/



Re: BASH_SUBSHELL count not counting?

2011-08-29 Thread Dennis Williamson
On Mon, Aug 29, 2011 at 7:24 PM, Roger  wrote:
>
> Within GNU Screen session & VTE:
>
> roger@localhost2 ~ $ bash
>
> 0 ;-)
> roger@localhost2 ~ $ ps -ax |tail
> Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
> 30840 pts/6    Ss     0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
> 30842 pts/5    S+     0:00 bash --noprofile
> 30844 pts/7    Ss+    0:00 su -
> 30845 pts/6    S      0:00 bash --noprofile
> 30848 pts/8    Ss     0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
> 30849 pts/8    S+     0:00 bash --noprofile
> 30920 ?        S      0:00 [kworker/1:2]
> 30981 pts/6    S      0:00 bash <-- New bash shell within a bash shell
> 30995 pts/6    R+     0:00 ps -ax
> 30996 pts/6    S+     0:00 tail
>
> 0 ;-)
> roger@localhost2 ~ $ echo $BASH_SUBSHELL
> 0
>
> 0 ;-)
> roger@localhost2 ~ $ exit
> exit
>
> 0 ;-)
> roger@localhost2 ~ $
>
> --
> Roger
> http://rogerx.freeshell.org/
>
>

I think you want $SHLVL

$ echo $SHLVL $BASH_SUBSHELL
1 0
$ bash
$ echo $SHLVL $BASH_SUBSHELL
2 0
$ (echo $SHLVL $BASH_SUBSHELL)
2 1
$ ( (echo $SHLVL $BASH_SUBSHELL) )
2 2
$ echo $SHLVL $(echo "$BASH_SUBSHELL")
2 1
$ echo foo | while read -r bar; do echo $SHLVL $BASH_SUBSHELL; done
2 1
$ while read -r bar; do echo $SHLVL $BASH_SUBSHELL; done < <(echo foo)
2 0


-- 
Visit serverfault.com to get your system administration questions answered.



Re: BASH_SUBSHELL count not counting?

2011-08-29 Thread Dennis Williamson
By the way, you might find

ps fx

to be more useful in this case.

On Mon, Aug 29, 2011 at 7:24 PM, Roger  wrote:
>
> Within GNU Screen session & VTE:
>
> roger@localhost2 ~ $ bash
>
> 0 ;-)
> roger@localhost2 ~ $ ps -ax |tail
> Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
> 30840 pts/6    Ss     0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
> 30842 pts/5    S+     0:00 bash --noprofile
> 30844 pts/7    Ss+    0:00 su -
> 30845 pts/6    S      0:00 bash --noprofile
> 30848 pts/8    Ss     0:00 /bin/bash - /home/roger/bin/bashnoprofile_ionice.sh
> 30849 pts/8    S+     0:00 bash --noprofile
> 30920 ?        S      0:00 [kworker/1:2]
> 30981 pts/6    S      0:00 bash <-- New bash shell within a bash shell
> 30995 pts/6    R+     0:00 ps -ax
> 30996 pts/6    S+     0:00 tail
>
> 0 ;-)
> roger@localhost2 ~ $ echo $BASH_SUBSHELL
> 0
>
> 0 ;-)
> roger@localhost2 ~ $ exit
> exit
>
> 0 ;-)
> roger@localhost2 ~ $
>
> --
> Roger
> http://rogerx.freeshell.org/
>
>



-- 
Visit serverfault.com to get your system administration questions answered.



Re: BASH_SUBSHELL count not counting?

2011-08-29 Thread Roger
Ah!  That was it, SHLVL.


> On Mon, Aug 29, 2011 at 07:52:33PM -0500, Dennis Williamson wrote:
>By the way, you might find
>
>ps fx
>
>to be more useful in this case.

-- 
Roger
http://rogerx.freeshell.org/