summaryrefslogtreecommitdiffstats
path: root/usr.bin/printf/printf.1
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-04-23 02:56:16 +0000
committerjmallett <jmallett@FreeBSD.org>2002-04-23 02:56:16 +0000
commitd1fecdf4b5c7d9df339be033cf31854a4efe87e1 (patch)
treeef203ec3521897b58e9197ef37d23863b0a45e19 /usr.bin/printf/printf.1
parentccf61115c4dedb35a7931b0d4d8846a8dfb5c4e5 (diff)
downloadFreeBSD-src-d1fecdf4b5c7d9df339be033cf31854a4efe87e1.zip
FreeBSD-src-d1fecdf4b5c7d9df339be033cf31854a4efe87e1.tar.gz
- printf shouldn't bail out if a conversion fails, it should just keep
processing them. - \c escape to immediately stop output (similar to echo's \c) - \0NNN should be allowed for octal character escapes (instead of just \NNN) - %b conversion, which is like %s but interprets \n \t etc. inside the string is missing. And I may not be any poet, but in lieu of an in-tree regression test: ref5% ./printf '%s%b%b%c%s%d\n' 'PR' '\0072' '\t' '3' '56' 0x10 PR: 35616 Submitted by: tjr MFC after: 1 week
Diffstat (limited to 'usr.bin/printf/printf.1')
-rw-r--r--usr.bin/printf/printf.132
1 files changed, 27 insertions, 5 deletions
diff --git a/usr.bin/printf/printf.1 b/usr.bin/printf/printf.1
index abeac55..cea67da 100644
--- a/usr.bin/printf/printf.1
+++ b/usr.bin/printf/printf.1
@@ -62,7 +62,8 @@ The
.Ar arguments
after the first are treated as strings if the corresponding format is
either
-.Cm c
+.Cm c ,
+.Cm b
or
.Cm s ;
otherwise it is evaluated as a C constant, with the following extensions:
@@ -71,8 +72,8 @@ otherwise it is evaluated as a C constant, with the following extensions:
.It
A leading plus or minus sign is allowed.
.It
-If the leading character is a single or double quote, or not a digit,
-plus, or minus sign, the value is the ASCII code of the next character.
+If the leading character is a single or double quote the value is the ASCII
+code of the next character.
.El
.Pp
The format string is reused as often as necessary to satisfy the
@@ -81,7 +82,8 @@ Any extra format specifications are evaluated with zero or the null
string.
.Pp
Character escape sequences are in backslash notation as defined in the
-.St -ansiC .
+.St -ansiC ,
+with extensions.
The characters and their meanings
are as follows:
.Pp
@@ -90,6 +92,8 @@ are as follows:
Write a <bell> character.
.It Cm \eb
Write a <backspace> character.
+.It Cm \ec
+Ignore remaining characters in this string.
.It Cm \ef
Write a <form-feed> character.
.It Cm \en
@@ -105,6 +109,7 @@ Write a <single quote> character.
.It Cm \e\e
Write a backslash character.
.It Cm \e Ns Ar num
+.It Cm \e0 Ns Ar num
Write an 8-bit character whose
.Tn ASCII
value is the 1-, 2-, or 3-digit
@@ -187,7 +192,7 @@ from a string; if the digit string is missing, the precision is treated
as zero;
.It Format:
A character which indicates the type of format to use (one of
-.Cm diouxXfwEgGcs ) .
+.Cm diouxXfwEgGcsb ) .
.El
.Pp
A field width or precision may be
@@ -244,6 +249,11 @@ Characters from the string
are printed until the end is reached or until the number of characters
indicated by the precision specification is reached; however if the
precision is 0 or missing, all characters in the string are printed.
+.It Cm b
+As for
+.Cm s ,
+but interpret character escapes in backslash notation in the string
+.Ar argument .
.It Cm \&%
Print a `%'; no argument is used.
.El
@@ -257,8 +267,20 @@ a field; padding takes place only if the specified field width exceeds
the actual width.
.Sh DIAGNOSTICS
.Ex -std
+.Sh COMPATIBILITY
+The traditional
+.Bx
+behavior of converting arguments of numeric formats not beginning
+with a digit to the ASCII code of the first characer is not supported.
.Sh SEE ALSO
+.Xr echo 1 ,
.Xr printf 3
+.Sh STANDARDS
+The
+.Nm
+command is expected to be compatible with the
+.St -p1003.2
+specification.
.Sh HISTORY
The
.Nm
OpenPOWER on IntegriCloud