lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 66fe46b 03/18: Resolve more shellcheck "S


From: Greg Chicares
Subject: Re: [lmi] [lmi-commits] master 66fe46b 03/18: Resolve more shellcheck "SC1117" warnings
Date: Thu, 30 May 2019 13:35:21 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 2019-05-29 23:10, Vadim Zeitlin wrote:
> On Wed, 29 May 2019 18:49:07 -0400 (EDT) Greg Chicares <address@hidden> wrote:
[...]
> GC> commit 66fe46b85a63a552925fcc4b4d300034265c22fe
[...]
> GC> -printf "all permissions forced\n"
> GC> +printf '%s\n' "all permissions forced"
[...]
> when it would seem that
> 
>       printf 'foo bar\n'
> 
> would work just as well and be shorter and easier to read and understand?
> Should this really be done for all the future uses of printf in shell
> scripts? Personally I find such use of "%s" very strange and don't see what
> do we gain from it. Could you please explain why is it used?

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
| printf format [argument...]
...
| If the format operand contains no conversion specifications and
| argument operands are present, the results are unspecified.

In this case:
  printf 'foo bar\n'
there is only one operand, which must be 'format'; and it
contains no conversion specification; so isn't its behavior
unspecified? No, wait, I guess not: no 'argument' operand is
present, so
  printf 'foo bar\n'
is okay after all.

Thanks for questioning this: I had misread the standard.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]