commit bash-20050317 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:44:53 -05:00
parent af91506ad6
commit 3ee6b87dbc
25 changed files with 2906 additions and 2118 deletions
+25
View File
@@ -11183,3 +11183,28 @@ lib/sh/zread.c
builtins/evalstring.c
- don't allow parse_and_execute to short-circuit and call exec() if
the command's return value is being inverted
3/15
----
builtins/printf.def
- new macro PC to call putchar and increment number of chars printed -
fixes bug in computation of value for %n format char
- `tw' is now a global var so printstr can modify it using PC()
- convert PF macro to use asprintf into a local buffer
Preparation for printf -v var
- add code to add the text printed to a `variable buffer' if -v option
supplied. The buffer grows as needed
- printf now takes a `-v var' option to put the output into the variable
VAR rather than sending it to stdout. It does not:
print partial output on error (e.g., format string error)
handle NULs in the variable value, as usual
3/16
----
parse.y
- fix bug in prompt string decoding that caused a core dump when PS1
contained \W and PWD was unset (null pointer deref)
builtins/printf.def
- changed -v var behavior so it stores partial output into the named
variable upon an error
+1
View File
@@ -805,6 +805,7 @@ tests/posix2.tests f
tests/posix2.right f
tests/posixpat.tests f
tests/posixpat.right f
tests/posix-ifs.sh f
tests/prec.right f
tests/precedence f
tests/printf.tests f
+108 -16
View File
@@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
Copyright (C) 1997-2003 Free Software Foundation, Inc.
Copyright (C) 1997-2005 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,7 +23,7 @@ $PRODUCES printf.c
$BUILTIN printf
$FUNCTION printf_builtin
$SHORT_DOC printf format [arguments]
$SHORT_DOC printf [-v var] format [arguments]
printf formats and prints ARGUMENTS under control of the FORMAT. FORMAT
is a character string which contains three types of objects: plain
characters, which are simply copied to standard output, character escape
@@ -32,6 +32,8 @@ format specifications, each of which causes printing of the next successive
argument. In addition to the standard printf(1) formats, %b means to
expand backslash escape sequences in the corresponding argument, and %q
means to quote the argument in a way that can be reused as shell input.
If the -v option is supplied, the output is placed into the value of the
shell variable VAR rather than being sent to the standard output.
$END
#include <config.h>
@@ -74,28 +76,58 @@ $END
extern int errno;
#endif
#define PC(c) \
do { \
char b[2]; \
tw++; \
b[0] = c; b[1] = '\0'; \
if (vflag) \
vbadd (b, 1); \
else \
putchar (c); \
} while (0)
#define PF(f, func) \
do { \
char *b = 0; \
int nw; \
if (have_fieldwidth && have_precision) \
tw += printf(f, fieldwidth, precision, func); \
nw = asprintf(&b, f, fieldwidth, precision, func); \
else if (have_fieldwidth) \
tw += printf(f, fieldwidth, func); \
nw = asprintf(&b, f, fieldwidth, func); \
else if (have_precision) \
tw += printf(f, precision, func); \
nw = asprintf(&b, f, precision, func); \
else \
tw += printf(f, func); \
nw = asprintf(&b, f, func); \
tw += nw; \
if (b) \
{ \
if (vflag) \
(void)vbadd (b, nw); \
else \
(void)fputs (b, stdout); \
free (b); \
} \
} while (0)
/* We free the buffer used by mklong() if it's `too big'. */
#define PRETURN(value) \
do \
{ \
if (vflag) \
bind_variable (vname, vbuf, 0); \
if (conv_bufsize > 4096 ) \
{ \
free(conv_buf); \
free (conv_buf); \
conv_bufsize = 0; \
conv_buf = 0; \
} \
if (vbsize > 4096) \
{ \
free (vbuf); \
vbsize = 0; \
vbuf = 0; \
} \
fflush (stdout); \
return (value); \
} \
@@ -108,6 +140,7 @@ static void printf_erange __P((char *));
static int printstr __P((char *, char *, int, int, int));
static int tescape __P((char *, char *, int *));
static char *bexpand __P((char *, int, int *, int *));
static char *vbadd __P((char *, int));
static char *mklong __P((char *, char *, size_t));
static int getchr __P((void));
static char *getstr __P((void));
@@ -132,6 +165,14 @@ static WORD_LIST *garglist;
static int retval;
static int conversion_error;
/* printf -v var support */
static int vflag = 0;
static char *vbuf, *vname;
static size_t vbsize;
static int vblen;
static intmax_t tw;
static char *conv_buf;
static size_t conv_bufsize;
@@ -141,14 +182,35 @@ printf_builtin (list)
{
int ch, fieldwidth, precision;
int have_fieldwidth, have_precision;
intmax_t tw;
char convch, thisch, nextch, *format, *modstart, *fmt, *start;
conversion_error = 0;
retval = EXECUTION_SUCCESS;
if (no_options (list))
return (EX_USAGE);
vflag = 0;
reset_internal_getopt ();
while ((ch = internal_getopt (list, "v:")) != -1)
{
switch (ch)
{
case 'v':
if (legal_identifier (vname = list_optarg))
{
vflag = 1;
vblen = 0;
}
else
{
sh_invalidid (vname);
return (EX_USAGE);
}
break;
default:
builtin_usage ();
return (EX_USAGE);
}
}
list = loptend; /* skip over possible `--' */
if (list == 0)
@@ -161,6 +223,7 @@ printf_builtin (list)
return (EXECUTION_SUCCESS);
format = list->word->word;
tw = 0;
garglist = list->next;
@@ -189,14 +252,14 @@ printf_builtin (list)
/* A NULL third argument to tescape means to bypass the
special processing for arguments to %b. */
fmt += tescape (fmt, &nextch, (int *)NULL);
putchar (nextch);
PC (nextch);
fmt--; /* for loop will increment it for us again */
continue;
}
if (*fmt != '%')
{
putchar (*fmt);
PC (*fmt);
continue;
}
@@ -205,7 +268,7 @@ printf_builtin (list)
if (*fmt == '%') /* %% prints a % */
{
putchar ('%');
PC ('%');
continue;
}
@@ -544,15 +607,15 @@ printstr (fmt, string, len, fieldwidth, precision)
/* leading pad characters */
for (; padlen > 0; padlen--)
putchar (' ');
PC (' ');
/* output NC characters from STRING */
for (i = 0; i < nc; i++)
putchar (string[i]);
PC (string[i]);
/* output any necessary trailing padding */
for (; padlen < 0; padlen++)
putchar (' ');
PC (' ');
return (ferror (stdout) ? -1 : 0);
}
@@ -712,6 +775,35 @@ bexpand (string, len, sawc, lenp)
return ret;
}
static char *
vbadd (buf, blen)
char *buf;
int blen;
{
size_t nlen;
nlen = vblen + blen + 1;
if (nlen >= vbsize)
{
vbsize = ((nlen + 63) >> 6) << 6;
vbuf = (char *)xrealloc (vbuf, vbsize);
}
if (blen == 1)
vbuf[vblen++] = buf[0];
else
{
FASTCOPY (buf, vbuf + vblen, blen);
vblen += blen;
}
vbuf[vblen] = '\0';
if (strlen (vbuf) != vblen)
internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, strlen (vbuf));
return vbuf;
}
static char *
mklong (str, modifiers, mlen)
char *str;
+332 -329
View File
File diff suppressed because it is too large Load Diff
+6 -3
View File
@@ -6,12 +6,12 @@
.\" Case Western Reserve University
.\" chet@po.CWRU.Edu
.\"
.\" Last Change: Sat Feb 19 17:38:29 EST 2005
.\" Last Change: Tue Mar 15 17:21:41 EST 2005
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2005 Feb 19" "GNU Bash-3.1-devel"
.TH BASH 1 "2005 Mar 15" "GNU Bash-3.1-devel"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -7290,7 +7290,7 @@ is empty, a non-existent directory stack entry is specified, or the
directory change fails.
.RE
.TP
\fBprintf\fP \fIformat\fP [\fIarguments\fP]
\fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
Write the formatted \fIarguments\fP to the standard output under the
control of the \fIformat\fP.
The \fIformat\fP is a character string which contains three types of objects:
@@ -7306,6 +7306,9 @@ beginning with \fB\e0\fP may contain up to four digits),
and \fB%q\fP causes \fBprintf\fP to output the corresponding
\fIargument\fP in a format that can be reused as shell input.
.sp 1
The \fB\-v\fP option causes the output to be assigned to the variable
\fIvar\fP rather than being printed to the standard output.
.sp 1
The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
extra format specifications behave as if a zero value or null string, as
+6 -3
View File
@@ -2,7 +2,7 @@
<TITLE>BASH(1) Manual Page</TITLE>
</HEAD>
<BODY><TABLE WIDTH=100%>
<TH ALIGN=LEFT>BASH(1)<TH ALIGN=CENTER>2005 Feb 19<TH ALIGN=RIGHT>BASH(1)
<TH ALIGN=LEFT>BASH(1)<TH ALIGN=CENTER>2005 Mar 15<TH ALIGN=RIGHT>BASH(1)
</TABLE>
<BR><A HREF="#index">Index</A>
<HR>
@@ -9384,7 +9384,7 @@ is empty, a non-existent directory stack entry is specified, or the
directory change fails.
</DL>
<DT><B>printf</B> <I>format</I> [<I>arguments</I>]<DD>
<DT><B>printf</B> [<B>-v</B> <I>var</I>] <I>format</I> [<I>arguments</I>]<DD>
Write the formatted <I>arguments</I> to the standard output under the
control of the <I>format</I>.
The <I>format</I> is a character string which contains three types of objects:
@@ -9400,6 +9400,9 @@ beginning with <B>\0</B> may contain up to four digits),
and <B>%q</B> causes <B>printf</B> to output the corresponding
<I>argument</I> in a format that can be reused as shell input.
<P>
The <B>-v</B> option causes the output to be assigned to the variable
<I>var</I> rather than being printed to the standard output.
<P>
The <I>format</I> is reused as necessary to consume all of the <I>arguments</I>.
If the <I>format</I> requires more <I>arguments</I> than are supplied, the
extra format specifications behave as if a zero value or null string, as
@@ -11484,6 +11487,6 @@ Array variables may not (yet) be exported.
</DL>
<HR>
This document was created by man2html from bash.1.<BR>
Time: 22 February 2005 13:44:29 EST
Time: 15 March 2005 17:27:07 EST
</BODY>
</HTML>
+598 -593
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+12 -14
View File
@@ -1,6 +1,6 @@
<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created on February, 22 2005 by texi2html 1.64 -->
<!-- Created on March, 15 2005 by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
@@ -33,10 +33,10 @@ Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
<H1>Bash Reference Manual</H1></P><P>
This text is a brief description of the features that are present in
the Bash shell (version 3.1-devel, 19 February 2005)..
the Bash shell (version 3.1-devel, 15 March 2005)..
</P><P>
This is Edition 3.1-devel, last updated 19 February 2005,
This is Edition 3.1-devel, last updated 15 March 2005,
of <CITE>The GNU Bash Reference Manual</CITE>,
for <CODE>Bash</CODE>, Version 3.1-devel.
</P><P>
@@ -4572,7 +4572,7 @@ parent.
<DT><CODE>printf</CODE>
<DD><A NAME="IDX101"></A>
<TABLE><tr><td>&nbsp;</td><td class=example><pre><CODE>printf</CODE> <VAR>format</VAR> [<VAR>arguments</VAR>]
<TABLE><tr><td>&nbsp;</td><td class=example><pre><CODE>printf</CODE> [-v <VAR>var</VAR>] <VAR>format</VAR> [<VAR>arguments</VAR>]
</pre></td></tr></table>Write the formatted <VAR>arguments</VAR> to the standard output under the
control of the <VAR>format</VAR>.
The <VAR>format</VAR> is a character string which contains three types of objects:
@@ -4590,6 +4590,10 @@ and <SAMP>`%q'</SAMP> causes <CODE>printf</CODE> to output the
corresponding <VAR>argument</VAR> in a format that can be reused as shell input.
<P>
The <SAMP>`-v'</SAMP> option causes the output to be assigned to the variable
<VAR>var</VAR> rather than being printed to the standard output.
</P><P>
The <VAR>format</VAR> is reused as necessary to consume all of the <VAR>arguments</VAR>.
If the <VAR>format</VAR> requires more <VAR>arguments</VAR> than are supplied, the
extra format specifications behave as if a zero value or null string, as
@@ -7896,7 +7900,8 @@ example, <CODE>SIGTSTP</CODE>.
<P>
<LI>
Reserved words may not be aliased.
Reserved words appearing in a context where reserved words are recognized
do not undergo alias expansion.
<P>
<LI>
@@ -7971,13 +7976,6 @@ redirection errors, variable assignment errors for assignments preceding
the command name, and so on.
<P>
<LI>
If the <CODE>cd</CODE> builtin finds a directory to change to
using <CODE>$CDPATH</CODE>, the
value it assigns to the <CODE>PWD</CODE> variable does not contain any
symbolic links, as if <SAMP>`cd -P'</SAMP> had been executed.
<P>
<LI>
If <CODE>CDPATH</CODE> is set, the <CODE>cd</CODE> builtin will not implicitly
append the current directory to it. This means that <CODE>cd</CODE> will
@@ -15169,7 +15167,7 @@ to permit their use in free software.
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1>About this document</H1>
This document was generated by <I>Chet Ramey</I> on <I>February, 22 2005</I>
This document was generated by <I>Chet Ramey</I> on <I>March, 15 2005</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
<P></P>
@@ -15331,7 +15329,7 @@ the following structure:
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Chet Ramey</I> on <I>February, 22 2005</I>
by <I>Chet Ramey</I> on <I>March, 15 2005</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
+164 -164
View File
@@ -2,10 +2,10 @@ This is bashref.info, produced by makeinfo version 4.7 from
/Users/chet/src/bash/src/doc/bashref.texi.
This text is a brief description of the features that are present in
the Bash shell (version 3.1-devel, 19 February 2005).
the Bash shell (version 3.1-devel, 15 March 2005).
This is Edition 3.1-devel, last updated 19 February 2005, of `The
GNU Bash Reference Manual', for `Bash', Version 3.1-devel.
This is Edition 3.1-devel, last updated 15 March 2005, of `The GNU
Bash Reference Manual', for `Bash', Version 3.1-devel.
Copyright (C) 1988-2005 Free Software Foundation, Inc.
@@ -37,10 +37,10 @@ Bash Features
*************
This text is a brief description of the features that are present in
the Bash shell (version 3.1-devel, 19 February 2005)..
the Bash shell (version 3.1-devel, 15 March 2005)..
This is Edition 3.1-devel, last updated 19 February 2005, of `The
GNU Bash Reference Manual', for `Bash', Version 3.1-devel.
This is Edition 3.1-devel, last updated 15 March 2005, of `The GNU
Bash Reference Manual', for `Bash', Version 3.1-devel.
Bash contains features that appear in other popular shells, and some
features that only appear in Bash. Some of the shells that Bash has
@@ -2945,7 +2945,7 @@ POSIX 1003.2 standard.
Exit a login shell, returning a status of N to the shell's parent.
`printf'
`printf' FORMAT [ARGUMENTS]
`printf' [-v VAR] FORMAT [ARGUMENTS]
Write the formatted ARGUMENTS to the standard output under the
control of the FORMAT. The FORMAT is a character string which
contains three types of objects: plain characters, which are
@@ -2960,6 +2960,9 @@ POSIX 1003.2 standard.
and `%q' causes `printf' to output the corresponding ARGUMENT in a
format that can be reused as shell input.
The `-v' option causes the output to be assigned to the variable
VAR rather than being printed to the standard output.
The FORMAT is reused as necessary to consume all of the ARGUMENTS.
If the FORMAT requires more ARGUMENTS than are supplied, the extra
format specifications behave as if a zero value or null string, as
@@ -5253,7 +5256,8 @@ startup files.
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
`SIGTSTP'.
4. Reserved words may not be aliased.
4. Reserved words appearing in a context where reserved words are
recognized do not undergo alias expansion.
5. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
number and `!!' to `!' are enabled, and parameter expansion is
@@ -5301,85 +5305,81 @@ startup files.
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
18. If the `cd' builtin finds a directory to change to using
`$CDPATH', the value it assigns to the `PWD' variable does not
contain any symbolic links, as if `cd -P' had been executed.
19. If `CDPATH' is set, the `cd' builtin will not implicitly append
18. If `CDPATH' is set, the `cd' builtin will not implicitly append
the current directory to it. This means that `cd' will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH', even if the a directory with the same name as the name
given as an argument to `cd' exists in the current directory.
20. A non-interactive shell exits with an error status if a variable
19. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
21. A non-interactive shell exits with an error status if the iteration
20. A non-interactive shell exits with an error status if the iteration
variable in a `for' statement or the selection variable in a
`select' statement is a readonly variable.
22. Process substitution is not available.
21. Process substitution is not available.
23. Assignment statements preceding POSIX 1003.2 special builtins
22. Assignment statements preceding POSIX 1003.2 special builtins
persist in the shell environment after the builtin completes.
24. Assignment statements preceding shell function calls persist in the
23. Assignment statements preceding shell function calls persist in the
shell environment after the function returns, as if a POSIX
special builtin command had been executed.
25. The `export' and `readonly' builtin commands display their output
24. The `export' and `readonly' builtin commands display their output
in the format required by POSIX 1003.2.
26. The `trap' builtin displays signal names without the leading `SIG'.
25. The `trap' builtin displays signal names without the leading `SIG'.
27. The `trap' builtin doesn't check the first argument for a possible
26. The `trap' builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they
should use `-' as the first argument.
28. The `.' and `source' builtins do not search the current directory
27. The `.' and `source' builtins do not search the current directory
for the filename argument if it is not found by searching `PATH'.
29. Subshells spawned to execute command substitutions inherit the
28. Subshells spawned to execute command substitutions inherit the
value of the `-e' option from the parent shell. When not in POSIX
mode, Bash clears the `-e' option in such subshells.
30. Alias expansion is always enabled, even in non-interactive shells.
29. Alias expansion is always enabled, even in non-interactive shells.
31. When the `alias' builtin displays alias definitions, it does not
30. When the `alias' builtin displays alias definitions, it does not
display them with a leading `alias ' unless the `-p' option is
supplied.
32. When the `set' builtin is invoked without options, it does not
31. When the `set' builtin is invoked without options, it does not
display shell function names and definitions.
33. When the `set' builtin is invoked without options, it displays
32. When the `set' builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
34. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
33. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from `$PWD' and the directory name supplied as an
argument does not refer to an existing directory, `cd' will fail
instead of falling back to PHYSICAL mode.
35. When the `pwd' builtin is supplied the `-P' option, it resets
34. When the `pwd' builtin is supplied the `-P' option, it resets
`$PWD' to a pathname containing no symlinks.
36. When listing the history, the `fc' builtin does not include an
35. When listing the history, the `fc' builtin does not include an
indication of whether or not a history entry has been modified.
37. The default editor used by `fc' is `ed'.
36. The default editor used by `fc' is `ed'.
38. The `type' and `command' builtins will not report a non-executable
37. The `type' and `command' builtins will not report a non-executable
file as having been found, though the shell will attempt to
execute such a file if it is the only so-named file found in
`$PATH'.
39. When the `xpg_echo' option is enabled, Bash does not attempt to
38. When the `xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to `echo' as options. Each argument is
displayed, after escape characters are converted.
@@ -8994,7 +8994,7 @@ Index of Shell Builtin Commands
(line 58)
* pwd: Bourne Shell Builtins.
(line 163)
* read: Bash Builtins. (line 324)
* read: Bash Builtins. (line 327)
* readonly: Bourne Shell Builtins.
(line 172)
* return: Bourne Shell Builtins.
@@ -9002,8 +9002,8 @@ Index of Shell Builtin Commands
* set: The Set Builtin. (line 9)
* shift: Bourne Shell Builtins.
(line 200)
* shopt: Bash Builtins. (line 385)
* source: Bash Builtins. (line 616)
* shopt: Bash Builtins. (line 388)
* source: Bash Builtins. (line 619)
* suspend: Job Control Builtins.
(line 94)
* test: Bourne Shell Builtins.
@@ -9012,12 +9012,12 @@ Index of Shell Builtin Commands
(line 276)
* trap: Bourne Shell Builtins.
(line 281)
* type: Bash Builtins. (line 620)
* typeset: Bash Builtins. (line 651)
* ulimit: Bash Builtins. (line 657)
* type: Bash Builtins. (line 623)
* typeset: Bash Builtins. (line 654)
* ulimit: Bash Builtins. (line 660)
* umask: Bourne Shell Builtins.
(line 322)
* unalias: Bash Builtins. (line 719)
* unalias: Bash Builtins. (line 722)
* unset: Bourne Shell Builtins.
(line 339)
* wait: Job Control Builtins.
@@ -9488,129 +9488,129 @@ Concept Index

