summaryrefslogtreecommitdiff
path: root/usr.bin/printf/printf.1
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2002-11-24 22:35:38 +0000
committerchristos <christos@NetBSD.org>2002-11-24 22:35:38 +0000
commitc02b3bbdf434f79cb24ea5b28cc64628ed2b7528 (patch)
tree903f03dc56a5a9befcf0cd418043d56f29558e32 /usr.bin/printf/printf.1
parent589ff87f68704ea71c635b0ff1555a7e5eae0f66 (diff)
Fixes from David Laight:
- ansification - format of output of jobs command (etc) - job identiers %+, %- etc - $? and $(...) - correct quoting of output of set, export -p and readonly -p - differentiation between nornal and 'posix special' builtins - correct behaviour (posix) for errors on builtins and special builtins - builtin printf and kill - set -o debug (if compiled with DEBUG) - cd src obj (as ksh - too useful to do without) - unset -e name, remove non-readonly variable from export list. (so I could unset -e PS1 before running the test shell...)
Diffstat (limited to 'usr.bin/printf/printf.1')
-rw-r--r--usr.bin/printf/printf.1103
1 files changed, 87 insertions, 16 deletions
diff --git a/usr.bin/printf/printf.1 b/usr.bin/printf/printf.1
index 87acf11d883..2f1d6250365 100644
--- a/usr.bin/printf/printf.1
+++ b/usr.bin/printf/printf.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: printf.1,v 1.16 2002/09/30 11:09:09 grant Exp $
+.\" $NetBSD: printf.1,v 1.17 2002/11/24 22:35:45 christos Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -64,6 +64,7 @@ The
after the first are treated as strings if the corresponding format is
either
.Cm b ,
+.Cm B ,
.Cm c
or
.Cm s ;
@@ -85,8 +86,7 @@ string.
.Pp
Character escape sequences are in backslash notation as defined in
.St -ansiC .
-The characters and their meanings
-are as follows:
+The characters and their meanings are as follows:
.Bl -tag -width Ds -offset indent
.It Cm \ee
Write an \*[Lt]escape\*[Gt] character.
@@ -106,14 +106,20 @@ Write a \*[Lt]tab\*[Gt] character.
Write a \*[Lt]vertical tab\*[Gt] character.
.It Cm \e\'
Write a \*[Lt]single quote\*[Gt] character.
+.It Cm \e"
+Write a \*[Lt]double quote\*[Gt] character.
.It Cm \e\e
Write a backslash character.
.It Cm \e Ns Ar num
-Write an 8-bit character whose
+Write an 8\-bit character whose
.Tn ASCII
-value is the 1-, 2-, or 3-digit
-octal number
+value is the 1\-, 2\-, or 3\-digit octal number
.Ar num .
+.It Cm \ex Ns Ar xx
+Write an 8\-bit character whose
+.Tn ASCII
+value is the 1\- or 2\-digit hexadecimal number
+.Ar xx .
.El
.Pp
Each format specification is introduced by the percent character
@@ -127,14 +133,15 @@ in the following order:
A `#' character
specifying that the value should be printed in an ``alternative form''.
For
-.Cm c ,
+.Cm b ,
+.Cm c ,
.Cm d ,
and
-.Cm s ,
+.Cm s
formats, this option has no effect.
For the
.Cm o
-formats the precision of the number is increased to force the first
+format the precision of the number is increased to force the first
character of the output string to a zero.
For the
.Cm x
@@ -149,7 +156,7 @@ For
.Cm f ,
.Cm g ,
and
-.Cm G ,
+.Cm G
formats, the result will always contain a decimal point, even if no
digits follow the point (normally, a decimal point only appears in the
results of those formats if a digit follows the decimal point).
@@ -158,7 +165,11 @@ For
and
.Cm G
formats, trailing zeros are not removed from the result as they
-would otherwise be;
+would otherwise be.
+.\" I turned this off - decided it isn't a valid use of '#'
+.\" For the
+.\" .Cm B
+.\" format, backslash-escape sequences are expanded first;
.It Cm \&\-
A minus sign `\-' which specifies
.Em left adjustment
@@ -193,11 +204,18 @@ for
and
.Cm f
formats, or the maximum number of characters to be printed
-from a string; if the digit string is missing, the precision is treated
+from a string
+.Sm off
+.Pf ( Cm b No ,
+.Sm on
+.Cm B
+and
+.Cm s
+formats); 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 diouxXfwEgGbcs ) .
+.Cm diouxXfwEgGbBcs ) .
.El
.Pp
A field width or precision may be
@@ -251,6 +269,48 @@ whichever gives full precision in minimum space.
Characters from the string
.Ar argument
are printed with backslash-escape sequences expanded.
+.br
+The following additional backslash-escape sequences are supported:
+.Bl -tag -width Ds
+.It Cm \ec
+Causes
+.Nm
+to ignore any remaining characters in the string operand containing it,
+any remaining string operands, and any additional characters in
+the format operand.
+.It Cm \e0 Ns Ar num
+Write an 8\-bit character whose
+.Tn ASCII
+value is the 1\-, 2\-, or 3\-digit
+octal number
+.Ar num .
+.It Cm \e^ Ns Ar c
+Write the control character
+.Ar c .
+Generates characters `\e000' through `\e037`, and `\e177' (from `\e^?').
+.It Cm \eM\- Ns Ar c
+Write the character
+.Ar c
+with the 8th bit set.
+Generates characters `\e241' through `\e376`.
+.It Cm \eM^ Ns Ar c
+Write the control character
+.Ar c
+with the 8th bit set.
+Generates characters `\e000' through `\e037`, and `\e177' (from `\eM^?').
+.El
+.It Cm B
+Characters from the string
+.Ar argument
+are printed with unprintable characters backslash-escaped using the
+.Sm off
+.Pf ` Cm \e Ar c No ',
+.Pf ` Cm \e^ Ar c No ',
+.Pf ` Cm \eM\- Ar c No '
+or
+.Pf ` Cm \eM^ Ar c No ',
+.Sm on
+formats described above.
.It Cm c
The first character of
.Ar argument
@@ -259,8 +319,8 @@ is printed.
Characters from the string
.Ar argument
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.
+indicated by the precision specification is reached; if the
+precision is omitted, all characters in the string are printed.
.It Cm \&%
Print a `%'; no argument is used.
.El
@@ -275,13 +335,24 @@ exits 0 on success, 1 on failure.
.Xr echo 1 ,
.Xr printf 3 ,
.Xr printf 9
+.Xr vis 3
.Sh STANDARDS
The
.Nm
utility conforms to
-.St -p1003.2-92 .
+.St -p1003.1-2001 .
+.Pp
+Support for the floating point formats and `*' as a field width and precision
+are optional in POSIX.
+.Pp
+The behaviour of the %B format and the \e', \e", \exxx, \ee and
+\e[M][\-|^]c escape sequences are undefined in POSIX.
.Sh BUGS
Since the floating point numbers are translated from
.Tn ASCII
to floating-point and
then back again, floating-point precision may be lost.
+.Pp
+Hexadecimal character constants are restricted to, and should be specified
+as, two character constants. This is contrary to the ISO C standard but
+does guarantee detection of the end of the constant.