diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-11-03 12:56:22 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:30:15 +0000 |
commit | 5ef08864113505c6392158c9fac9a6cb1b3ac0e6 (patch) | |
tree | 03989580af0b143935d1319e69f6fd519d880aab /doc/coreutils.texi | |
parent | 697b8ce26549cceffa8745a1dc0f13654173c575 (diff) | |
download | coreutils-5ef08864113505c6392158c9fac9a6cb1b3ac0e6.tar.xz |
printf: support the %q format to quote for shell
* src/printf.c (usage): Mention the new format.
(print_formatted): Handle the quoting by calling
out to the quotearg module with "shell-escape" mode.
* doc/coreutils.texi (printf invocation): Document %q.
* tests/misc/printf-quote.sh: New test.
* tests/local.mk: Reference new test.
* NEWS: Mention the new feature.
Diffstat (limited to 'doc/coreutils.texi')
-rw-r--r-- | doc/coreutils.texi | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 177379b38..8618a6457 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -12075,7 +12075,7 @@ one. @item @kindex %b -@command{printf} has an additional directive, @samp{%b}, which prints its +An additional directive @samp{%b}, prints its argument string with @samp{\} escapes interpreted in the same way as in the @var{format} string, except that octal escapes are of the form @samp{\0@var{ooo}} where @var{ooo} is 0 to 3 octal digits. If @@ -12084,6 +12084,14 @@ If a precision is also given, it limits the number of bytes printed from the converted string. @item +@kindex %q +An additional directive @samp{%q}, prints its argument string +in a format that can be reused as input by most shells. +Non-printable characters are escaped with the POSIX proposed @samp{$''} syntax, +and shell metacharacters are quoted appropriately. +This is an equivalent format to @command{ls --quoting=shell-escape} output. + +@item Numeric arguments must be single C constants, possibly with leading @samp{+} or @samp{-}. For example, @samp{printf %.4d -3} outputs @samp{-0003}. |