Re: [dev] Shell style guide

From: Kamil Cholewiński <harry666t_AT_gmail.com>
Date: Thu, 08 Sep 2016 16:05:04 +0200

On Thu, 08 Sep 2016, Evan Gates <evan.gates_AT_gmail.com> wrote:
> No. $_AT_ is another example of something that _must_ be quoted every
> time. When inside quotes the shell expands it correctly to a word for
> each parameter. Without quotes the shell will do extra word splitting
> and globbing. For example, try this:
>
> nargs() { echo "$#"; }
> set -- foo 'bar baz'
> echo "$#"
> nargs "$_AT_"
> nargs $_AT_
>
> When in a case statement should you not quote? I can't think of any examples.

Wow, shell quoting is just fucked up crazy. I was mostly using unquoted
$_AT_ my whole life. And here I thought I knew enough not to screw up a
simple script, but there just always seems to be a new hidden gotcha.

Perhaps we should start with a simple, minimalistic list of allowed
constructs, and make it a policy to use rc/c for anything else?

(Also, isn't this how C++ was finally outlawed here? long long time ago?
People trying to agree which subset was "sane" and ultimately deciding
none of it was?)

<3,K.
Received on Thu Sep 08 2016 - 16:05:04 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 08 2016 - 16:12:12 CEST