Hacker News new | ask | show | jobs
by alganet 1276 days ago
They mentioned "20 ways of doing things", I'm replying to that complaint.

Quoting is an issue if you don't understand the IFS and command expansion. It's an old fashioned style, but it is consistent and there's only one way of doing it (quoting every variable and subshell use).

Think of shell variables as non first-class citizens, they can only be used interpolated within a string, like "$var". The shellcheck tool enforces this perspective, which makes ' and " behave very much like python or JS.

1 comments

To give a more solid example, they don't understand why

  npm test
works and why they don't need

  npm "test"
That's just lazy. How that works is on any shell man page. If you fiddle with it a little bit you figure it out:

    set -- "foo"
    echo $#
    set -- foo
    echo $#
    set -- "foo bar"
    echo $#
    set -- foo bar
    echo $#
Of course, people just want their commands to run and not learn a whole new language. Then I come back to my initial point: the language itself is small and easy to remember once you internalize it, what makes it scary is the umbrella of different command line utilities that _seems_ to be a part of the language but it's not.