Date:        Tue, 14 May 2024 12:41:51 +0300
    From:        Valery Ushakov <[email protected]>
    Message-ID:  <[email protected]>

  | Unfortunately that advice is not true without further caveats.

That you have to actually write a valid printf(1) command, and not
simply s/echo/printf/ ?   Does that really need saying?


  | netbsd$ sh -c "printf '-V\n'"

        printf -- -V\\n 

and it will work anywhere - our printf is specially hacked as once
upon a time it took no options, and this kind of thing would work.
Format strings starting with a '-' don't work in general however,
the '--' should be included if the format might begin with a '-'.

Even better would be

        printf -- %s\\n -V

(where the -- is optional here).

kre

aside: I'd use '-V\n' inside "" as well.   But as a sh -c command
string I'd use:

        sh -c 'printf -- -V\\n'


Reply via email to