Source-Changes-D archive

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

Re: CVS commit: src/usr.bin/printf



    Date:        Fri, 26 Jun 2020 22:05:05 +0000
    From:        "Valeriy E. Ushakov" <uwe%netbsd.org@localhost>
    Message-ID:  <20200626220505.E9030FB28%cvs.NetBSD.org@localhost>

  | Modified Files:
  | 	src/usr.bin/printf: printf.1
  |
  | Log Message:
  | Drop redundant quoting in the nested printf example.

I don't think that is correct, the quotes around 0x0A were obviously
redundant (and changing it to 0x0a doesn't alter that), but those
around the $(printf ...) are not - without those the result from the
command substitution would be subject to field splitting, and if IFS
happens to contain a \ or an octal digit, bad things will happen.

In general it is never a good idea to omit quotes around sh word
expansions except in the cases where you actually want field splitting
(or pathname expansion, etc) to happen (and sometimes except in the
contexts where those don't occur anyway, like x=$whatever)

For the example in question, try running it with IFS=1 or IFS=2
to see what I mean.

kre



Home | Main Index | Thread Index | Old Index