

Why Bash is like that: Subshells - ehamberg
http://www.vidarholen.net/contents/blog/?p=178

======
dfc
I noticed that the author uses cmd.exe in one of the charts. I wonder if this
is a stumbling point for people moving to linux. As it is none of this
surprised me or needed any explanation.

Why would I want a shell script to change my $CWD after the shell script
exits?

~~~
spudlyo
_Why would I want a shell script to change my $CWD after the shell script
exits?_

Maybe you wanted a script that would use shortcuts to take you to cumbersome
directory paths?

I enjoyed this article, even though some of it was review. I didn't know that
anything in a pipeline got its own separate subshell in bash, and that
different shells behaved differently in that regard. I'm always happy to learn
interesting uses for process substitution, and got a kick out of:

    
    
        read sum < <(echo "2+3" | bc)
    

Good stuff.

~~~
dfc
For cumbersome directory paths:

    
    
      $ tail -1 ~/.bash_aliases 
      CMBRSM=/opt/var/dont-know-about-FHS/local/etc/cache/config
      $ cd $CMBRSM
    

Unlike a shell script an alias allows you to:

    
    
      $ ls $CMBRSM/subdirectory
      $ cat $CMBRSM/file.txt

------
tzaman
Thanx for the explanation, however Bash is slowly losing fight with ever more
popular ZSH (and oh-my-zsh on top of it)

~~~
CJefferson
Is that your experience? Where I work, I know at least 6 people who switched
to zsh, and only one who is still there (everyone else is back on bash).

The main problem seems to be that the benefits don't outweigh the problems.
The two things which did zsh in for me is finding it not installed on remote
machines, and not being able to use it to distribute scripts. On the other
hand, bash is everywhere and almost as good.

~~~
tzaman
Yes, that's my experience - nearly all my developer mates switched to ZSH
(including me) and never looked back. It's perfectly fine that it's not
installed on remote machines, it's not that different from bash for basic
stuff - in fact I switched from Bash to ZSH on a couple of machines and nobody
even noticed. I find it a significant productivity improvement and had no
problems at all.

