Timeline for How to show how many times bash has been invoked? [duplicate]
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 3, 2020 at 19:46 | comment | added | jesse_b | @user5359531: all the linked answers also cover SHLVL | |
| Jan 3, 2020 at 19:44 | comment | added | G-Man Says 'Reinstate Monica' | See also How many shells deep I am? | |
| Jan 3, 2020 at 19:22 | comment | added | terdon♦ | @user5359531 OK, I added unix.stackexchange.com/questions/3212/… as a duplicate target as well. Those two combined should cover everything. | |
| Jan 3, 2020 at 19:21 | history | duplicates list edited | terdon♦ | duplicates list edited from How can I detect if I'm in a subshell? to How to know the "level" of shells I am in?, How can I detect if I'm in a subshell? | |
| Jan 3, 2020 at 19:20 | review | Reopen votes | |||
| Jan 3, 2020 at 19:46 | |||||
| Jan 3, 2020 at 19:04 | history | edited | user5359531 | CC BY-SA 4.0 | added 53 characters in body |
| Jan 3, 2020 at 19:01 | comment | added | user5359531 | @terdon I updated my post to demonstrate why the $BASH_SUBSHELL answers proposed do not work. Its not starting a new subshell so the variable $BASH_SUBSHELL does not change. However the variable SHLVL does reflect this. So, this is not solved by the answers in the proposed duplicate. @steeldriver's solution works, I can accept it if he posts it as an answer | |
| Jan 3, 2020 at 17:52 | comment | added | terdon♦ | You probably want $BASH_SUBSHELL from the answers of the duplicate. Also, please let me know if the duplicate's answers don't solve your issue or you feel I closed this incorrectly. | |
| Jan 3, 2020 at 17:52 | history | closed | jesse_b terdon♦ bash Users with the bash badge or a synonym can single-handedly close bash questions as duplicates and reopen them as needed. | Duplicate of How can I detect if I'm in a subshell? | |
| Jan 3, 2020 at 16:20 | review | Close votes | |||
| Jan 3, 2020 at 17:55 | |||||
| Jan 3, 2020 at 16:16 | comment | added | Kusalananda♦ | To avoid having SHLVL increase by 2, use exec bash instead of just bash. | |
| Jan 3, 2020 at 16:09 | comment | added | jesse_b | @user5359531: The script itself is a child shell then you execute bash inside it creating another child shell. | |
| Jan 3, 2020 at 16:09 | history | edited | user5359531 | CC BY-SA 4.0 | added 362 characters in body |
| Jan 3, 2020 at 16:07 | comment | added | user5359531 | also strangely, $SHLVL increases by 2 every time I run this kind of script | |
| Jan 3, 2020 at 16:03 | comment | added | user5359531 | looks like the $SHLVL one works, if you want to make that an answer @steeldriver. I tried the ones comparing the bash process ID values but they did not seem to be working either, I think because its not a true 'subshell' invoked with () | |
| Jan 3, 2020 at 15:59 | comment | added | steeldriver | Perhaps $SHLVL is what you want? see for example Why does the value of BASH_SUBSHELL not change while the value of SHLVL changes? | |
| Jan 3, 2020 at 15:49 | history | asked | user5359531 | CC BY-SA 4.0 |