Tag Table:
Node: Top1375
Node: Introduction3537
Node: What is Bash?3766
Node: What is a shell?4859
Node: Definitions7400
Node: Basic Shell Features10141
Node: Shell Syntax11360
Node: Shell Operation12392
Node: Quoting13686
Node: Escape Character14990
Node: Single Quotes15475
Node: Double Quotes15823
Node: ANSI-C Quoting16948
Node: Locale Translation17904
Node: Comments18800
Node: Shell Commands19414
Node: Simple Commands20180
Node: Pipelines20811
Node: Lists22686
Node: Compound Commands24317
Node: Looping Constructs25101
Node: Conditional Constructs27548
Node: Command Grouping35008
Node: Shell Functions36457
Node: Shell Parameters40747
Node: Positional Parameters43077
Node: Special Parameters43977
Node: Shell Expansions46941
Node: Brace Expansion48866
Node: Tilde Expansion51191
Node: Shell Parameter Expansion53542
Node: Command Substitution61051
Node: Arithmetic Expansion62384
Node: Process Substitution63234
Node: Word Splitting64284
Node: Filename Expansion65745
Node: Pattern Matching67881
Node: Quote Removal71206
Node: Redirections71501
Node: Executing Commands79231
Node: Simple Command Expansion79906
Node: Command Search and Execution81836
Node: Command Execution Environment83842
Node: Environment86613
Node: Exit Status88273
Node: Signals89477
Node: Shell Scripts91441
Node: Shell Builtin Commands93959
Node: Bourne Shell Builtins95538
Node: Bash Builtins112491
Node: The Set Builtin141325
Node: Special Builtins149732
Node: Shell Variables150709
Node: Bourne Shell Variables151149
Node: Bash Variables153130
Node: Bash Features173182
Node: Invoking Bash174065
Node: Bash Startup Files179886
Node: Interactive Shells184744
Node: What is an Interactive Shell?185154
Node: Is this Shell Interactive?185804
Node: Interactive Shell Behavior186619
Node: Bash Conditional Expressions189895
Node: Shell Arithmetic193474
Node: Aliases196220
Node: Arrays198788
Node: The Directory Stack202055
Node: Directory Stack Builtins202769
Node: Printing a Prompt205660
Node: The Restricted Shell208374
Node: Bash POSIX Mode210206
Node: Job Control217657
Node: Job Control Basics218124
Node: Job Control Builtins222500
Node: Job Control Variables226852
Node: Command Line Editing228010
Node: Introduction and Notation229009
Node: Readline Interaction230631
Node: Readline Bare Essentials231822
Node: Readline Movement Commands233611
Node: Readline Killing Commands234576
Node: Readline Arguments236496
Node: Searching237540
Node: Readline Init File239726
Node: Readline Init File Syntax240785
Node: Conditional Init Constructs252644
Node: Sample Init File255177
Node: Bindable Readline Commands258294
Node: Commands For Moving259501
Node: Commands For History260362
Node: Commands For Text263517
Node: Commands For Killing266190
Node: Numeric Arguments268332
Node: Commands For Completion269471
Node: Keyboard Macros273064
Node: Miscellaneous Commands273635
Node: Readline vi Mode278946
Node: Programmable Completion279860
Node: Programmable Completion Builtins285652
Node: Using History Interactively293248
Node: Bash History Facilities293928
Node: Bash History Builtins296623
Node: History Interaction300480
Node: Event Designators303036
Node: Word Designators304051
Node: Modifiers305690
Node: Installing Bash307096
Node: Basic Installation308233
Node: Compilers and Options310925
Node: Compiling For Multiple Architectures311666
Node: Installation Names313330
Node: Specifying the System Type314148
Node: Sharing Defaults314864
Node: Operation Controls315537
Node: Optional Features316495
Node: Reporting Bugs325304
Node: Major Differences From The Bourne Shell326498
Node: Copying This Manual342406
Node: GNU Free Documentation License342682
Node: Builtin Index365088
Node: Reserved Word Index371637
Node: Variable Index374073
Node: Function Index384933
Node: Concept Index391653
Node: Top1369
Node: Introduction3525
Node: What is Bash?3754
Node: What is a shell?4847
Node: Definitions7388
Node: Basic Shell Features10129
Node: Shell Syntax11348
Node: Shell Operation12380
Node: Quoting13674
Node: Escape Character14978
Node: Single Quotes15463
Node: Double Quotes15811
Node: ANSI-C Quoting16936
Node: Locale Translation17892
Node: Comments18788
Node: Shell Commands19402
Node: Simple Commands20168
Node: Pipelines20799
Node: Lists22674
Node: Compound Commands24305
Node: Looping Constructs25089
Node: Conditional Constructs27536
Node: Command Grouping34996
Node: Shell Functions36445
Node: Shell Parameters40735
Node: Positional Parameters43065
Node: Special Parameters43965
Node: Shell Expansions46929
Node: Brace Expansion48854
Node: Tilde Expansion51179
Node: Shell Parameter Expansion53530
Node: Command Substitution61039
Node: Arithmetic Expansion62372
Node: Process Substitution63222
Node: Word Splitting64272
Node: Filename Expansion65733
Node: Pattern Matching67869
Node: Quote Removal71194
Node: Redirections71489
Node: Executing Commands79219
Node: Simple Command Expansion79894
Node: Command Search and Execution81824
Node: Command Execution Environment83830
Node: Environment86601
Node: Exit Status88261
Node: Signals89465
Node: Shell Scripts91429
Node: Shell Builtin Commands93947
Node: Bourne Shell Builtins95526
Node: Bash Builtins112479
Node: The Set Builtin141452
Node: Special Builtins149859
Node: Shell Variables150836
Node: Bourne Shell Variables151276
Node: Bash Variables153257
Node: Bash Features173309
Node: Invoking Bash174192
Node: Bash Startup Files180013
Node: Interactive Shells184871
Node: What is an Interactive Shell?185281
Node: Is this Shell Interactive?185931
Node: Interactive Shell Behavior186746
Node: Bash Conditional Expressions190022
Node: Shell Arithmetic193601
Node: Aliases196347
Node: Arrays198915
Node: The Directory Stack202182
Node: Directory Stack Builtins202896
Node: Printing a Prompt205787
Node: The Restricted Shell208501
Node: Bash POSIX Mode210333
Node: Job Control217663
Node: Job Control Basics218130
Node: Job Control Builtins222506
Node: Job Control Variables226858
Node: Command Line Editing228016
Node: Introduction and Notation229015
Node: Readline Interaction230637
Node: Readline Bare Essentials231828
Node: Readline Movement Commands233617
Node: Readline Killing Commands234582
Node: Readline Arguments236502
Node: Searching237546
Node: Readline Init File239732
Node: Readline Init File Syntax240791
Node: Conditional Init Constructs252650
Node: Sample Init File255183
Node: Bindable Readline Commands258300
Node: Commands For Moving259507
Node: Commands For History260368
Node: Commands For Text263523
Node: Commands For Killing266196
Node: Numeric Arguments268338
Node: Commands For Completion269477
Node: Keyboard Macros273070
Node: Miscellaneous Commands273641
Node: Readline vi Mode278952
Node: Programmable Completion279866
Node: Programmable Completion Builtins285658
Node: Using History Interactively293254
Node: Bash History Facilities293934
Node: Bash History Builtins296629
Node: History Interaction300486
Node: Event Designators303042
Node: Word Designators304057
Node: Modifiers305696
Node: Installing Bash307102
Node: Basic Installation308239
Node: Compilers and Options310931
Node: Compiling For Multiple Architectures311672
Node: Installation Names313336
Node: Specifying the System Type314154
Node: Sharing Defaults314870
Node: Operation Controls315543
Node: Optional Features316501
Node: Reporting Bugs325310
Node: Major Differences From The Bourne Shell326504
Node: Copying This Manual342412
Node: GNU Free Documentation License342688
Node: Builtin Index365094
Node: Reserved Word Index371643
Node: Variable Index374079
Node: Function Index384939
Node: Concept Index391659

