Hacker News new | ask | show | jobs
by opk 1532 days ago
The basic unit on which shell scripts build is external commands. If what you want to do is to tie a few together, it is by far the best tool. For the type of programming problem where you need data structures it is indeed awful. But things like Python are really quite poor when it comes to executing external commands. You either need a dozen lines for each external command or things are done in a crap way with commands running synchronously when they don't need to be. With many real languages, people use a `system()` function that is running sh every time along with evaluation because the alternative is fork/exec/wait etc.

Many of those sh tricks you link to are better even in the common ksh/bash/zsh subset than in pure POSIX.

1 comments

My point is that the shell would be a much better tool if the language could be expressed with a simple, LR-parsed yacc grammar.

Because the shell needs such an advanced parser, it shows that the language is full of ambiguity and pitfalls.

The slides for the parent presentation have this gem:

Quiz: Which is the command that outputs \\ ?

1 echo "\\\"

2 echo "\\\\"

3 echo "\\\\\\"

The language should be clearer, and less ambiguous.