pkgsrc-Users archive

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

Re: Guide, Programming in Makefiles: Why trailing '' in example 3?

    Date:        Fri, 11 May 2018 15:26:36 -0500
    From:        "J. Lewis Muir" <>
    Message-ID:  <>

  |   printf '%s\n' ${STRING:Q}''
  | What is the purpose of the two trailing single quote characters?

They make sure that the argument does not vanish completely, even
if STRING is empty (the :Q quotes meta-chars, I don't think it quotes
nothing).  If ${STRING::Q} produces something, the appended null
string changes nothing.  IIf it produces nothing the '' ensures that
there's an arg to match the %s in printf - not that printf actually cares,
if the arg is missing, printf assumes '' (or 0 for numeric conversions)
but other commands might.

And Joerg - with the example being printf, the "ask yourself: doesn't
really help, as
	printf '%s\n'
	printf '%s\n' ''
do the exact same thing.


Home | Main Index | Thread Index | Old Index