dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Printf %q
@ 2022-03-28  4:45 Björn Bidar
  2022-03-28  6:11 ` Harald van Dijk
  0 siblings, 1 reply; 2+ messages in thread
From: Björn Bidar @ 2022-03-28  4:45 UTC (permalink / raw)
  To: dash

Hey,

Bash and Coreutils support print %q to quote a string for it to be used as 
shell input.

"%q     ARGUMENT is printed in a format that can be reused as shell input, 
escaping non-printable characters with the proposed POSIX $'' syntax."

Dash also supports the $' ' syntax used by this. Where was this proposed to 
POSIX?

Would it make sense to also support printf %q dash already supports $' '.


Br,

Björn Bidar

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Printf %q
  2022-03-28  4:45 Printf %q Björn Bidar
@ 2022-03-28  6:11 ` Harald van Dijk
  0 siblings, 0 replies; 2+ messages in thread
From: Harald van Dijk @ 2022-03-28  6:11 UTC (permalink / raw)
  To: Björn Bidar, dash

On 28/03/2022 05:45, Björn Bidar wrote:
> Dash also supports the $' ' syntax used by this.

Does it? As far as I can see, dash does not support the $' ' syntax. 
With the $' ' syntax,

   newline=$'\n'

assigns to newline a string of length 1 containing a newline character. 
In dash, what happens instead is that newline is assigned a string of 
length 3 containing the characters $, \, and n.

Tested with current master, commit 057cd650.

Cheers,
Harald van Dijk

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-28  6:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  4:45 Printf %q Björn Bidar
2022-03-28  6:11 ` Harald van Dijk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).