End Tag Table
+11 -11
View File
@@ -1,4 +1,4 @@
This is TeX, Version 3.14159 (Web2C 7.4.5) (format=tex 2003.12.31) 22 FEB 2005 13:44
This is TeX, Version 3.14159 (Web2C 7.4.5) (format=tex 2003.12.31) 15 MAR 2005 17:26
**/Users/chet/src/bash/src/doc/bashref.texi
(/Users/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
Loading texinfo [version 2003-02-03.16]: Basics,
@@ -185,7 +185,7 @@ m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
.etc.
[39] [40] [41] [42] [43]
Overfull \hbox (43.33536pt too wide) in paragraph at lines 3479--3479
Overfull \hbox (43.33536pt too wide) in paragraph at lines 3482--3482
[]@texttt read [-ers] [-a @textttsl aname@texttt ] [-d @textttsl de-lim@texttt
] [-n @textttsl nchars@texttt ] [-p @textttsl prompt@texttt ] [-t @textttsl ti
me-
@@ -199,7 +199,7 @@ me-
.etc.
[44] [45]
Underfull \hbox (badness 2573) in paragraph at lines 3663--3667
Underfull \hbox (badness 2573) in paragraph at lines 3666--3670
[] []@textrm Error trac-ing is en-abled: com-mand sub-sti-tu-tion, shell
@hbox(7.60416+2.12917)x433.62, glue set 2.95305
@@ -215,7 +215,7 @@ Underfull \hbox (badness 2573) in paragraph at lines 3663--3667
.etc.
[46] [47] [48] [49] [50] [51]
Underfull \hbox (badness 4036) in paragraph at lines 4110--4117
Underfull \hbox (badness 4036) in paragraph at lines 4113--4120
@texttt -x[]@textrm Print a trace of sim-ple com-mands, @texttt \@textrm fB-fo
r@texttt \@textrm fP com-mands,
@@ -229,7 +229,7 @@ r@texttt \@textrm fP com-mands,
[52] [53] Chapter 5 [54] [55] [56] [57] [58] [59] [60] [61] [62] Chapter 6
[63] [64]
Overfull \hbox (51.96864pt too wide) in paragraph at lines 4837--4837
Overfull \hbox (51.96864pt too wide) in paragraph at lines 4840--4840
[]@texttt bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@t
exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -242,7 +242,7 @@ exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
Overfull \hbox (76.23077pt too wide) in paragraph at lines 4838--4838
Overfull \hbox (76.23077pt too wide) in paragraph at lines 4841--4841
[]@texttt bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@texttt
] [-O @textttsl shopt_option@texttt ] -c @textttsl string @texttt [@textttsl ar
-
@@ -256,7 +256,7 @@ Overfull \hbox (76.23077pt too wide) in paragraph at lines 4838--4838
.etc.
Overfull \hbox (34.72258pt too wide) in paragraph at lines 4839--4839
Overfull \hbox (34.72258pt too wide) in paragraph at lines 4842--4842
[]@texttt bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@text
tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -269,7 +269,7 @@ tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
[65] [66]
Underfull \hbox (badness 2245) in paragraph at lines 5013--5015
Underfull \hbox (badness 2245) in paragraph at lines 5016--5018
[]@textrm When a lo-gin shell ex-its, Bash reads and ex-e-cutes com-mands from
the file
@@ -337,7 +337,7 @@ Underfull \hbox (badness 2753) in paragraph at lines 1758--1761
[111]) (/Users/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[112] [113] [114] [115] [116]) Chapter 10 [117] [118] [119] [120] [121]
Underfull \hbox (badness 2772) in paragraph at lines 6715--6719
Underfull \hbox (badness 2772) in paragraph at lines 6713--6717
[]@textrm Enable sup-port for large files (@texttt http://www.sas.com/standard
s/large_
@@ -376,10 +376,10 @@ Overfull \vbox (42.26959pt too high) has occurred while \output is active
Here is how much of TeX's memory you used:
1726 strings out of 98002
23501 string characters out of 1221986
52386 words of memory out of 1000001
52380 words of memory out of 1000001
2577 multiletter control sequences out of 10000+50000
31953 words of font info for 111 fonts, out of 500000 for 1000
19 hyphenation exceptions out of 1000
15i,8n,11p,269b,465s stack positions out of 1500i,500n,5000p,200000b,5000s
Output written on bashref.dvi (158 pages, 587400 bytes).
Output written on bashref.dvi (158 pages, 587404 bytes).
+181 -183
View File
@@ -10,7 +10,7 @@
%DVIPSWebPage: (www.radicaleye.com)
%DVIPSCommandLine: dvips -D 600 -t letter -o bashref.ps bashref.dvi
%DVIPSParameters: dpi=600, compressed
%DVIPSSource: TeX output 2005.02.22:1344
%DVIPSSource: TeX output 2005.03.15:1726
%%BeginProcSet: texc.pro
%!
/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S
@@ -4226,21 +4226,19 @@ letter
TeXDict begin 1 0 bop 150 1318 a Fu(Bash)64 b(Reference)j(Man)-5
b(ual)p 150 1385 3600 34 v 2361 1481 a Ft(Reference)31
b(Do)s(cumen)m(tation)i(for)d(Bash)1963 1589 y(Edition)h(3.1-dev)m(el,)
i(for)d Fs(Bash)f Ft(V)-8 b(ersion)31 b(3.1-dev)m(el.)3180
1697 y(F)-8 b(ebruary)30 b(2005)150 4935 y Fr(Chet)45
b(Ramey)-11 b(,)46 b(Case)g(W)-11 b(estern)46 b(Reserv)l(e)g(Univ)l
(ersit)l(y)150 5068 y(Brian)f(F)-11 b(o)l(x,)45 b(F)-11
b(ree)45 b(Soft)l(w)l(are)h(F)-11 b(oundation)p 150 5141
3600 17 v eop end
i(for)d Fs(Bash)f Ft(V)-8 b(ersion)31 b(3.1-dev)m(el.)3285
1697 y(Marc)m(h)g(2005)150 4935 y Fr(Chet)45 b(Ramey)-11
b(,)46 b(Case)g(W)-11 b(estern)46 b(Reserv)l(e)g(Univ)l(ersit)l(y)150
5068 y(Brian)f(F)-11 b(o)l(x,)45 b(F)-11 b(ree)45 b(Soft)l(w)l(are)h(F)
-11 b(oundation)p 150 5141 3600 17 v eop end
%%Page: 2 2
TeXDict begin 2 1 bop 150 2889 a Ft(This)35 b(text)h(is)g(a)g(brief)f
(description)h(of)f(the)h(features)g(that)g(are)g(presen)m(t)g(in)f
(the)h(Bash)f(shell)h(\(v)m(ersion)150 2999 y(3.1-dev)m(el,)d(19)e(F)-8
b(ebruary)30 b(2005\).)150 3133 y(This)41 b(is)i(Edition)f(3.1-dev)m
(el,)48 b(last)43 b(up)s(dated)e(19)i(F)-8 b(ebruary)42
b(2005,)47 b(of)42 b Fq(The)g(GNU)h(Bash)f(Reference)150
3243 y(Man)m(ual)p Ft(,)32 b(for)e Fs(Bash)p Ft(,)f(V)-8
b(ersion)31 b(3.1-dev)m(el.)150 3377 y(Cop)m(yrigh)m(t)602
(the)h(Bash)f(shell)h(\(v)m(ersion)150 2999 y(3.1-dev)m(el,)d(15)e
(Marc)m(h)g(2005\).)150 3133 y(This)23 b(is)h(Edition)g(3.1-dev)m(el,)k
(last)c(up)s(dated)f(15)i(Marc)m(h)f(2005,)j(of)d Fq(The)g(GNU)g(Bash)g
(Reference)h(Man)m(ual)p Ft(,)150 3243 y(for)30 b Fs(Bash)p
Ft(,)g(V)-8 b(ersion)31 b(3.1-dev)m(el.)150 3377 y(Cop)m(yrigh)m(t)602
3374 y(c)577 3377 y Fp(\015)f Ft(1988-2005)k(F)-8 b(ree)32
b(Soft)m(w)m(are)f(F)-8 b(oundation,)32 b(Inc.)150 3512
y(P)m(ermission)g(is)h(gran)m(ted)g(to)f(mak)m(e)i(and)d(distribute)h
@@ -7796,79 +7794,83 @@ b([)p Fj(n)11 b Fs(])630 5340 y Ft(Exit)31 b(a)g(login)g(shell,)g
(t.)p eop end
%%Page: 44 50
TeXDict begin 44 49 bop 150 -116 a Ft(44)2572 b(Bash)31
b(Reference)g(Man)m(ual)150 299 y Fs(printf)870 445 y(printf)46
b Fj(format)57 b Fs([)p Fj(arguments)11 b Fs(])630 591
y Ft(W)-8 b(rite)27 b(the)g(formatted)f Fq(argumen)m(ts)k
Ft(to)d(the)f(standard)f(output)h(under)e(the)i(con)m(trol)i(of)e(the)
630 701 y Fq(format)p Ft(.)41 b(The)28 b Fq(format)j
Ft(is)e(a)g(c)m(haracter)i(string)d(whic)m(h)h(con)m(tains)h(three)f(t)
m(yp)s(es)g(of)g(ob)5 b(jects:)630 810 y(plain)28 b(c)m(haracters,)j
(whic)m(h)d(are)h(simply)f(copied)h(to)h(standard)d(output,)i(c)m
(haracter)h(escap)s(e)630 920 y(sequences,)g(whic)m(h)f(are)g(con)m(v)m
(erted)i(and)d(copied)i(to)f(the)h(standard)e(output,)h(and)g(format)
630 1029 y(sp)s(eci\014cations,)39 b(eac)m(h)e(of)g(whic)m(h)f(causes)g
(prin)m(ting)g(of)h(the)f(next)h(successiv)m(e)g Fq(argumen)m(t)p
Ft(.)630 1139 y(In)31 b(addition)h(to)h(the)e(standard)g
b(Reference)g(Man)m(ual)150 299 y Fs(printf)870 429 y(printf)46
b([-v)h Fj(var)11 b Fs(])46 b Fj(format)57 b Fs([)p Fj(arguments)11
b Fs(])630 559 y Ft(W)-8 b(rite)27 b(the)g(formatted)f
Fq(argumen)m(ts)k Ft(to)d(the)f(standard)f(output)h(under)e(the)i(con)m
(trol)i(of)e(the)630 669 y Fq(format)p Ft(.)41 b(The)28
b Fq(format)j Ft(is)e(a)g(c)m(haracter)i(string)d(whic)m(h)h(con)m
(tains)h(three)f(t)m(yp)s(es)g(of)g(ob)5 b(jects:)630
778 y(plain)28 b(c)m(haracters,)j(whic)m(h)d(are)h(simply)f(copied)h
(to)h(standard)d(output,)i(c)m(haracter)h(escap)s(e)630
888 y(sequences,)g(whic)m(h)f(are)g(con)m(v)m(erted)i(and)d(copied)i
(to)f(the)h(standard)e(output,)h(and)g(format)630 998
y(sp)s(eci\014cations,)39 b(eac)m(h)e(of)g(whic)m(h)f(causes)g(prin)m
(ting)g(of)h(the)f(next)h(successiv)m(e)g Fq(argumen)m(t)p
Ft(.)630 1107 y(In)31 b(addition)h(to)h(the)e(standard)g
Fs(printf\(1\))f Ft(formats,)i(`)p Fs(\045b)p Ft(')g(causes)g
Fs(printf)e Ft(to)j(expand)630 1249 y(bac)m(kslash)39
Fs(printf)e Ft(to)j(expand)630 1217 y(bac)m(kslash)39
b(escap)s(e)g(sequences)f(in)h(the)f(corresp)s(onding)f
Fq(argumen)m(t)p Ft(,)k(\(except)f(that)f(`)p Fs(\\c)p
Ft(')630 1358 y(terminates)44 b(output,)j(bac)m(kslashes)d(in)f(`)p
Ft(')630 1326 y(terminates)44 b(output,)j(bac)m(kslashes)d(in)f(`)p
Fs(\\')p Ft(',)k(`)p Fs(\\")p Ft(',)g(and)c(`)p Fs(\\?)p
Ft(')g(are)h(not)g(remo)m(v)m(ed,)k(and)630 1468 y(o)s(ctal)25
Ft(')g(are)h(not)g(remo)m(v)m(ed,)k(and)630 1436 y(o)s(ctal)25
b(escap)s(es)f(b)s(eginning)f(with)g(`)p Fs(\\0)p Ft(')h(ma)m(y)g(con)m
(tain)h(up)e(to)h(four)f(digits\),)j(and)d(`)p Fs(\045q)p
Ft(')h(causes)630 1577 y Fs(printf)31 b Ft(to)i(output)f(the)h(corresp)
Ft(')h(causes)630 1545 y Fs(printf)31 b Ft(to)i(output)f(the)h(corresp)
s(onding)f Fq(argumen)m(t)j Ft(in)d(a)h(format)g(that)g(can)g(b)s(e)f
(reused)630 1687 y(as)f(shell)f(input.)630 1833 y(The)h
Fq(format)i Ft(is)f(reused)e(as)i(necessary)f(to)i(consume)e(all)h(of)f
(the)h Fq(argumen)m(ts)p Ft(.)44 b(If)30 b(the)i Fq(for-)630
1943 y(mat)c Ft(requires)e(more)g Fq(argumen)m(ts)k Ft(than)25
b(are)i(supplied,)e(the)h(extra)h(format)f(sp)s(eci\014cations)630
2052 y(b)s(eha)m(v)m(e)j(as)g(if)f(a)h(zero)g(v)-5 b(alue)29
b(or)g(n)m(ull)f(string,)h(as)g(appropriate,)g(had)f(b)s(een)g
(supplied.)38 b(The)630 2162 y(return)29 b(v)-5 b(alue)31
b(is)g(zero)g(on)f(success,)h(non-zero)g(on)f(failure.)150
2345 y Fs(read)870 2491 y(read)47 b([-ers])f([-a)h Fj(aname)11
(reused)630 1655 y(as)f(shell)f(input.)630 1785 y(The)24
b(`)p Fs(-v)p Ft(')h(option)g(causes)g(the)g(output)g(to)g(b)s(e)f
(assigned)h(to)h(the)f(v)-5 b(ariable)25 b Fq(v)-5 b(ar)32
b Ft(rather)24 b(than)630 1895 y(b)s(eing)30 b(prin)m(ted)g(to)h(the)g
(standard)e(output.)630 2025 y(The)i Fq(format)i Ft(is)f(reused)e(as)i
(necessary)f(to)i(consume)e(all)h(of)f(the)h Fq(argumen)m(ts)p
Ft(.)44 b(If)30 b(the)i Fq(for-)630 2134 y(mat)c Ft(requires)e(more)g
Fq(argumen)m(ts)k Ft(than)25 b(are)i(supplied,)e(the)h(extra)h(format)f
(sp)s(eci\014cations)630 2244 y(b)s(eha)m(v)m(e)j(as)g(if)f(a)h(zero)g
(v)-5 b(alue)29 b(or)g(n)m(ull)f(string,)h(as)g(appropriate,)g(had)f(b)
s(een)g(supplied.)38 b(The)630 2354 y(return)29 b(v)-5
b(alue)31 b(is)g(zero)g(on)f(success,)h(non-zero)g(on)f(failure.)150
2504 y Fs(read)870 2634 y(read)47 b([-ers])f([-a)h Fj(aname)11
b Fs(])45 b([-d)i Fj(delim)11 b Fs(])46 b([-n)h Fj(nchars)11
b Fs(])45 b([-p)i Fj(prompt)11 b Fs(])45 b([-t)i Fj(time-)870
2600 y(out)11 b Fs(])46 b([-u)h Fj(fd)11 b Fs(])46 b([)p
Fj(name)57 b Fs(...])630 2746 y Ft(One)26 b(line)h(is)g(read)f(from)h
2744 y(out)11 b Fs(])46 b([-u)h Fj(fd)11 b Fs(])46 b([)p
Fj(name)57 b Fs(...])630 2874 y Ft(One)26 b(line)h(is)g(read)f(from)h
(the)f(standard)g(input,)h(or)g(from)f(the)h(\014le)f(descriptor)h
Fq(fd)i Ft(supplied)630 2856 y(as)37 b(an)g(argumen)m(t)h(to)f(the)h(`)
Fq(fd)i Ft(supplied)630 2984 y(as)37 b(an)g(argumen)m(t)h(to)f(the)h(`)
p Fs(-u)p Ft(')e(option,)k(and)c(the)i(\014rst)e(w)m(ord)g(is)h
(assigned)h(to)f(the)h(\014rst)630 2966 y Fq(name)p Ft(,)29
(assigned)h(to)f(the)h(\014rst)630 3093 y Fq(name)p Ft(,)29
b(the)f(second)h(w)m(ord)e(to)i(the)g(second)f Fq(name)p
Ft(,)h(and)e(so)i(on,)g(with)f(lefto)m(v)m(er)i(w)m(ords)e(and)630
3075 y(their)g(in)m(terv)m(ening)h(separators)g(assigned)f(to)h(the)f
3203 y(their)g(in)m(terv)m(ening)h(separators)g(assigned)f(to)h(the)f
(last)h Fq(name)p Ft(.)40 b(If)27 b(there)i(are)f(few)m(er)g(w)m(ords)
630 3185 y(read)44 b(from)f(the)g(input)g(stream)h(than)g(names,)j(the)
c(remaining)h(names)g(are)g(assigned)630 3294 y(empt)m(y)31
630 3313 y(read)44 b(from)f(the)g(input)g(stream)h(than)g(names,)j(the)
c(remaining)h(names)g(are)g(assigned)630 3422 y(empt)m(y)31
b(v)-5 b(alues.)41 b(The)30 b(c)m(haracters)i(in)e(the)h(v)-5
b(alue)31 b(of)g(the)f Fs(IFS)g Ft(v)-5 b(ariable)31
b(are)g(used)f(to)h(split)630 3404 y(the)37 b(line)h(in)m(to)g(w)m
b(are)g(used)f(to)h(split)630 3532 y(the)37 b(line)h(in)m(to)g(w)m
(ords.)61 b(The)36 b(bac)m(kslash)i(c)m(haracter)h(`)p
Fs(\\)p Ft(')e(ma)m(y)h(b)s(e)f(used)f(to)i(remo)m(v)m(e)h(an)m(y)630
3513 y(sp)s(ecial)h(meaning)g(for)f(the)g(next)h(c)m(haracter)h(read)e
3641 y(sp)s(ecial)h(meaning)g(for)f(the)g(next)h(c)m(haracter)h(read)e
(and)g(for)g(line)h(con)m(tin)m(uation.)69 b(If)39 b(no)630
3623 y(names)28 b(are)h(supplied,)f(the)g(line)h(read)g(is)f(assigned)h
3751 y(names)28 b(are)h(supplied,)f(the)g(line)h(read)g(is)f(assigned)h
(to)g(the)f(v)-5 b(ariable)29 b Fs(REPLY)p Ft(.)39 b(The)28
b(return)630 3733 y(co)s(de)i(is)f(zero,)i(unless)e(end-of-\014le)h(is)
b(return)630 3861 y(co)s(de)i(is)f(zero,)i(unless)e(end-of-\014le)h(is)
f(encoun)m(tered,)h Fs(read)f Ft(times)h(out,)g(or)f(an)h(in)m(v)-5
b(alid)30 b(\014le)630 3842 y(descriptor)35 b(is)h(supplied)e(as)i(the)
b(alid)30 b(\014le)630 3970 y(descriptor)35 b(is)h(supplied)e(as)i(the)
f(argumen)m(t)h(to)g(`)p Fs(-u)p Ft('.)56 b(Options,)37
b(if)e(supplied,)h(ha)m(v)m(e)h(the)630 3952 y(follo)m(wing)32
b(meanings:)630 4134 y Fs(-a)e Fj(aname)114 b Ft(The)34
b(if)e(supplied,)h(ha)m(v)m(e)h(the)630 4080 y(follo)m(wing)32
b(meanings:)630 4230 y Fs(-a)e Fj(aname)114 b Ft(The)34
b(w)m(ords)f(are)i(assigned)f(to)h(sequen)m(tial)h(indices)e(of)g(the)g
(arra)m(y)h(v)-5 b(ariable)1110 4244 y Fq(aname)p Ft(,)29
(arra)m(y)h(v)-5 b(ariable)1110 4340 y Fq(aname)p Ft(,)29
b(starting)h(at)f(0.)40 b(All)29 b(elemen)m(ts)h(are)e(remo)m(v)m(ed)i
(from)d Fq(aname)34 b Ft(b)s(efore)1110 4354 y(the)d(assignmen)m(t.)41
(from)d Fq(aname)34 b Ft(b)s(efore)1110 4450 y(the)d(assignmen)m(t.)41
b(Other)30 b Fq(name)36 b Ft(argumen)m(ts)30 b(are)h(ignored.)630
4536 y Fs(-d)f Fj(delim)114 b Ft(The)41 b(\014rst)h(c)m(haracter)h(of)f
4600 y Fs(-d)f Fj(delim)114 b Ft(The)41 b(\014rst)h(c)m(haracter)h(of)f
Fq(delim)g Ft(is)g(used)g(to)g(terminate)h(the)f(input)f(line,)1110
4646 y(rather)30 b(than)g(newline.)630 4829 y Fs(-e)384
4710 y(rather)30 b(than)g(newline.)630 4861 y Fs(-e)384
b Ft(Readline)28 b(\(see)h(Chapter)e(8)h([Command)f(Line)g(Editing],)i
(page)f(87\))h(is)f(used)1110 4938 y(to)j(obtain)g(the)g(line.)630
(page)f(87\))h(is)f(used)1110 4970 y(to)j(obtain)g(the)g(line.)630
5121 y Fs(-n)f Fj(nchars)1110 5230 y Fs(read)38 b Ft(returns)f(after)j
(reading)f Fq(nc)m(hars)j Ft(c)m(haracters)e(rather)f(than)g(w)m
(aiting)1110 5340 y(for)30 b(a)h(complete)h(line)e(of)h(input.)p
@@ -10059,192 +10061,188 @@ TeXDict begin 79 84 bop 150 -116 a Ft(Chapter)30 b(6:)41
b(Bash)30 b(F)-8 b(eatures)2484 b(79)150 299 y(c)m(hanging)38
b(the)f(b)s(eha)m(vior)g(to)g(matc)m(h)h(that)f(sp)s(eci\014ed)g(b)m(y)
f Fl(posix)g Ft(in)h(areas)g(where)g(the)g(Bash)g(default)150
408 y(di\013ers.)275 554 y(When)30 b(in)m(v)m(ok)m(ed)h(as)g
408 y(di\013ers.)275 539 y(When)30 b(in)m(v)m(ok)m(ed)h(as)g
Fs(sh)p Ft(,)f(Bash)h(en)m(ters)g Fl(posix)e Ft(mo)s(de)h(after)h
(reading)g(the)f(startup)g(\014les.)275 700 y(The)f(follo)m(wing)j
(reading)g(the)f(startup)g(\014les.)275 669 y(The)f(follo)m(wing)j
(list)f(is)g(what's)f(c)m(hanged)h(when)e(`)p Fl(posix)h
Ft(mo)s(de')h(is)f(in)g(e\013ect:)199 846 y(1.)61 b(When)28
Ft(mo)s(de')h(is)f(in)g(e\013ect:)199 800 y(1.)61 b(When)28
b(a)i(command)e(in)g(the)h(hash)f(table)i(no)e(longer)h(exists,)h(Bash)
f(will)g(re-searc)m(h)h Fs($PATH)d Ft(to)i(\014nd)330
955 y(the)i(new)e(lo)s(cation.)43 b(This)29 b(is)i(also)g(a)m(v)-5
909 y(the)i(new)e(lo)s(cation.)43 b(This)29 b(is)i(also)g(a)m(v)-5
b(ailable)33 b(with)d(`)p Fs(shopt)f(-s)h(checkhash)p
Ft('.)199 1095 y(2.)61 b(The)42 b(message)h(prin)m(ted)e(b)m(y)h(the)g
Ft('.)199 1040 y(2.)61 b(The)42 b(message)h(prin)m(ted)e(b)m(y)h(the)g
(job)g(con)m(trol)i(co)s(de)e(and)f(builtins)h(when)f(a)h(job)g(exits)h
(with)f(a)330 1205 y(non-zero)31 b(status)g(is)f(`Done\(status\)'.)199
1345 y(3.)61 b(The)40 b(message)h(prin)m(ted)f(b)m(y)g(the)h(job)f(con)
(with)f(a)330 1149 y(non-zero)31 b(status)g(is)f(`Done\(status\)'.)199
1280 y(3.)61 b(The)40 b(message)h(prin)m(ted)f(b)m(y)g(the)h(job)f(con)
m(trol)h(co)s(de)g(and)f(builtins)f(when)h(a)g(job)g(is)h(stopp)s(ed)e
(is)330 1455 y(`Stopp)s(ed\()p Fq(signame)5 b Ft(\)',)31
(is)330 1390 y(`Stopp)s(ed\()p Fq(signame)5 b Ft(\)',)31
b(where)f Fq(signame)36 b Ft(is,)31 b(for)f(example,)h
Fs(SIGTSTP)p Ft(.)199 1595 y(4.)61 b(Reserv)m(ed)31 b(w)m(ords)f(ma)m
(y)h(not)f(b)s(e)g(aliased.)199 1735 y(5.)61 b(The)39
b Fl(posix)f Ft(1003.2)k Fs(PS1)d Ft(and)f Fs(PS2)h Ft(expansions)g(of)
g(`)p Fs(!)p Ft(')h(to)g(the)f(history)g(n)m(um)m(b)s(er)f(and)h(`)p
Fs(!!)p Ft(')g(to)330 1844 y(`)p Fs(!)p Ft(')c(are)h(enabled,)h(and)e
(parameter)g(expansion)h(is)f(p)s(erformed)f(on)h(the)h(v)-5
b(alues)35 b(of)h Fs(PS1)e Ft(and)h Fs(PS2)330 1954 y
Ft(regardless)c(of)f(the)h(setting)g(of)g(the)f Fs(promptvars)e
Ft(option.)199 2094 y(6.)61 b(The)30 b Fl(posix)g Ft(1003.2)i(startup)e
(\014les)h(are)f(executed)i(\()p Fs($ENV)p Ft(\))e(rather)g(than)g(the)
g(normal)h(Bash)f(\014les.)199 2234 y(7.)61 b(Tilde)30
b(expansion)g(is)f(only)h(p)s(erformed)f(on)h(assignmen)m(ts)g
(preceding)g(a)g(command)g(name,)g(rather)330 2344 y(than)g(on)g(all)i
(assignmen)m(t)f(statemen)m(ts)h(on)e(the)h(line.)199
2484 y(8.)61 b(The)30 b(default)g(history)h(\014le)f(is)h(`)p
Fs(~/.sh_history)p Ft(')c(\(this)k(is)f(the)g(default)h(v)-5
b(alue)31 b(of)f Fs($HISTFILE)p Ft(\).)199 2624 y(9.)61
Fs(SIGTSTP)p Ft(.)199 1520 y(4.)61 b(Reserv)m(ed)40 b(w)m(ords)g(app)s
(earing)f(in)h(a)g(con)m(text)i(where)d(reserv)m(ed)h(w)m(ords)f(are)i
(recognized)g(do)f(not)330 1630 y(undergo)30 b(alias)h(expansion.)199
1760 y(5.)61 b(The)39 b Fl(posix)f Ft(1003.2)k Fs(PS1)d
Ft(and)f Fs(PS2)h Ft(expansions)g(of)g(`)p Fs(!)p Ft(')h(to)g(the)f
(history)g(n)m(um)m(b)s(er)f(and)h(`)p Fs(!!)p Ft(')g(to)330
1870 y(`)p Fs(!)p Ft(')c(are)h(enabled,)h(and)e(parameter)g(expansion)h
(is)f(p)s(erformed)f(on)h(the)h(v)-5 b(alues)35 b(of)h
Fs(PS1)e Ft(and)h Fs(PS2)330 1979 y Ft(regardless)c(of)f(the)h(setting)
g(of)g(the)f Fs(promptvars)e Ft(option.)199 2110 y(6.)61
b(The)30 b Fl(posix)g Ft(1003.2)i(startup)e(\014les)h(are)f(executed)i
(\()p Fs($ENV)p Ft(\))e(rather)g(than)g(the)g(normal)h(Bash)f(\014les.)
199 2240 y(7.)61 b(Tilde)30 b(expansion)g(is)f(only)h(p)s(erformed)f
(on)h(assignmen)m(ts)g(preceding)g(a)g(command)g(name,)g(rather)330
2350 y(than)g(on)g(all)i(assignmen)m(t)f(statemen)m(ts)h(on)e(the)h
(line.)199 2480 y(8.)61 b(The)30 b(default)g(history)h(\014le)f(is)h(`)
p Fs(~/.sh_history)p Ft(')c(\(this)k(is)f(the)g(default)h(v)-5
b(alue)31 b(of)f Fs($HISTFILE)p Ft(\).)199 2611 y(9.)61
b(The)23 b(output)f(of)i(`)p Fs(kill)29 b(-l)p Ft(')23
b(prin)m(ts)f(all)i(the)g(signal)f(names)g(on)g(a)h(single)g(line,)h
(separated)e(b)m(y)g(spaces,)330 2733 y(without)30 b(the)h(`)p
Fs(SIG)p Ft(')f(pre\014x.)154 2874 y(10.)61 b(The)30
(separated)e(b)m(y)g(spaces,)330 2720 y(without)30 b(the)h(`)p
Fs(SIG)p Ft(')f(pre\014x.)154 2851 y(10.)61 b(The)30
b Fs(kill)f Ft(builtin)h(do)s(es)g(not)h(accept)h(signal)f(names)f
(with)g(a)h(`)p Fs(SIG)p Ft(')f(pre\014x.)154 3014 y(11.)61
(with)g(a)h(`)p Fs(SIG)p Ft(')f(pre\014x.)154 2981 y(11.)61
b(Non-in)m(teractiv)m(e)34 b(shells)c(exit)h(if)g Fq(\014lename)k
Ft(in)30 b Fs(.)g Fq(\014lename)36 b Ft(is)31 b(not)f(found.)154
3154 y(12.)61 b(Non-in)m(teractiv)m(e)41 b(shells)d(exit)h(if)f(a)g
3112 y(12.)61 b(Non-in)m(teractiv)m(e)41 b(shells)d(exit)h(if)f(a)g
(syn)m(tax)g(error)g(in)f(an)h(arithmetic)h(expansion)f(results)f(in)h
(an)330 3263 y(in)m(v)-5 b(alid)31 b(expression.)154
3403 y(13.)61 b(Redirection)25 b(op)s(erators)f(do)g(not)g(p)s(erform)f
(an)330 3221 y(in)m(v)-5 b(alid)31 b(expression.)154
3352 y(13.)61 b(Redirection)25 b(op)s(erators)f(do)g(not)g(p)s(erform)f
(\014lename)h(expansion)g(on)g(the)g(w)m(ord)f(in)h(the)g(redirection)
330 3513 y(unless)30 b(the)g(shell)h(is)f(in)m(teractiv)m(e.)154
3653 y(14.)61 b(Redirection)31 b(op)s(erators)g(do)f(not)h(p)s(erform)e
330 3461 y(unless)30 b(the)g(shell)h(is)f(in)m(teractiv)m(e.)154
3592 y(14.)61 b(Redirection)31 b(op)s(erators)g(do)f(not)h(p)s(erform)e
(w)m(ord)h(splitting)h(on)f(the)h(w)m(ord)f(in)g(the)g(redirection.)154
3793 y(15.)61 b(F)-8 b(unction)35 b(names)g(m)m(ust)f(b)s(e)g(v)-5
3722 y(15.)61 b(F)-8 b(unction)35 b(names)g(m)m(ust)f(b)s(e)g(v)-5
b(alid)35 b(shell)f Fs(name)p Ft(s.)52 b(That)34 b(is,)i(they)f(ma)m(y)
g(not)g(con)m(tain)g(c)m(haracters)330 3903 y(other)e(than)g(letters,)h
g(not)g(con)m(tain)g(c)m(haracters)330 3832 y(other)e(than)g(letters,)h
(digits,)h(and)d(underscores,)h(and)f(ma)m(y)h(not)g(start)h(with)e(a)h
(digit.)49 b(Declaring)330 4012 y(a)31 b(function)f(with)g(an)g(in)m(v)
(digit.)49 b(Declaring)330 3941 y(a)31 b(function)f(with)g(an)g(in)m(v)
-5 b(alid)31 b(name)g(causes)f(a)h(fatal)h(syn)m(tax)f(error)f(in)g
(non-in)m(teractiv)m(e)j(shells.)154 4153 y(16.)61 b
(non-in)m(teractiv)m(e)j(shells.)154 4072 y(16.)61 b
Fl(posix)23 b Ft(1003.2)j(`sp)s(ecial')e(builtins)f(are)h(found)e(b)s
(efore)h(shell)h(functions)f(during)f(command)h(lo)s(okup.)154
4293 y(17.)61 b(If)33 b(a)h Fl(posix)f Ft(1003.2)j(sp)s(ecial)e
4202 y(17.)61 b(If)33 b(a)h Fl(posix)f Ft(1003.2)j(sp)s(ecial)e
(builtin)g(returns)e(an)i(error)f(status,)i(a)f(non-in)m(teractiv)m(e)i
(shell)e(exits.)330 4402 y(The)43 b(fatal)j(errors)d(are)h(those)h
(shell)e(exits.)330 4312 y(The)43 b(fatal)j(errors)d(are)h(those)h
(listed)f(in)g(the)g(POSIX.2)g(standard,)j(and)c(include)h(things)g
(lik)m(e)330 4512 y(passing)25 b(incorrect)i(options,)g(redirection)f
(lik)m(e)330 4422 y(passing)25 b(incorrect)i(options,)g(redirection)f
(errors,)g(v)-5 b(ariable)26 b(assignmen)m(t)g(errors)f(for)g
(assignmen)m(ts)330 4621 y(preceding)30 b(the)h(command)f(name,)h(and)e
(so)i(on.)154 4762 y(18.)61 b(If)33 b(the)h Fs(cd)f Ft(builtin)h
(\014nds)e(a)i(directory)g(to)h(c)m(hange)g(to)f(using)g
Fs($CDPATH)p Ft(,)f(the)h(v)-5 b(alue)34 b(it)g(assigns)g(to)330
4871 y(the)d Fs(PWD)e Ft(v)-5 b(ariable)31 b(do)s(es)f(not)h(con)m
(tain)h(an)m(y)e(sym)m(b)s(olic)h(links,)f(as)h(if)f(`)p
Fs(cd)g(-P)p Ft(')g(had)g(b)s(een)g(executed.)154 5011
y(19.)61 b(If)34 b Fs(CDPATH)f Ft(is)h(set,)i(the)f Fs(cd)f
Ft(builtin)g(will)g(not)h(implicitly)h(app)s(end)c(the)j(curren)m(t)f
(directory)h(to)g(it.)330 5121 y(This)29 b(means)g(that)h
Fs(cd)f Ft(will)h(fail)g(if)g(no)f(v)-5 b(alid)30 b(directory)g(name)f
(can)h(b)s(e)f(constructed)h(from)f(an)m(y)h(of)330 5230
y(the)i(en)m(tries)g(in)f Fs($CDPATH)p Ft(,)e(ev)m(en)j(if)g(the)f(a)h
(directory)g(with)f(the)g(same)h(name)f(as)h(the)g(name)f(giv)m(en)330
5340 y(as)g(an)f(argumen)m(t)h(to)g Fs(cd)f Ft(exists)h(in)f(the)g
(curren)m(t)g(directory)-8 b(.)p eop end
(assignmen)m(ts)330 4531 y(preceding)30 b(the)h(command)f(name,)h(and)e
(so)i(on.)154 4662 y(18.)61 b(If)34 b Fs(CDPATH)f Ft(is)h(set,)i(the)f
Fs(cd)f Ft(builtin)g(will)g(not)h(implicitly)h(app)s(end)c(the)j
(curren)m(t)f(directory)h(to)g(it.)330 4771 y(This)29
b(means)g(that)h Fs(cd)f Ft(will)h(fail)g(if)g(no)f(v)-5
b(alid)30 b(directory)g(name)f(can)h(b)s(e)f(constructed)h(from)f(an)m
(y)h(of)330 4881 y(the)i(en)m(tries)g(in)f Fs($CDPATH)p
Ft(,)e(ev)m(en)j(if)g(the)f(a)h(directory)g(with)f(the)g(same)h(name)f
(as)h(the)g(name)f(giv)m(en)330 4990 y(as)g(an)f(argumen)m(t)h(to)g
Fs(cd)f Ft(exists)h(in)f(the)g(curren)m(t)g(directory)-8
b(.)154 5121 y(19.)61 b(A)31 b(non-in)m(teractiv)m(e)j(shell)d(exits)h
(with)e(an)h(error)g(status)g(if)g(a)g(v)-5 b(ariable)32
b(assignmen)m(t)g(error)e(o)s(ccurs)330 5230 y(when)38
b(no)h(command)g(name)g(follo)m(ws)i(the)e(assignmen)m(t)h(statemen)m
(ts.)69 b(A)39 b(v)-5 b(ariable)40 b(assignmen)m(t)330
5340 y(error)30 b(o)s(ccurs,)g(for)g(example,)i(when)d(trying)i(to)g
(assign)f(a)h(v)-5 b(alue)31 b(to)g(a)g(readonly)f(v)-5
b(ariable.)p eop end
%%Page: 80 86
TeXDict begin 80 85 bop 150 -116 a Ft(80)2572 b(Bash)31
b(Reference)g(Man)m(ual)154 299 y(20.)61 b(A)31 b(non-in)m(teractiv)m
(e)j(shell)d(exits)h(with)e(an)h(error)g(status)g(if)g(a)g(v)-5
b(ariable)32 b(assignmen)m(t)g(error)e(o)s(ccurs)330
408 y(when)38 b(no)h(command)g(name)g(follo)m(ws)i(the)e(assignmen)m(t)
h(statemen)m(ts.)69 b(A)39 b(v)-5 b(ariable)40 b(assignmen)m(t)330
518 y(error)30 b(o)s(ccurs,)g(for)g(example,)i(when)d(trying)i(to)g
(assign)f(a)h(v)-5 b(alue)31 b(to)g(a)g(readonly)f(v)-5
b(ariable.)154 645 y(21.)61 b(A)43 b(non-in)m(teractiv)m(e)i(shell)e
(exits)h(with)f(an)f(error)h(status)g(if)g(the)g(iteration)h(v)-5
b(ariable)44 b(in)f(a)g Fs(for)330 755 y Ft(statemen)m(t)32
b(Reference)g(Man)m(ual)154 299 y(20.)61 b(A)43 b(non-in)m(teractiv)m
(e)i(shell)e(exits)h(with)f(an)f(error)h(status)g(if)g(the)g(iteration)
h(v)-5 b(ariable)44 b(in)f(a)g Fs(for)330 408 y Ft(statemen)m(t)32
b(or)f(the)f(selection)i(v)-5 b(ariable)32 b(in)e(a)g
Fs(select)f Ft(statemen)m(t)j(is)f(a)f(readonly)h(v)-5
b(ariable.)154 881 y(22.)61 b(Pro)s(cess)30 b(substitution)g(is)h(not)f
(a)m(v)-5 b(ailable.)154 1008 y(23.)61 b(Assignmen)m(t)32
b(ariable.)154 545 y(21.)61 b(Pro)s(cess)30 b(substitution)g(is)h(not)f
(a)m(v)-5 b(ailable.)154 682 y(22.)61 b(Assignmen)m(t)32
b(statemen)m(ts)g(preceding)f Fl(posix)g Ft(1003.2)i(sp)s(ecial)f
(builtins)e(p)s(ersist)h(in)f(the)i(shell)f(en-)330 1118
(builtins)e(p)s(ersist)h(in)f(the)i(shell)f(en-)330 792
y(vironmen)m(t)g(after)f(the)h(builtin)f(completes.)154
1245 y(24.)61 b(Assignmen)m(t)35 b(statemen)m(ts)h(preceding)f(shell)f
929 y(23.)61 b(Assignmen)m(t)35 b(statemen)m(ts)h(preceding)f(shell)f
(function)g(calls)i(p)s(ersist)e(in)g(the)h(shell)f(en)m(vironmen)m(t)
330 1354 y(after)d(the)f(function)h(returns,)e(as)i(if)f(a)h
330 1038 y(after)d(the)f(function)h(returns,)e(as)i(if)f(a)h
Fl(posix)e Ft(sp)s(ecial)i(builtin)f(command)g(had)g(b)s(een)g
(executed.)154 1481 y(25.)61 b(The)38 b Fs(export)f Ft(and)g
(executed.)154 1175 y(24.)61 b(The)38 b Fs(export)f Ft(and)g
Fs(readonly)f Ft(builtin)i(commands)g(displa)m(y)h(their)f(output)g(in)
g(the)h(format)g(re-)330 1591 y(quired)30 b(b)m(y)g Fl(posix)f
Ft(1003.2.)154 1718 y(26.)61 b(The)30 b Fs(trap)f Ft(builtin)h(displa)m
g(the)h(format)g(re-)330 1285 y(quired)30 b(b)m(y)g Fl(posix)f
Ft(1003.2.)154 1422 y(25.)61 b(The)30 b Fs(trap)f Ft(builtin)h(displa)m
(ys)g(signal)i(names)e(without)g(the)h(leading)g Fs(SIG)p
Ft(.)154 1845 y(27.)61 b(The)39 b Fs(trap)e Ft(builtin)i(do)s(esn't)g
Ft(.)154 1558 y(26.)61 b(The)39 b Fs(trap)e Ft(builtin)i(do)s(esn't)g
(c)m(hec)m(k)h(the)g(\014rst)e(argumen)m(t)i(for)e(a)i(p)s(ossible)e
(signal)i(sp)s(eci\014cation)330 1954 y(and)30 b(rev)m(ert)i(the)e
(signal)i(sp)s(eci\014cation)330 1668 y(and)30 b(rev)m(ert)i(the)e
(signal)i(handling)e(to)h(the)g(original)h(disp)s(osition)e(if)h(it)g
(is,)g(unless)f(that)h(argumen)m(t)330 2064 y(consists)e(solely)g(of)g
(is,)g(unless)f(that)h(argumen)m(t)330 1778 y(consists)e(solely)g(of)g
(digits)g(and)f(is)g(a)h(v)-5 b(alid)29 b(signal)g(n)m(um)m(b)s(er.)38
b(If)28 b(users)g(w)m(an)m(t)h(to)g(reset)g(the)g(handler)330
2173 y(for)h(a)g(giv)m(en)h(signal)g(to)f(the)h(original)g(disp)s
1887 y(for)h(a)g(giv)m(en)h(signal)g(to)f(the)h(original)g(disp)s
(osition,)f(they)g(should)f(use)h(`)p Fs(-)p Ft(')g(as)g(the)g(\014rst)
f(argumen)m(t.)154 2300 y(28.)61 b(The)21 b Fs(.)h Ft(and)f
f(argumen)m(t.)154 2024 y(27.)61 b(The)21 b Fs(.)h Ft(and)f
Fs(source)f Ft(builtins)h(do)g(not)h(searc)m(h)h(the)f(curren)m(t)f
(directory)h(for)g(the)g(\014lename)f(argumen)m(t)330
2410 y(if)30 b(it)h(is)g(not)f(found)f(b)m(y)i(searc)m(hing)g
Fs(PATH)p Ft(.)154 2537 y(29.)61 b(Subshells)20 b(spa)m(wned)h(to)h
2134 y(if)30 b(it)h(is)g(not)f(found)f(b)m(y)i(searc)m(hing)g
Fs(PATH)p Ft(.)154 2271 y(28.)61 b(Subshells)20 b(spa)m(wned)h(to)h
(execute)g(command)g(substitutions)f(inherit)g(the)g(v)-5
b(alue)22 b(of)g(the)f(`)p Fs(-e)p Ft(')g(option)330
2646 y(from)34 b(the)h(paren)m(t)g(shell.)55 b(When)34
2380 y(from)34 b(the)h(paren)m(t)g(shell.)55 b(When)34
b(not)i(in)e Fl(posix)g Ft(mo)s(de,)i(Bash)f(clears)h(the)f(`)p
Fs(-e)p Ft(')f(option)i(in)e(suc)m(h)330 2756 y(subshells.)154
2883 y(30.)61 b(Alias)31 b(expansion)g(is)f(alw)m(a)m(ys)i(enabled,)e
(ev)m(en)i(in)e(non-in)m(teractiv)m(e)j(shells.)154 3010
y(31.)61 b(When)43 b(the)g Fs(alias)f Ft(builtin)g(displa)m(ys)i(alias)
Fs(-e)p Ft(')f(option)i(in)e(suc)m(h)330 2490 y(subshells.)154
2627 y(29.)61 b(Alias)31 b(expansion)g(is)f(alw)m(a)m(ys)i(enabled,)e
(ev)m(en)i(in)e(non-in)m(teractiv)m(e)j(shells.)154 2763
y(30.)61 b(When)43 b(the)g Fs(alias)f Ft(builtin)g(displa)m(ys)i(alias)
g(de\014nitions,)i(it)d(do)s(es)g(not)g(displa)m(y)h(them)f(with)g(a)
330 3119 y(leading)31 b(`)p Fs(alias)e Ft(')i(unless)f(the)g(`)p
Fs(-p)p Ft(')g(option)h(is)g(supplied.)154 3246 y(32.)61
330 2873 y(leading)31 b(`)p Fs(alias)e Ft(')i(unless)f(the)g(`)p
Fs(-p)p Ft(')g(option)h(is)g(supplied.)154 3010 y(31.)61
b(When)40 b(the)g Fs(set)f Ft(builtin)h(is)g(in)m(v)m(ok)m(ed)h
(without)f(options,)j(it)e(do)s(es)f(not)g(displa)m(y)g(shell)g
(function)330 3356 y(names)30 b(and)g(de\014nitions.)154
3483 y(33.)61 b(When)36 b(the)g Fs(set)g Ft(builtin)g(is)g(in)m(v)m(ok)
(function)330 3119 y(names)30 b(and)g(de\014nitions.)154
3256 y(32.)61 b(When)36 b(the)g Fs(set)g Ft(builtin)g(is)g(in)m(v)m(ok)
m(ed)i(without)e(options,)i(it)f(displa)m(ys)f(v)-5 b(ariable)37
b(v)-5 b(alues)37 b(without)330 3592 y(quotes,)26 b(unless)d(they)i
b(v)-5 b(alues)37 b(without)330 3366 y(quotes,)26 b(unless)d(they)i
(con)m(tain)g(shell)f(metac)m(haracters,)k(ev)m(en)d(if)f(the)g(result)
g(con)m(tains)i(nonprin)m(ting)330 3702 y(c)m(haracters.)154
3829 y(34.)61 b(When)35 b(the)g Fs(cd)f Ft(builtin)h(is)g(in)m(v)m(ok)m
g(con)m(tains)i(nonprin)m(ting)330 3476 y(c)m(haracters.)154
3612 y(33.)61 b(When)35 b(the)g Fs(cd)f Ft(builtin)h(is)g(in)m(v)m(ok)m
(ed)i(in)d Fq(logical)41 b Ft(mo)s(de,)36 b(and)f(the)g(pathname)g
(constructed)g(from)330 3938 y Fs($PWD)i Ft(and)h(the)h(directory)f
(constructed)g(from)330 3722 y Fs($PWD)i Ft(and)h(the)h(directory)f
(name)h(supplied)e(as)i(an)f(argumen)m(t)h(do)s(es)f(not)g(refer)h(to)g
(an)f(existing)330 4048 y(directory)-8 b(,)32 b Fs(cd)d
(an)f(existing)330 3832 y(directory)-8 b(,)32 b Fs(cd)d
Ft(will)i(fail)g(instead)g(of)f(falling)h(bac)m(k)h(to)f
Fq(ph)m(ysical)j Ft(mo)s(de.)154 4175 y(35.)61 b(When)20
Fq(ph)m(ysical)j Ft(mo)s(de.)154 3968 y(34.)61 b(When)20
b(the)h Fs(pwd)e Ft(builtin)h(is)g(supplied)g(the)g(`)p
Fs(-P)p Ft(')g(option,)j(it)e(resets)g Fs($PWD)e Ft(to)i(a)g(pathname)f
(con)m(taining)330 4284 y(no)30 b(symlinks.)154 4411
y(36.)61 b(When)35 b(listing)g(the)g(history)-8 b(,)36
(con)m(taining)330 4078 y(no)30 b(symlinks.)154 4215
y(35.)61 b(When)35 b(listing)g(the)g(history)-8 b(,)36
b(the)f Fs(fc)g Ft(builtin)f(do)s(es)g(not)h(include)g(an)f(indication)
i(of)f(whether)f(or)330 4521 y(not)d(a)f(history)h(en)m(try)f(has)g(b)s
(een)g(mo)s(di\014ed.)154 4648 y(37.)61 b(The)30 b(default)g(editor)h
(used)f(b)m(y)g Fs(fc)g Ft(is)g Fs(ed)p Ft(.)154 4775
y(38.)61 b(The)37 b Fs(type)g Ft(and)g Fs(command)f Ft(builtins)i(will)
i(of)f(whether)f(or)330 4324 y(not)d(a)f(history)h(en)m(try)f(has)g(b)s
(een)g(mo)s(di\014ed.)154 4461 y(36.)61 b(The)30 b(default)g(editor)h
(used)f(b)m(y)g Fs(fc)g Ft(is)g Fs(ed)p Ft(.)154 4598
y(37.)61 b(The)37 b Fs(type)g Ft(and)g Fs(command)f Ft(builtins)i(will)
g(not)g(rep)s(ort)f(a)i(non-executable)g(\014le)f(as)g(ha)m(ving)h(b)s
(een)330 4884 y(found,)26 b(though)h(the)g(shell)g(will)g(attempt)h(to)
(een)330 4708 y(found,)26 b(though)h(the)g(shell)g(will)g(attempt)h(to)
g(execute)g(suc)m(h)f(a)g(\014le)g(if)g(it)g(is)g(the)g(only)g
(so-named)g(\014le)330 4994 y(found)i(in)h Fs($PATH)p
Ft(.)154 5121 y(39.)61 b(When)41 b(the)g Fs(xpg_echo)e
(so-named)g(\014le)330 4817 y(found)i(in)h Fs($PATH)p
Ft(.)154 4954 y(38.)61 b(When)41 b(the)g Fs(xpg_echo)e
Ft(option)i(is)g(enabled,)j(Bash)d(do)s(es)g(not)g(attempt)h(to)g(in)m
(terpret)f(an)m(y)h(ar-)330 5230 y(gumen)m(ts)35 b(to)g
(terpret)f(an)m(y)h(ar-)330 5064 y(gumen)m(ts)35 b(to)g
Fs(echo)e Ft(as)i(options.)54 b(Eac)m(h)35 b(argumen)m(t)g(is)f(displa)
m(y)m(ed,)j(after)e(escap)s(e)g(c)m(haracters)h(are)330
5340 y(con)m(v)m(erted.)p eop end
5173 y(con)m(v)m(erted.)275 5340 y(There)29 b(is)i(other)f
Fl(posix)g Ft(1003.2)j(b)s(eha)m(vior)d(that)h(Bash)g(do)s(es)f(not)h
(implemen)m(t.)41 b(Sp)s(eci\014cally:)p eop end
%%Page: 81 87
TeXDict begin 81 86 bop 150 -116 a Ft(Chapter)30 b(6:)41
b(Bash)30 b(F)-8 b(eatures)2484 b(81)275 299 y(There)29
b(is)i(other)f Fl(posix)g Ft(1003.2)j(b)s(eha)m(vior)d(that)h(Bash)g
(do)s(es)f(not)h(implemen)m(t.)41 b(Sp)s(eci\014cally:)199
433 y(1.)61 b(Assignmen)m(t)26 b(statemen)m(ts)i(a\013ect)f(the)f
(execution)g(en)m(vironmen)m(t)h(of)f(all)g(builtins,)g(not)g(just)f
(sp)s(ecial)330 543 y(ones.)199 677 y(2.)61 b(When)20
b(a)h(subshell)f(is)h(created)g(to)h(execute)g(a)f(shell)f(script)h
(with)f(execute)i(p)s(ermission,)g(but)e(without)330
787 y(a)35 b(leading)h(`)p Fs(#!)p Ft(',)g(Bash)g(sets)f
Fs($0)f Ft(to)i(the)f(full)g(pathname)g(of)g(the)g(script)g(as)g(found)
f(b)m(y)h(searc)m(hing)330 897 y Fs($PATH)p Ft(,)29 b(rather)h(than)h
(the)f(command)g(as)h(t)m(yp)s(ed)f(b)m(y)g(the)h(user.)199
1031 y(3.)61 b(When)28 b(using)f(`)p Fs(.)p Ft(')h(to)g(source)g(a)h
(shell)f(script)f(found)g(in)g Fs($PATH)p Ft(,)h(bash)f(c)m(hec)m(ks)i
(execute)g(p)s(ermission)330 1141 y(bits)h(rather)h(than)f(read)g(p)s
(ermission)f(bits,)i(just)f(as)g(if)g(it)h(w)m(ere)g(searc)m(hing)g
(for)g(a)f(command.)p eop end
b(Bash)30 b(F)-8 b(eatures)2484 b(81)199 299 y(1.)61
b(Assignmen)m(t)26 b(statemen)m(ts)i(a\013ect)f(the)f(execution)g(en)m
(vironmen)m(t)h(of)f(all)g(builtins,)g(not)g(just)f(sp)s(ecial)330
408 y(ones.)199 543 y(2.)61 b(When)20 b(a)h(subshell)f(is)h(created)g
(to)h(execute)g(a)f(shell)f(script)h(with)f(execute)i(p)s(ermission,)g
(but)e(without)330 653 y(a)35 b(leading)h(`)p Fs(#!)p
Ft(',)g(Bash)g(sets)f Fs($0)f Ft(to)i(the)f(full)g(pathname)g(of)g(the)
g(script)g(as)g(found)f(b)m(y)h(searc)m(hing)330 762
y Fs($PATH)p Ft(,)29 b(rather)h(than)h(the)f(command)g(as)h(t)m(yp)s
(ed)f(b)m(y)g(the)h(user.)199 897 y(3.)61 b(When)28 b(using)f(`)p
Fs(.)p Ft(')h(to)g(source)g(a)h(shell)f(script)f(found)g(in)g
Fs($PATH)p Ft(,)h(bash)f(c)m(hec)m(ks)i(execute)g(p)s(ermission)330
1006 y(bits)h(rather)h(than)f(read)g(p)s(ermission)f(bits,)i(just)f(as)
g(if)g(it)h(w)m(ere)g(searc)m(hing)g(for)g(a)f(command.)p
eop end
%%Page: 82 88
TeXDict begin 82 87 bop 150 -116 a Ft(82)2572 b(Bash)31
b(Reference)g(Man)m(ual)p eop end
+4 -1
View File
@@ -3449,7 +3449,7 @@ parent.
@item printf
@btindex printf
@example
@code{printf} @var{format} [@var{arguments}]
@code{printf} [-v @var{var}] @var{format} [@var{arguments}]
@end example
Write the formatted @var{arguments} to the standard output under the
control of the @var{format}.
@@ -3467,6 +3467,9 @@ beginning with @samp{\0} may contain up to four digits),
and @samp{%q} causes @code{printf} to output the
corresponding @var{argument} in a format that can be reused as shell input.
The @option{-v} option causes the output to be assigned to the variable
@var{var} rather than being printed to the standard output.
The @var{format} is reused as necessary to consume all of the @var{arguments}.
If the @var{format} requires more @var{arguments} than are supplied, the
extra format specifications behave as if a zero value or null string, as
+108 -105
View File
@@ -710,7 +710,7 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
tent directory stack entry is specified, or the directory change
fails.
pprriinnttff _f_o_r_m_a_t [_a_r_g_u_m_e_n_t_s]
pprriinnttff [--vv _v_a_r] _f_o_r_m_a_t [_a_r_g_u_m_e_n_t_s]
Write the formatted _a_r_g_u_m_e_n_t_s to the standard output under the
control of the _f_o_r_m_a_t. The _f_o_r_m_a_t is a character string which
contains three types of objects: plain characters, which are
@@ -725,59 +725,62 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a format that can
be reused as shell input.
The _f_o_r_m_a_t is reused as necessary to consume all of the _a_r_g_u_-
The --vv option causes the output to be assigned to the variable
_v_a_r rather than being printed to the standard output.
The _f_o_r_m_a_t is reused as necessary to consume all of the _a_r_g_u_-
_m_e_n_t_s. If the _f_o_r_m_a_t requires more _a_r_g_u_m_e_n_t_s than are supplied,
the extra format specifications behave as if a zero value or
null string, as appropriate, had been supplied. The return
the extra format specifications behave as if a zero value or
null string, as appropriate, had been supplied. The return
value is zero on success, non-zero on failure.
ppuusshhdd [--nn] [_d_i_r]
ppuusshhdd [--nn] [+_n] [-_n]
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory. With no arguments, exchanges the top two directories
and returns 0, unless the directory stack is empty. Arguments,
and returns 0, unless the directory stack is empty. Arguments,
if supplied, have the following meanings:
++_n Rotates the stack so that the _nth directory (counting
from the left of the list shown by ddiirrss, starting with
++_n Rotates the stack so that the _nth directory (counting
from the left of the list shown by ddiirrss, starting with
zero) is at the top.
--_n Rotates the stack so that the _nth directory (counting
from the right of the list shown by ddiirrss, starting with
--_n Rotates the stack so that the _nth directory (counting
from the right of the list shown by ddiirrss, starting with
zero) is at the top.
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
--nn Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is
manipulated.
_d_i_r Adds _d_i_r to the directory stack at the top, making it the
new current working directory.
If the ppuusshhdd command is successful, a ddiirrss is performed as well.
If the first form is used, ppuusshhdd returns 0 unless the cd to _d_i_r
fails. With the second form, ppuusshhdd returns 0 unless the direc-
tory stack is empty, a non-existent directory stack element is
specified, or the directory change to the specified new current
If the first form is used, ppuusshhdd returns 0 unless the cd to _d_i_r
fails. With the second form, ppuusshhdd returns 0 unless the direc-
tory stack is empty, a non-existent directory stack element is
specified, or the directory change to the specified new current
directory fails.
ppwwdd [--LLPP]
Print the absolute pathname of the current working directory.
Print the absolute pathname of the current working directory.
The pathname printed contains no symbolic links if the --PP option
is supplied or the --oo pphhyyssiiccaall option to the sseett builtin command
is enabled. If the --LL option is used, the pathname printed may
contain symbolic links. The return status is 0 unless an error
occurs while reading the name of the current directory or an
is enabled. If the --LL option is used, the pathname printed may
contain symbolic links. The return status is 0 unless an error
occurs while reading the name of the current directory or an
invalid option is supplied.
rreeaadd [--eerrss] [--uu _f_d] [--tt _t_i_m_e_o_u_t] [--aa _a_n_a_m_e] [--pp _p_r_o_m_p_t] [--nn _n_c_h_a_r_s] [--dd
_d_e_l_i_m] [_n_a_m_e ...]
One line is read from the standard input, or from the file
descriptor _f_d supplied as an argument to the --uu option, and the
One line is read from the standard input, or from the file
descriptor _f_d supplied as an argument to the --uu option, and the
first word is assigned to the first _n_a_m_e, the second word to the
second _n_a_m_e, and so on, with leftover words and their interven-
ing separators assigned to the last _n_a_m_e. If there are fewer
second _n_a_m_e, and so on, with leftover words and their interven-
ing separators assigned to the last _n_a_m_e. If there are fewer
words read from the input stream than names, the remaining names
are assigned empty values. The characters in IIFFSS are used to
split the line into words. The backslash character (\\) may be
used to remove any special meaning for the next character read
and for line continuation. Options, if supplied, have the fol-
are assigned empty values. The characters in IIFFSS are used to
split the line into words. The backslash character (\\) may be
used to remove any special meaning for the next character read
and for line continuation. Options, if supplied, have the fol-
lowing meanings:
--aa _a_n_a_m_e
The words are assigned to sequential indices of the array
@@ -785,100 +788,100 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
new values are assigned. Other _n_a_m_e arguments are
ignored.
--dd _d_e_l_i_m
The first character of _d_e_l_i_m is used to terminate the
The first character of _d_e_l_i_m is used to terminate the
input line, rather than newline.
--ee If the standard input is coming from a terminal, rreeaaddlliinnee
(see RREEAADDLLIINNEE above) is used to obtain the line.
--nn _n_c_h_a_r_s
rreeaadd returns after reading _n_c_h_a_r_s characters rather than
rreeaadd returns after reading _n_c_h_a_r_s characters rather than
waiting for a complete line of input.
--pp _p_r_o_m_p_t
Display _p_r_o_m_p_t on standard error, without a trailing new-
line, before attempting to read any input. The prompt is
displayed only if input is coming from a terminal.
--rr Backslash does not act as an escape character. The back-
slash is considered to be part of the line. In
particular, a backslash-newline pair may not be used as a
line continuation.
slash is considered to be part of the line. In particu-
lar, a backslash-newline pair may not be used as a line
continuation.
--ss Silent mode. If input is coming from a terminal, charac-
ters are not echoed.
--tt _t_i_m_e_o_u_t
Cause rreeaadd to time out and return failure if a complete
line of input is not read within _t_i_m_e_o_u_t seconds. This
option has no effect if rreeaadd is not reading input from
Cause rreeaadd to time out and return failure if a complete
line of input is not read within _t_i_m_e_o_u_t seconds. This
option has no effect if rreeaadd is not reading input from
the terminal or a pipe.
--uu _f_d Read input from file descriptor _f_d.
If no _n_a_m_e_s are supplied, the line read is assigned to the vari-
able RREEPPLLYY. The return code is zero, unless end-of-file is
encountered, rreeaadd times out, or an invalid file descriptor is
able RREEPPLLYY. The return code is zero, unless end-of-file is
encountered, rreeaadd times out, or an invalid file descriptor is
supplied as the argument to --uu.
rreeaaddoonnllyy [--aappff] [_n_a_m_e[=_w_o_r_d] ...]
The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s
may not be changed by subsequent assignment. If the --ff option
is supplied, the functions corresponding to the _n_a_m_e_s are so
The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s
may not be changed by subsequent assignment. If the --ff option
is supplied, the functions corresponding to the _n_a_m_e_s are so
marked. The --aa option restricts the variables to arrays. If no
_n_a_m_e arguments are given, or if the --pp option is supplied, a
list of all readonly names is printed. The --pp option causes
output to be displayed in a format that may be reused as input.
If a variable name is followed by =_w_o_r_d, the value of the vari-
able is set to _w_o_r_d. The return status is 0 unless an invalid
option is encountered, one of the _n_a_m_e_s is not a valid shell
_n_a_m_e arguments are given, or if the --pp option is supplied, a
list of all readonly names is printed. The --pp option causes
output to be displayed in a format that may be reused as input.
If a variable name is followed by =_w_o_r_d, the value of the vari-
able is set to _w_o_r_d. The return status is 0 unless an invalid
option is encountered, one of the _n_a_m_e_s is not a valid shell
variable name, or --ff is supplied with a _n_a_m_e that is not a func-
tion.
rreettuurrnn [_n]
Causes a function to exit with the return value specified by _n.
If _n is omitted, the return status is that of the last command
executed in the function body. If used outside a function, but
during execution of a script by the .. (ssoouurrccee) command, it
Causes a function to exit with the return value specified by _n.
If _n is omitted, the return status is that of the last command
executed in the function body. If used outside a function, but
during execution of a script by the .. (ssoouurrccee) command, it
causes the shell to stop executing that script and return either
_n or the exit status of the last command executed within the
script as the exit status of the script. If used outside a
function and not during execution of a script by .., the return
_n or the exit status of the last command executed within the
script as the exit status of the script. If used outside a
function and not during execution of a script by .., the return
status is false. Any command associated with the RREETTUURRNN trap is
executed before execution resumes after the function or script.
executed before execution resumes after the function or script.
sseett [----aabbeeffhhkkmmnnppttuuvvxxBBCCHHPP] [--oo _o_p_t_i_o_n] [_a_r_g ...]
Without options, the name and value of each shell variable are
Without options, the name and value of each shell variable are
displayed in a format that can be reused as input for setting or
resetting the currently-set variables. Read-only variables can-
not be reset. In _p_o_s_i_x _m_o_d_e, only shell variables are listed.
The output is sorted according to the current locale. When
options are specified, they set or unset shell attributes. Any
arguments remaining after the options are processed are treated
as values for the positional parameters and are assigned, in
not be reset. In _p_o_s_i_x _m_o_d_e, only shell variables are listed.
The output is sorted according to the current locale. When
options are specified, they set or unset shell attributes. Any
arguments remaining after the options are processed are treated
as values for the positional parameters and are assigned, in
order, to $$11, $$22, ...... $$_n. Options, if specified, have the fol-
lowing meanings:
--aa Automatically mark variables and functions which are
modified or created for export to the environment of
--aa Automatically mark variables and functions which are
modified or created for export to the environment of
subsequent commands.
--bb Report the status of terminated background jobs immedi-
--bb Report the status of terminated background jobs immedi-
ately, rather than before the next primary prompt. This
is effective only when job control is enabled.
--ee Exit immediately if a _s_i_m_p_l_e _c_o_m_m_a_n_d (see SSHHEELLLL GGRRAAMMMMAARR
--ee Exit immediately if a _s_i_m_p_l_e _c_o_m_m_a_n_d (see SSHHEELLLL GGRRAAMMMMAARR
above) exits with a non-zero status. The shell does not
exit if the command that fails is part of the command
list immediately following a wwhhiillee or uunnttiill keyword,
part of the test in an _i_f statement, part of a &&&& or ||||
exit if the command that fails is part of the command
list immediately following a wwhhiillee or uunnttiill keyword,
part of the test in an _i_f statement, part of a &&&& or ||||
list, or if the command's return value is being inverted
via !!. A trap on EERRRR, if set, is executed before the
via !!. A trap on EERRRR, if set, is executed before the
shell exits.
--ff Disable pathname expansion.
--hh Remember the location of commands as they are looked up
--hh Remember the location of commands as they are looked up
for execution. This is enabled by default.
--kk All arguments in the form of assignment statements are
placed in the environment for a command, not just those
--kk All arguments in the form of assignment statements are
placed in the environment for a command, not just those
that precede the command name.
--mm Monitor mode. Job control is enabled. This option is
on by default for interactive shells on systems that
support it (see JJOOBB CCOONNTTRROOLL above). Background pro-
cesses run in a separate process group and a line con-
taining their exit status is printed upon their comple-
tion.
--mm Monitor mode. Job control is enabled. This option is
on by default for interactive shells on systems that
support it (see JJOOBB CCOONNTTRROOLL above). Background pro-
cesses run in a separate process group and a line
containing their exit status is printed upon their com-
pletion.
--nn Read commands but do not execute them. This may be used
to check a shell script for syntax errors. This is
to check a shell script for syntax errors. This is
ignored by interactive shells.
--oo _o_p_t_i_o_n_-_n_a_m_e
The _o_p_t_i_o_n_-_n_a_m_e can be one of the following:
@@ -886,7 +889,7 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
Same as --aa.
bbrraacceeeexxppaanndd
Same as --BB.
eemmaaccss Use an emacs-style command line editing inter-
eemmaaccss Use an emacs-style command line editing inter-
face. This is enabled by default when the shell
is interactive, unless the shell is started with
the ----nnooeeddiittiinngg option.
@@ -902,8 +905,8 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
HHIISSTTOORRYY. This option is on by default in inter-
active shells.
iiggnnoorreeeeooff
The effect is as if the shell command
``IGNOREEOF=10'' had been executed (see SShheellll
The effect is as if the shell command
``IGNOREEOF=10'' had been executed (see SShheellll
VVaarriiaabblleess above).
kkeeyywwoorrdd Same as --kk.
mmoonniittoorr Same as --mm.
@@ -917,12 +920,12 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
pphhyyssiiccaall
Same as --PP.
ppiippeeffaaiill
If set, the return value of a pipeline is the
value of the last (rightmost) command to exit
with a non-zero status, or zero if all commands
in the pipeline exit successfully. This option
If set, the return value of a pipeline is the
value of the last (rightmost) command to exit
with a non-zero status, or zero if all commands
in the pipeline exit successfully. This option
is disabled by default.
ppoossiixx Change the behavior of bbaasshh where the default
ppoossiixx Change the behavior of bbaasshh where the default
operation differs from the POSIX 1003.2 standard
to match the standard (_p_o_s_i_x _m_o_d_e).
pprriivviilleeggeedd
@@ -931,32 +934,32 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
vvii Use a vi-style command line editing interface.
xxttrraaccee Same as --xx.
If --oo is supplied with no _o_p_t_i_o_n_-_n_a_m_e, the values of the
current options are printed. If ++oo is supplied with no
_o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the
current option settings is displayed on the standard
current options are printed. If ++oo is supplied with no
_o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the
current option settings is displayed on the standard
output.
--pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and
$$BBAASSHH__EENNVV files are not processed, shell functions are
not inherited from the environment, and the SSHHEELLLLOOPPTTSS
variable, if it appears in the environment, is ignored.
If the shell is started with the effective user (group)
id not equal to the real user (group) id, and the --pp
option is not supplied, these actions are taken and the
--pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and
$$BBAASSHH__EENNVV files are not processed, shell functions are
not inherited from the environment, and the SSHHEELLLLOOPPTTSS
variable, if it appears in the environment, is ignored.
If the shell is started with the effective user (group)
id not equal to the real user (group) id, and the --pp
option is not supplied, these actions are taken and the
effective user id is set to the real user id. If the --pp
option is supplied at startup, the effective user id is
option is supplied at startup, the effective user id is
not reset. Turning this option off causes the effective
user and group ids to be set to the real user and group
user and group ids to be set to the real user and group
ids.
--tt Exit after reading and executing one command.
--uu Treat unset variables as an error when performing param-
eter expansion. If expansion is attempted on an unset
eter expansion. If expansion is attempted on an unset
variable, the shell prints an error message, and, if not
interactive, exits with a non-zero status.
--vv Print shell input lines as they are read.
--xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee
command, sseelleecctt command, or arithmetic ffoorr command, dis-
play the expanded value of PPSS44, followed by the command
and its expanded arguments or associated word list.
--xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee
command, sseelleecctt command, or arithmetic ffoorr command,
display the expanded value of PPSS44, followed by the com-
mand and its expanded arguments or associated word list.
--BB The shell performs brace expansion (see BBrraaccee EExxppaannssiioonn
above). This is on by default.
--CC If set, bbaasshh does not overwrite an existing file with
+685 -683
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.18.1
%%CreationDate: Tue Feb 22 13:37:34 2005
%%CreationDate: Tue Mar 15 17:26:56 2005
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.18 1
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2005 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Feb 23 16:45:53 EST 2005
@set LASTCHANGE Tue Mar 15 17:21:22 EST 2005
@set EDITION 3.1-devel
@set VERSION 3.1-devel
@set UPDATED 23 February 2005
@set UPDATED-MONTH February 2005
@set UPDATED 15 March 2005
@set UPDATED-MONTH March 2005
+4 -4
View File
@@ -129,16 +129,16 @@ typedef struct {
: (type)(list))
#if __GNUC__ > 1
# define FASTCOPY(s, d, n) __builtin_memcpy (d, s, n)
# define FASTCOPY(s, d, n) __builtin_memcpy ((d), (s), (n))
#else /* !__GNUC__ */
# if !defined (HAVE_BCOPY)
# if !defined (HAVE_MEMMOVE)
# define FASTCOPY(s, d, n) memcpy (d, s, n)
# define FASTCOPY(s, d, n) memcpy ((d), (s), (n))
# else
# define FASTCOPY(s, d, n) memmove (d, s, n)
# define FASTCOPY(s, d, n) memmove ((d), (s), (n))
# endif /* !HAVE_MEMMOVE */
# else /* HAVE_BCOPY */
# define FASTCOPY(s, d, n) bcopy (s, d, n)
# define FASTCOPY(s, d, n) bcopy ((s), (d), (n))
# endif /* HAVE_BCOPY */
#endif /* !__GNUC__ */
+1 -1
View File
@@ -4135,7 +4135,7 @@ decode_prompt_string (string)
#define ROOT_PATH(x) ((x)[0] == '/' && (x)[1] == 0)
#define DOUBLE_SLASH_ROOT(x) ((x)[0] == '/' && (x)[1] == '/' && (x)[2] == 0)
/* Abbreviate \W as ~ if $PWD == $HOME */
if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, temp) == 0))
if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, t_string) == 0))
{
if (ROOT_PATH (t_string) == 0 && DOUBLE_SLASH_ROOT (t_string) == 0)
{
+20
View File
@@ -39,3 +39,23 @@ argv[1] = <-^?->
argv[1] = <^?>
argv[1] = <-^?->
ok
argv[1] = <aaa^?bbb>
argv[1] = <ccc^?ddd>
argv[1] = <eee^?fff>
argv[1] = <ggg^?hhh>
argv[1] = <aaabbb>
argv[1] = <cccddd>
argv[1] = <eeefff>
argv[1] = <ggghhh>
argv[1] = <aaa^?bbb>
argv[1] = <ccc^?ddd>
argv[1] = <eee^?fff>
argv[1] = <ggg^?hhh>
argv[1] = <aaabbb>
argv[1] = <cccddd>
argv[1] = <eeefff>
argv[1] = <ggghhh>
argv[1] = <aaa^?bbb>
argv[1] = <ccc^?ddd>
argv[1] = <eee^?fff>
argv[1] = <ggg^?hhh>
+29
View File
@@ -112,3 +112,32 @@ case "$L1/$L2" in
4/4) echo ok;;
*) echo CTLNUL bug: L1=$L1, L2=$L2;;
esac
x=$'\177'
recho "aaa${x}bbb"
recho ccc"${x}"ddd
recho eee"$x"fff
recho ggg"$(echo $x)"hhh
x=
recho "aaa${x}bbb"
recho ccc"${x}"ddd
recho eee"$x"fff
recho ggg"$(echo $x)"hhh
set -- $'\177'
recho "aaa${1}bbb"
recho ccc"${1}"ddd
recho eee"$1"fff
recho ggg"$(echo $1)"hhh
set -- ""
recho "aaa${1}bbb"
recho ccc"${1}"ddd
recho eee"$1"fff
recho ggg"$(echo $1)"hhh
recho aaa$'\177'bbb
recho ccc""ddd
recho "eeefff"
recho ggg"$(echo $'\177')"hhh
+257
View File
@@ -0,0 +1,257 @@
# Usage: $SHELL ifs.sh
#
# This script generates 6856 tests for the set(1) and read(1)
# builtins w.r.t. IFS whitespace and non-whitespace characters.
# Each failed test produces one line on the standard output that
# contains the test along with the expected and actual results.
# The last output line contains the test result counts. ordered>0
# are the number of tests where IFS=": " produced different results
# than IFS=" :". If a test fails the same way for IFS=": " and
# IFS=" :" then the second output line is suppressed.
TESTS=6856
ksh_read=0
echo 1 | read ksh_read
ksh_arith=0
eval '((ksh_arith+=1))' 2>/dev/null
failed=0
ordered=0
passed=0
split()
{
i=$1 s=$2 r=$3 S='' R=''
for ifs in ': ' ' :'
do IFS=$ifs
set x $i
shift
IFS=' '
g="[$#]"
while :
do case $# in
0) break ;;
esac
g="$g($1)"
shift
done
case $g in
"$s") case $ksh_arith in
1) ((passed+=1)) ;;
*) passed=`expr $passed + 1` ;;
esac
case $S in
'') S=$g
;;
"$g") ;;
*) case $ksh_arith in
1) ((ordered+=1)) ;;
*) ordered=`expr $ordered + 1` ;;
esac
;;
esac
;;
"$S") case $ksh_arith in
1) ((failed+=1)) ;;
*) failed=`expr $failed + 1` ;;
esac
;;
*) case $ksh_arith in
1) ((failed+=1)) ;;
*) failed=`expr $failed + 1` ;;
esac
case $s in
"$S") ;;
?0*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#]\" # expected \"$s\" got \"$g\"" ;;
?1*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)\" # expected \"$s\" got \"$g\"" ;;
?2*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)\" # expected \"$s\" got \"$g\"" ;;
?3*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)(\$3)\" # expected \"$s\" got \"$g\"" ;;
*) echo TEST ERROR i="'$i'" s="'$s'" ;;
esac
case $S in
'') S=$g
;;
"$g") ;;
*) case $ksh_arith in
1) ((ordered+=1)) ;;
*) ordered=`expr $ordered + 1` ;;
esac
;;
esac
esac
case $ksh_read in
1) echo "$i" | IFS=$ifs read x y; g="($x)($y)" ;;
*) g=`export ifs; echo "$i" | ( IFS=$ifs; read x y; echo "($x)($y)" )` ;;
esac
case $g in
"$r") case $ksh_arith in
1) ((passed+=1)) ;;
*) passed=`expr $passed + 1` ;;
esac
case $R in
'') R=$g
;;
"$g") ;;
*) case $ksh_arith in
1) ((ordered+=1)) ;;
*) ordered=`expr $ordered + 1` ;;
esac
;;
esac
;;
"$R") case $ksh_arith in
1) ((failed+=1)) ;;
*) failed=`expr $failed + 1` ;;
esac
;;
*) case $ksh_arith in
1) ((failed+=1)) ;;
*) failed=`expr $failed + 1` ;;
esac
case $r in
"$R") ;;
*) echo "echo \"$i\" | ( IFS=\"$ifs\" read x y; echo \"(\$x)(\$y)\" ) # expected \"$r\" got \"$g\"" ;;
esac
case $R in
'') R=$g
;;
"$g") ;;
*) case $ksh_arith in
1) ((ordered+=1)) ;;
*) ordered=`expr $ordered + 1` ;;
esac
;;
esac
;;
esac
done
}
for str in \
'-' \
'a' \
'- -' \
'- a' \
'a -' \
'a b' \
'- - -' \
'- - a' \
'- a -' \
'- a b' \
'a - -' \
'a - b' \
'a b -' \
'a b c' \
do
IFS=' '
set x $str
shift
case $# in
0) continue ;;
esac
f1=$1
case $f1 in
'-') f1='' ;;
esac
shift
case $# in
0) for d0 in '' ' '
do
for d1 in '' ' ' ':' ' :' ': ' ' : '
do
case $f1$d1 in
'') split "$d0$f1$d1" "[0]" "()()" ;;
' ') ;;
*) split "$d0$f1$d1" "[1]($f1)" "($f1)()" ;;
esac
done
done
continue
;;
esac
f2=$1
case $f2 in
'-') f2='' ;;
esac
shift
case $# in
0) for d0 in '' ' '
do
for d1 in ' ' ':' ' :' ': ' ' : '
do
case ' ' in
$f1$d1|$d1$f2) continue ;;
esac
for d2 in '' ' ' ':' ' :' ': ' ' : '
do
case $f2$d2 in
'') split "$d0$f1$d1$f2$d2" "[1]($f1)" "($f1)()" ;;
' ') ;;
*) split "$d0$f1$d1$f2$d2" "[2]($f1)($f2)" "($f1)($f2)" ;;
esac
done
done
done
continue
;;
esac
f3=$1
case $f3 in
'-') f3='' ;;
esac
shift
case $# in
0) for d0 in '' ' '
do
for d1 in ':' ' :' ': ' ' : '
do
case ' ' in
$f1$d1|$d1$f2) continue ;;
esac
for d2 in ' ' ':' ' :' ': ' ' : '
do
case $f2$d2 in
' ') continue ;;
esac
case ' ' in
$f2$d2|$d2$f3) continue ;;
esac
for d3 in '' ' ' ':' ' :' ': ' ' : '
do
case $f3$d3 in
'') split "$d0$f1$d1$f2$d2$f3$d3" "[2]($f1)($f2)" "($f1)($f2)" ;;
' ') ;;
*) x=$f2$d2$f3$d3
x=${x#' '}
x=${x%' '}
split "$d0$f1$d1$f2$d2$f3$d3" "[3]($f1)($f2)($f3)" "($f1)($x)"
;;
esac
done
done
done
done
continue
;;
esac
done
case $ksh_arith in
1) ((tests=passed+failed)) ;;
*) tests=`expr $passed + $failed` ;;
esac
case $ordered in
0) ordered="" ;;
*) ordered=" ordered $ordered" ;;
esac
case $tests in
$TESTS) fatal="" ;;
*) fatal=" -- fundamental IFS error -- $TESTS tests expected"
esac
echo "# tests $tests passed $passed failed $failed$ordered$fatal"
Binary file not shown.
+12 -4
View File
@@ -9,6 +9,13 @@ printf --
printf ""
printf -- ""
# in the future this may mean to put the output into VAR, but for
# now it is an error
# 2005-03-15 no longer an error
unset var
printf -v var "%10d" $RANDOM
echo ${#var}
# this should expand escape sequences in the format string, nothing else
printf "\tone\n"
@@ -196,10 +203,6 @@ printf "%d\n" 26
# happily ignore overflow conditions in strtol(3)
#printf "%ld\n" 4294967296
# in the future this may mean to put the output into VAR, but for
# now it is an error
printf -v var "%10d" $RANDOM
printf "%10"
printf "ab%Mcd\n"
@@ -220,6 +223,11 @@ printf '(%*b)(%*s)\n' -4 foo -4 bar
format='%'`printf '%0100384d' 0`'d\n'
printf $format 0
# failures in all bash versions through bash-3.0 - undercounted characters
unset vv
printf " %s %s %s \n%n" ab cd ef vv
echo "$vv"
# this doesn't work with printf(3) on all systems
#printf "%'s\n" foo
+338
View File
@@ -0,0 +1,338 @@
LC_ALL=C
LC_NUMERIC=C
unset vv
# this should expand escape sequences in the format string, nothing else
printf -v vv "\tone\n"
printf "%s" "$vv"
# this should not cut off output after the \c
printf -v vv "one\ctwo\n"
printf "%s" "$vv"
# and unrecognized backslash escapes should have the backslash preserverd
printf -v vv "4\.2\n"
printf "%s" "$vv"
printf -v vv "no newline " ; printf "%s" "$vv" ; printf -v vv "now newline\n"
printf "%s" "$vv"
# %% -> %
printf -v vv "%%\n"
printf "%s" "$vv"
# this was a bug caused by pre-processing the string for backslash escapes
# before doing the `%' format processing -- all versions before bash-2.04
printf -v vv "\045"
printf "%s" "$vv"
echo
printf -v vv "\045d\n"
printf "%s" "$vv"
# simple character output
printf -v vv "%c\n" ABCD
printf "%s" "$vv"
# test simple string output
printf -v vv "%s\n" unquoted
printf "%s" "$vv"
# test quoted string output
printf -v vv "%s %q\n" unquoted quoted
printf "%s" "$vv"
printf -v vv "%s%10q\n" unquoted quoted
printf "%s" "$vv"
printf -v vv "%q\n" 'this&that'
printf "%s" "$vv"
# make sure the format string is reused to use up arguments
printf -v vv "%d " 1 2 3 4 5
printf "%s" "$vv"
echo
# make sure that extra format characters get null arguments
printf -v vv "%s %d %d %d\n" onestring
printf "%s" "$vv"
printf -v vv "%s %d %u %4.2f\n" onestring
printf "%s" "$vv"
printf -v vv -- "--%s %s--\n" 4.2 ''
printf "%s" "$vv"
printf -v vv -- "--%s %s--\n" 4.2
printf "%s" "$vv"
# test %b escapes
# 8 is a non-octal digit, so the `81' should be output
printf -v vv -- "--%b--\n" '\n\081'
printf "%s" "$vv"
printf -v vv -- "--%b--\n" '\t\0101'
printf "%s" "$vv"
printf -v vv -- "--%b--\n" '\t\101'
printf "%s" "$vv"
# these should all display `A7'
echo -e "\1017"
echo -e "\x417"
printf -v vv "%b\n" '\01017'
printf "%s" "$vv"
printf -v vv "%b\n" '\1017'
printf "%s" "$vv"
printf -v vv "%b\n" '\x417'
printf "%s" "$vv"
printf -v vv -- "--%b--\n" '\"abcd\"'
printf "%s" "$vv"
printf -v vv -- "--%b--\n" "\'abcd\'"
printf "%s" "$vv"
printf -v vv -- "--%b--\n" 'a\\x'
printf "%s" "$vv"
printf -v vv -- "--%b--\n" '\x'
printf "%s" "$vv"
Z1=$(printf -- "%b\n" '\a\b\e\f\r\v')
Z2=$'\a\b\e\f\r\v'
if [ "$Z1" != "$Z2" ]; then
printf "%s" "whoops: printf -v vv %b and $'' differ" >&2
fi
unset Z1 Z2
printf -v vv -- "--%b--\n" ''
printf "%s" "$vv"
printf -v vv -- "--%b--\n"
printf "%s" "$vv"
# the stuff following the \c should be ignored, as well as the rest
# of the format string
printf -v vv -- "--%b--\n" '4.2\c5.4\n'
printf "%s" "$vv"
echo
# unrecognized escape sequences should by displayed unchanged
printf -v vv -- "--%b--\n" '4\.2'
printf "%s" "$vv"
# a bare \ should not be processed as an escape sequence
printf -v vv -- "--%b--\n" '\'
printf "%s" "$vv"
# make sure extra arguments are ignored if the format string doesn't
# actually use them
printf -v vv "\n" 4.4 BSD
printf "%s" "$vv"
printf -v vv " " 4.4 BSD
printf "%s" "$vv"
echo
# make sure that a fieldwidth and precision of `*' are handled right
printf -v vv "%10.8s\n" 4.4BSD
printf "%s" "$vv"
printf -v vv "%*.*s\n" 10 8 4.4BSD
printf "%s" "$vv"
printf -v vv "%10.8q\n" 4.4BSD
printf "%s" "$vv"
printf -v vv "%*.*q\n" 10 8 4.4BSD
printf "%s" "$vv"
printf -v vv "%6b\n" 4.4BSD
printf "%s" "$vv"
printf -v vv "%*b\n" 6 4.4BSD
printf "%s" "$vv"
# we handle this crap with homemade code in printf -v vv.def
printf -v vv "%10b\n" 4.4BSD
printf "%s" "$vv"
printf -v vv -- "--%-10b--\n" 4.4BSD
printf "%s" "$vv"
printf -v vv "%4.2b\n" 4.4BSD
printf "%s" "$vv"
printf -v vv "%.3b\n" 4.4BSD
printf "%s" "$vv"
printf -v vv -- "--%-8b--\n" 4.4BSD
printf "%s" "$vv"
# test numeric conversions -- these four lines should printf "%s" identically
printf -v vv "%d %u %i 0%o 0x%x 0x%X\n" 255 255 255 255 255 255
printf "%s" "$vv"
printf -v vv "%d %u %i %#o %#x %#X\n" 255 255 255 255 255 255
printf "%s" "$vv"
printf -v vv "%ld %lu %li 0%o 0x%x 0x%X\n" 255 255 255 255 255 255
printf "%s" "$vv"
printf -v vv "%ld %lu %li %#o %#x %#X\n" 255 255 255 255 255 255
printf "%s" "$vv"
printf -v vv "%10d\n" 42
printf "%s" "$vv"
printf -v vv "%10d\n" -42
printf "%s" "$vv"
printf -v vv "%*d\n" 10 42
printf "%s" "$vv"
printf -v vv "%*d\n" 10 -42
printf "%s" "$vv"
# test some simple floating point formats
printf -v vv "%4.2f\n" 4.2
printf "%s" "$vv"
printf -v vv "%#4.2f\n" 4.2
printf "%s" "$vv"
printf -v vv "%#4.1f\n" 4.2
printf "%s" "$vv"
printf -v vv "%*.*f\n" 4 2 4.2
printf "%s" "$vv"
printf -v vv "%#*.*f\n" 4 2 4.2
printf "%s" "$vv"
printf -v vv "%#*.*f\n" 4 1 4.2
printf "%s" "$vv"
printf -v vv "%E\n" 4.2
printf "%s" "$vv"
printf -v vv "%e\n" 4.2
printf "%s" "$vv"
printf -v vv "%6.1E\n" 4.2
printf "%s" "$vv"
printf -v vv "%6.1e\n" 4.2
printf "%s" "$vv"
printf -v vv "%G\n" 4.2
printf "%s" "$vv"
printf -v vv "%g\n" 4.2
printf "%s" "$vv"
printf -v vv "%6.2G\n" 4.2
printf "%s" "$vv"
printf -v vv "%6.2g\n" 4.2
printf "%s" "$vv"
# test some of the more esoteric features of POSIX.1 printf -v vv
printf -v vv "%d\n" "'string'"
printf "%s" "$vv"
printf -v vv "%d\n" '"string"'
printf "%s" "$vv"
printf -v vv "%#o\n" "'string'"
printf "%s" "$vv"
printf -v vv "%#o\n" '"string"'
printf "%s" "$vv"
printf -v vv "%#x\n" "'string'"
printf "%s" "$vv"
printf -v vv "%#X\n" '"string"'
printf "%s" "$vv"
printf -v vv "%6.2f\n" "'string'"
printf "%s" "$vv"
printf -v vv "%6.2f\n" '"string"'
printf "%s" "$vv"
# output from these two lines had better be the same
printf -v vv -- "--%6.4s--\n" abcdefghijklmnopqrstuvwxyz
printf "%s" "$vv"
printf -v vv -- "--%6.4b--\n" abcdefghijklmnopqrstuvwxyz
printf "%s" "$vv"
# and these two also
printf -v vv -- "--%12.10s--\n" abcdefghijklmnopqrstuvwxyz
printf "%s" "$vv"
printf -v vv -- "--%12.10b--\n" abcdefghijklmnopqrstuvwxyz
printf "%s" "$vv"
# tests for translating \' to ' and \\ to \
# printf -v vv translates \' to ' in the format string...
printf -v vv "\'abcd\'\n"
printf "%s" "$vv"
# but not when the %b format specification is used
printf -v vv "%b\n" \\\'abcd\\\'
printf "%s" "$vv"
# but both translate \\ to \
printf -v vv '\\abcd\\\n'
printf "%s" "$vv"
printf -v vv "%b\n" '\\abcd\\'
printf "%s" "$vv"
# this was reported as a bug in bash-2.03
# these three lines should all printf "%s" `26'
printf -v vv "%d\n" 0x1a
printf "%s" "$vv"
printf -v vv "%d\n" 032
printf "%s" "$vv"
printf -v vv "%d\n" 26
printf "%s" "$vv"
# error messages
# this should be an overflow, but error messages vary between systems
# printf -v vv "%lu\n" 4294967296
# ...but we cannot use this because some systems (SunOS4, for example),
# happily ignore overflow conditions in strtol(3)
#printf -v vv "%ld\n" 4294967296
printf -v vv "%10"
printf -v vv "ab%Mcd\n"
# this caused an infinite loop in older versions of printf -v vv
printf -v vv "%y" 0
# these should print a warning and `0', according to POSIX.2
printf -v vv "%d\n" GNU
printf "%s" "$vv"
printf -v vv "%o\n" GNU
printf "%s" "$vv"
# failures in all bash versions through bash-2.05
printf -v vv "%.0s" foo
printf "%s" "$vv"
printf -v vv "%.*s" 0 foo
printf "%s" "$vv"
printf -v vv '%.0b-%.0s\n' foo bar
printf "%s" "$vv"
printf -v vv '(%*b)(%*s)\n' -4 foo -4 bar
printf "%s" "$vv"
format='%'`printf '%0100384d' 0`'d\n'
printf -v vv $format 0
printf "%s" "$vv"
# failures in all bash versions through bash-3.0 - undercounted characters
unset vv
printf -v vv " %s %s %s \n%n" ab cd ef vvv
printf "%s" "$vv"
echo $vvv
# this doesn't work with printf -v vv(3) on all systems
#printf -v vv "%'s\n" foo
# test cases from an austin-group list discussion
# prints ^G as an extension
printf -v vv '%b\n' '\7'
printf "%s" "$vv"
# prints ^G
printf -v vv '%b\n' '\0007'
printf "%s" "$vv"
# prints NUL then 7
printf -v vv '\0007\n'
printf "%s" "$vv"
# prints no more than two hex digits
printf -v vv '\x07e\n'
printf "%s" "$vv"
# additional backslash escapes
printf -v vv '\"\?\n'
printf "%s" "$vv"