28 February 2009

Link to a shell escaping tutorial

A nearby LUG member just posted to the LUG's mailing list an explanation of how bash expands variables containing special characters and how various utilities interpret them. Give it a read. How to handle newlines was something I never thought about.


2 comments:

massysett said...

zsh fares much better in these situations. See e.g.

http://zsh.dotsrc.or/FAQ/zshfaq03.html#l18

Another reason I stick with zsh for interactive use.

massysett said...

Whoops, url got mangled in last comment. Blogger wants to wrap it; oh well.

http://zsh.dotsrc.org/FAQ/zshfaq03.html#l18

The designer of the fish shell also paid attention to these issues.

http://arstechnica.com/open-source/news/2005/12/linux-20051218.ars/3

I'm pretty hard on bash but I honestly see no reason to use it. Unlike straight sh, it's not portable; unlike fish, it carries the huge design warts of the past; unlike zsh, it's not as powerful for interactive use; unlike ksh, it's slow. It has the worst of all worlds and the biggest reason it's still in widespread use is just inertia--there was a time when it was the only free shell, but times have changed.