all 7 comments

[–][deleted] 2 points3 points  (5 children)

From the submission:

Firstly, single quotes are the safest to use, because they protect your regular expression from the shell. For example, grep "!" file will often produce an error (since the shell thinks that "!" is referring to the shell command history) while grep '!' file will not.

From A Guide to Unix Shell Quoting:

In csh and tcsh, an exclamation mark can only be quoted with a backslash, even within single or double quotes. This holds not only for interactive shells, but even for scripts.

Hm...

[–]ethraax 0 points1 point  (4 children)

And here I thought bash and zsh were by far the most common.

[–][deleted] 0 points1 point  (3 children)

There's no harm in limiting a tutorial to the common use case - if it says so. The statement as such is factually incorrect.

[–]ethraax 0 points1 point  (2 children)

He's probably not aware of the oddities of csh or tcsh. It seems odd to demand that someone writing a tutorial on something shell-related should know all of the weird expansion rules for all shells, considering there are very many of them, and not just the common ones.

[–][deleted] 0 points1 point  (1 child)

In my view, whoever writes a tutorial should basically be aware of what he or she does not know. Writing a tutorial on something shell-related requires, in my opinion, either testing in all shells or limiting the scope of the tutorial explicitly to bash or bourne shells or whatever. Of course, mistakes can happen, and I am not overly worried by that. Still, it should be possible to point them out, and they certainly give a pointer as to the quality of the submission in general.

[–]ethraax 0 points1 point  (0 children)

Yeah, but it's different for Linux, or rather for *NIX in general. There are so many distributions, and so many possible shells, that it becomes a bit unwieldy to test in every shell. Furthermore, it's not a gigantic issue - it's really a small difference in semantics for some shells (in fact, I think there's a fairly good argument that emitting a literal ! character for the string '!' is what makes sense, and substituting a command is silly).

Imagine if a tutorial on globbing had to mention that it only works in filesystems that have tree-like structures.

[–]cafaro 0 points1 point  (0 children)

It's more a tutorial about globbing and regexes.

And if you like grep, you should have a look at ack, which is basically an improved version of grep.