printf.md: support %q

This commit is contained in:
Zhuoxun Yang 2023-11-09 10:16:53 +08:00
parent 91a91458e7
commit 7279bc1741

View file

@ -78,6 +78,9 @@ Fields
second parameter is min-width, integer
output below that width is padded with leading zeroes
* `%q`: ARGUMENT is printed in a format that can be reused as shell input, escaping non-printable
characters with the proposed POSIX $'' syntax.
* `%f` or `%F`: decimal floating point value
* `%e` or `%E`: scientific notation floating point value
* `%g` or `%G`: shorter of specially interpreted decimal or SciNote floating point value.
@ -181,6 +184,11 @@ All string fields have a 'max width' parameter
still be interpreted and not throw a warning, you will have problems if you use this for a
literal whose code begins with zero, as it will be viewed as in `\\0NNN` form.)
* `%q`: escaped string - the string in a format that can be reused as input by most shells.
Non-printable characters are escaped with the POSIX proposed $'' syntax,
and shell meta-characters are quoted appropriately.
This is an equivalent format to ls --quoting=shell-escape output.
#### CHAR SUBSTITUTIONS
The character field does not have a secondary parameter.