Hoi.
[2020-01-19 14:22] Grant Taylor via TUHS <tuhs(a)minnie.tuhs.org>
Have you ever used shell level, $SHLVL, in your weekly ~> daily use of Unix?
What's the use of it? The only use of $SHLVL I can think of is the
answer to the question if ^D will close the last shell or just a
sub shell. I hardly ever ask myself this question. Probably that
starts to become relevant when you open sub shells frequently.
Someone also mentioned quickly starting a new
sub-shell from the current
shell for quick transient tasks, i.e. dc / bc, mount / cp / unmount,
{,r,s}cp, etc., in an existing terminal window to avoid cluttering that
first terminals history with the transient commands.
With tmux or screen at hand, this use case is obsolete for me.
(Besides, my shell doesn't know about $SHLVL.)
This all pretty much depends on your working habits, of course.
For instance, I never use history expansion but search the
history frequently, thus additional entries in the shell history
are no problem. I rather like to have all shell histories merged
into one for having search access to all the commands I executed.
This seems to be more of a modern shell usage concept.
Job control, OTOH, I use a lot, to suspend the editor, grep for
something, resume the editor, and the like. Which seems to be more
of an older style usage concept.
That got me to wondering if there were other uses for
shell level
($SHLVL). Hence my question.
I'm interested as well, as I've got difficulties imagine these
uses.
One thing to clarify: Are you looking for uses of the shell
variable $SHLVL or for uses of frequent sub shells?
meillo