commit bash-20080703 snapshot

This commit is contained in:
Chet Ramey
2011-12-07 09:25:28 -05:00
parent fdf670eaa1
commit 09767ff09d
113 changed files with 38264 additions and 36052 deletions
+140 -9646
View File
File diff suppressed because it is too large Load Diff
+143 -9646
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+18
View File
@@ -381,6 +381,7 @@ lib/sh/casemod.c f
lib/sh/clktck.c f
lib/sh/clock.c f
lib/sh/eaccess.c f
lib/sh/fdprintf.c f
lib/sh/fmtullong.c f
lib/sh/fmtulong.c f
lib/sh/fmtumax.c f
@@ -746,12 +747,15 @@ tests/array4.sub f
tests/array5.sub f
tests/array6.sub f
tests/array7.sub f
tests/array8.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
tests/assoc.right f
tests/assoc1.sub f
tests/assoc2.sub f
tests/assoc3.sub f
tests/assoc4.sub f
tests/braces.tests f
tests/braces.right f
tests/builtins.tests f
@@ -766,14 +770,24 @@ tests/source5.sub f
tests/source6.sub f
tests/case.tests f
tests/case.right f
tests/casemod.tests f
tests/casemod.right f
tests/comsub.tests f
tests/comsub.right f
tests/comsub-eof.tests f
tests/comsub-eof0.sub f
tests/comsub-eof1.sub f
tests/comsub-eof2.sub f
tests/comsub-eof3.sub f
tests/comsub-eof.right f
tests/comsub-posix.tests f
tests/comsub-posix.right f
tests/comsub-posix1.sub f
tests/cond.tests f
tests/cond.right f
tests/cond-regexp.sub f
tests/coproc.tests f
tests/coproc.right f
tests/cprint.tests f
tests/cprint.right f
tests/dbg-support.right f
@@ -786,6 +800,7 @@ tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -933,9 +948,12 @@ tests/run-assoc f
tests/run-braces f
tests/run-builtins f
tests/run-case f
tests/run-casemod f
tests/run-comsub f
tests/run-comsub-eof f
tests/run-comsub-posix f
tests/run-cond f
tests/run-coproc f
tests/run-cprint f
tests/run-dbg-support f
tests/run-dbg-support2 f
+22
View File
@@ -746,8 +746,15 @@ tests/array4.sub f
tests/array5.sub f
tests/array6.sub f
tests/array7.sub f
tests/array8.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
tests/assoc.right f
tests/assoc1.sub f
tests/assoc2.sub f
tests/assoc3.sub f
tests/assoc4.sub f
tests/braces.tests f
tests/braces.right f
tests/builtins.tests f
@@ -762,14 +769,24 @@ tests/source5.sub f
tests/source6.sub f
tests/case.tests f
tests/case.right f
tests/casemod.tests f
tests/casemod.right f
tests/comsub.tests f
tests/comsub.right f
tests/comsub-eof.tests f
tests/comsub-eof0.sub f
tests/comsub-eof1.sub f
tests/comsub-eof2.sub f
tests/comsub-eof3.sub f
tests/comsub-eof.right f
tests/comsub-posix.tests f
tests/comsub-posix.right f
tests/comsub-posix1.sub f
tests/cond.tests f
tests/cond.right f
tests/cond-regexp.sub f
tests/coproc.tests f
tests/coproc.right f
tests/cprint.tests f
tests/cprint.right f
tests/dbg-support.right f
@@ -782,6 +799,7 @@ tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -925,12 +943,16 @@ tests/run-arith-for f
tests/run-arith f
tests/run-array f
tests/run-array2 f
tests/run-assoc f
tests/run-braces f
tests/run-builtins f
tests/run-case f
tests/run-casemod f
tests/run-comsub f
tests/run-comsub-eof f
tests/run-comsub-posix f
tests/run-cond f
tests/run-coproc f
tests/run-cprint f
tests/run-dbg-support f
tests/run-dbg-support2 f
+1 -1
View File
@@ -213,7 +213,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/zmapfd.c ${SH_LIBSRC}/fpurge.c \
${SH_LIBSRC}/zgetline.c ${SH_LIBSRC}/mbscmp.c \
${SH_LIBSRC}/casemod.c ${SH_LIBSRC}/uconvert.c \
${SH_LIBSRC}/ufuncs.c
${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/fdprintf.c
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
+1 -1
View File
@@ -993,7 +993,7 @@ shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h arr
shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h
shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
sig.o: config.h bashtypes.h
sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+97 -17
View File
@@ -281,7 +281,7 @@ char *v;
return (array_rshift (a, 1, v));
}
ARRAY *
ARRAY *
array_quote(array)
ARRAY *array;
{
@@ -298,7 +298,7 @@ ARRAY *array;
return array;
}
ARRAY *
ARRAY *
array_quote_escapes(array)
ARRAY *array;
{
@@ -315,6 +315,54 @@ ARRAY *array;
return array;
}
ARRAY *
array_dequote(array)
ARRAY *array;
{
ARRAY_ELEMENT *a;
char *t;
if (array == 0 || array_head(array) == 0 || array_empty(array))
return (ARRAY *)NULL;
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
t = dequote_string (a->value);
FREE(a->value);
a->value = t;
}
return array;
}
ARRAY *
array_dequote_escapes(array)
ARRAY *array;
{
ARRAY_ELEMENT *a;
char *t;
if (array == 0 || array_head(array) == 0 || array_empty(array))
return (ARRAY *)NULL;
for (a = element_forw(array->head); a != array->head; a = element_forw(a)) {
t = dequote_escapes (a->value);
FREE(a->value);
a->value = t;
}
return array;
}
ARRAY *
array_remove_quoted_nulls(array)
ARRAY *array;
{
ARRAY_ELEMENT *a;
char *t;
if (array == 0 || array_head(array) == 0 || array_empty(array))
return (ARRAY *)NULL;
for (a = element_forw(array->head); a != array->head; a = element_forw(a))
a->value = remove_quoted_nulls (a->value);
return array;
}
/*
* Return a string whose elements are the members of array A beginning at
* index START and spanning NELEM members. Null elements are counted.
@@ -329,7 +377,8 @@ int starsub, quoted;
ARRAY *a2;
ARRAY_ELEMENT *h, *p;
arrayind_t i;
char *ifs, *sep, *t;
char *ifs, *sifs, *t;
int slen;
p = a ? array_head (a) : 0;
if (p == 0 || array_empty (a) || start > array_max_index(a))
@@ -361,24 +410,25 @@ int starsub, quoted;
if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) {
/* ${array[*]} */
sep = ifs_firstchar ((int *)NULL);
array_remove_quoted_nulls (a2);
sifs = ifs_firstchar ((int *)NULL);
t = array_to_string (a2, sifs, 0);
free (sifs);
} else if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) {
/* ${array[@]} */
sep = ifs_firstchar ((int *)NULL);
sifs = ifs_firstchar (&slen);
ifs = getifs ();
if (ifs == 0 || *ifs == 0) {
sep[0] = ' ';
sep[1] = '\0';
if (slen < 2)
sifs = xrealloc(sifs, 2);
sifs[0] = ' ';
sifs[1] = '\0';
}
} else {
sep = xmalloc (2);
sep[0] = ' ';
sep[1] = '\0';
}
t = array_to_string (a2, sep, 0);
t = array_to_string (a2, sifs, 0);
free (sifs);
} else
t = array_to_string (a2, " ", 0);
array_dispose(a2);
free (sep);
return t;
}
@@ -391,7 +441,8 @@ int mflags;
{
ARRAY *a2;
ARRAY_ELEMENT *e;
char *t, *sifs;
char *t, *sifs, *ifs;
int slen;
if (a == 0 || array_head(a) == 0 || array_empty(a))
return ((char *)NULL);
@@ -407,10 +458,24 @@ int mflags;
array_quote(a2);
else
array_quote_escapes(a2);
if (mflags & MATCH_STARSUB) {
array_remove_quoted_nulls (a2);
sifs = ifs_firstchar((int *)NULL);
t = array_to_string (a2, sifs, 0);
free(sifs);
} else if (mflags & MATCH_QUOTED) {
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
ifs = getifs ();
if (ifs == 0 || *ifs == 0) {
if (slen < 2)
sifs = xrealloc (sifs, 2);
sifs[0] = ' ';
sifs[1] = '\0';
}
t = array_to_string (a2, sifs, 0);
free(sifs);
} else
t = array_to_string (a2, " ", 0);
array_dispose (a2);
@@ -427,7 +492,8 @@ int mflags;
{
ARRAY *a2;
ARRAY_ELEMENT *e;
char *t, *sifs;
char *t, *sifs, *ifs;
int slen;
if (a == 0 || array_head(a) == 0 || array_empty(a))
return ((char *)NULL);
@@ -443,10 +509,24 @@ int mflags;
array_quote(a2);
else
array_quote_escapes(a2);
if (mflags & MATCH_STARSUB) {
array_remove_quoted_nulls (a2);
sifs = ifs_firstchar((int *)NULL);
t = array_to_string (a2, sifs, 0);
free(sifs);
} else if (mflags & MATCH_QUOTED) {
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
ifs = getifs ();
if (ifs == 0 || *ifs == 0) {
if (slen < 2)
sifs = xrealloc (sifs, 2);
sifs[0] = ' ';
sifs[1] = '\0';
}
t = array_to_string (a2, sifs, 0);
free(sifs);
} else
t = array_to_string (a2, " ", 0);
array_dispose (a2);
+4
View File
@@ -54,8 +54,12 @@ extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int));
extern int array_rshift __P((ARRAY *, int, char *));
extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *));
extern int array_shift_element __P((ARRAY *, char *));
extern ARRAY *array_quote __P((ARRAY *));
extern ARRAY *array_quote_escapes __P((ARRAY *));
extern ARRAY *array_dequote __P((ARRAY *));
extern ARRAY *array_dequote_escapes __P((ARRAY *));
extern ARRAY *array_remove_quoted_nulls __P((ARRAY *));
extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int));
extern char *array_patsub __P((ARRAY *, char *, char *, int));
+144 -4
View File
@@ -160,6 +160,114 @@ assoc_quote_escapes (h)
return h;
}
HASH_TABLE *
assoc_dequote (h)
HASH_TABLE *h;
{
int i;
BUCKET_CONTENTS *tlist;
char *t;
if (h == 0 || assoc_empty (h))
return ((HASH_TABLE *)NULL);
for (i = 0; i < h->nbuckets; i++)
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
{
t = dequote_string ((char *)tlist->data);
FREE (tlist->data);
tlist->data = t;
}
return h;
}
HASH_TABLE *
assoc_dequote_escapes (h)
HASH_TABLE *h;
{
int i;
BUCKET_CONTENTS *tlist;
char *t;
if (h == 0 || assoc_empty (h))
return ((HASH_TABLE *)NULL);
for (i = 0; i < h->nbuckets; i++)
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
{
t = dequote_escapes ((char *)tlist->data);
FREE (tlist->data);
tlist->data = t;
}
return h;
}
HASH_TABLE *
assoc_remove_quoted_nulls (h)
HASH_TABLE *h;
{
int i;
BUCKET_CONTENTS *tlist;
char *t;
if (h == 0 || assoc_empty (h))
return ((HASH_TABLE *)NULL);
for (i = 0; i < h->nbuckets; i++)
for (tlist = hash_items (i, h); tlist; tlist = tlist->next)
{
t = remove_quoted_nulls ((char *)tlist->data);
tlist->data = t;
}
return h;
}
/*
* Return a string whose elements are the members of array H beginning at
* the STARTth element and spanning NELEM members. Null elements are counted.
*/
char *
assoc_subrange (hash, start, nelem, starsub, quoted)
HASH_TABLE *hash;
arrayind_t start, nelem;
int starsub, quoted;
{
WORD_LIST *l, *save, *h, *t;
int i, j;
char *ret;
if (assoc_empty (hash))
return ((char *)NULL);
save = l = assoc_to_word_list (hash);
if (save == 0)
return ((char *)NULL);
for (i = 1; l && i < start; i++)
l = l->next;
if (l == 0)
return ((char *)NULL);
for (j = 0,h = t = l; l && j < nelem; j++)
{
t = l;
l = l->next;
}
t->next = (WORD_LIST *)NULL;
ret = string_list_pos_params (starsub ? '*' : '@', h, quoted);
if (t != l)
t->next = l;
dispose_words (save);
return (ret);
}
char *
assoc_patsub (h, pat, rep, mflags)
HASH_TABLE *h;
@@ -167,9 +275,9 @@ assoc_patsub (h, pat, rep, mflags)
int mflags;
{
BUCKET_CONTENTS *tlist;
int i;
int i, slen;
HASH_TABLE *h2;
char *t, *sifs;
char *t, *sifs, *ifs;
if (h == 0 || assoc_empty (h))
return ((char *)NULL);
@@ -190,10 +298,26 @@ assoc_patsub (h, pat, rep, mflags)
if (mflags & MATCH_STARSUB)
{
assoc_remove_quoted_nulls (h2);
sifs = ifs_firstchar ((int *)NULL);
t = assoc_to_string (h2, sifs, 0);
free (sifs);
}
else if (mflags & MATCH_QUOTED)
{
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
ifs = getifs ();
if (ifs == 0 || *ifs == 0)
{
if (slen < 2)
sifs = xrealloc (sifs, 2);
sifs[0] = ' ';
sifs[1] = '\0';
}
t = assoc_to_string (h2, sifs, 0);
free(sifs);
}
else
t = assoc_to_string (h2, " ", 0);
@@ -210,9 +334,9 @@ assoc_modcase (h, pat, modop, mflags)
int mflags;
{
BUCKET_CONTENTS *tlist;
int i;
int i, slen;
HASH_TABLE *h2;
char *t, *sifs;
char *t, *sifs, *ifs;
if (h == 0 || assoc_empty (h))
return ((char *)NULL);
@@ -233,10 +357,26 @@ assoc_modcase (h, pat, modop, mflags)
if (mflags & MATCH_STARSUB)
{
assoc_remove_quoted_nulls (h2);
sifs = ifs_firstchar ((int *)NULL);
t = assoc_to_string (h2, sifs, 0);
free (sifs);
}
else if (mflags & MATCH_QUOTED)
{
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
ifs = getifs ();
if (ifs == 0 || *ifs == 0)
{
if (slen < 2)
sifs = xrealloc (sifs, 2);
sifs[0] = ' ';
sifs[1] = '\0';
}
t = assoc_to_string (h2, sifs, 0);
free(sifs);
}
else
t = assoc_to_string (h2, " ", 0);
+4
View File
@@ -42,11 +42,15 @@ extern void assoc_remove __P((HASH_TABLE *, char *));
extern char *assoc_reference __P((HASH_TABLE *, char *));
extern char *assoc_subrange __P((HASH_TABLE *, arrayind_t, arrayind_t, int, int));
extern char *assoc_patsub __P((HASH_TABLE *, char *, char *, int));
extern char *assoc_modcase __P((HASH_TABLE *, char *, int, int));
extern HASH_TABLE *assoc_quote __P((HASH_TABLE *));
extern HASH_TABLE *assoc_quote_escapes __P((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote __P((HASH_TABLE *));
extern HASH_TABLE *assoc_dequote_escapes __P((HASH_TABLE *));
extern HASH_TABLE *assoc_remove_quoted_nulls __P((HASH_TABLE *));
extern char *assoc_to_assign __P((HASH_TABLE *, int));
+5782 -1619
View File
File diff suppressed because it is too large Load Diff
+86 -18
View File
@@ -18,46 +18,114 @@
'AM_PROG_F77_C_O' => 1,
'_LT_AC_TAGCONFIG' => 1,
'm4_pattern_forbid' => 1,
'AC_INIT' => 1,
'AC_CANONICAL_TARGET' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_HEADER_TIME' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRTOD' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_FUNC_STRNLEN' => 1,
'm4_sinclude' => 1,
'AC_PROG_CXX' => 1,
'AC_PATH_X' => 1,
'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
'AC_PROG_AWK' => 1,
'_m4_warn' => 1,
'AC_HEADER_STDC' => 1,
'AC_HEADER_MAJOR' => 1,
'AM_PROG_CXX_C_O' => 1,
'LT_INIT' => 1,
'AC_FUNC_ERROR_AT_LINE' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
'AC_LIBSOURCE' => 1,
'AC_FUNC_MBRTOWC' => 1,
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_CANONICAL_BUILD' => 1,
'AM_PROG_FC_C_O' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AC_PROG_MAKE_SET' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_PROG_YACC' => 1,
'AC_SUBST_TRACE' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AC_INIT' => 1,
'AC_FUNC_CHOWN' => 1,
'AC_SUBST' => 1,
'AC_FUNC_ALLOCA' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FC_SRCEXT' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_GETPGRP' => 1,
'AC_PROG_RANLIB' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_FUNC_SETPGRP' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_FUNC_MMAP' => 1,
'AC_FUNC_REALLOC' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_CHECK_TYPES' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
'AC_CONFIG_LINKS' => 1,
'LT_SUPPORTED_TAG' => 1,
'm4_sinclude' => 1,
'AC_CHECK_MEMBERS' => 1,
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
'_m4_warn' => 1,
'AM_PROG_CXX_C_O' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_HEADER_STAT' => 1,
'AC_C_INLINE' => 1,
'AC_PROG_CPP' => 1,
'AC_C_CONST' => 1,
'AM_ENABLE_MULTILIB' => 1,
'AC_PROG_LEX' => 1,
'AC_TYPE_PID_T' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'LT_INIT' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_LIBSOURCE' => 1,
'AM_PROG_FC_C_O' => 1,
'AC_CANONICAL_BUILD' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AC_FC_FREEFORM' => 1,
'AH_OUTPUT' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'm4_pattern_allow' => 1,
'sinclude' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_PROG_LN_S' => 1,
'm4_include' => 1,
'AC_SUBST_TRACE' => 1
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
}
], 'Autom4te::Request' )
);
+1874 -1747
View File
File diff suppressed because it is too large Load Diff
+25 -4
View File
@@ -23,7 +23,7 @@ $PRODUCES declare.c
$BUILTIN declare
$FUNCTION declare_builtin
$SHORT_DOC declare [-afFirtx] [-p] [name[=value] ...]
$SHORT_DOC declare [-aAfFilrtux] [-p] [name[=value] ...]
Set variable values and attributes.
Declare variables and give them attributes. If no NAMEs are given,
@@ -39,8 +39,10 @@ Options which set attributes:
-a to make NAMEs indexed arrays (if supported)
-A to make NAMEs associative arrays (if supported)
-i to make NAMEs have the `integer' attribute
-l to convert NAMEs to lower case on assignment
-r to make NAMEs readonly
-t to make NAMEs have the `trace' attribute
-u to convert NAMEs to upper case on assignment
-x to make NAMEs export
Using `+' instead of `-' turns off the given attribute.
@@ -57,7 +59,7 @@ $END
$BUILTIN typeset
$FUNCTION declare_builtin
$SHORT_DOC typeset [-afFirtx] [-p] name[=value] ...
$SHORT_DOC typeset [-aAfFilrtux] [-p] name[=value] ...
Set variable values and attributes.
Obsolete. See `help declare'.
@@ -124,9 +126,9 @@ local_builtin (list)
}
#if defined (ARRAY_VARS)
# define DECLARE_OPTS "+afiprtxAF"
# define DECLARE_OPTS "+acfilprtuxAF"
#else
# define DECLARE_OPTS "+fiprtxF"
# define DECLARE_OPTS "+cfilprtuxF"
#endif
/* The workhorse function. */
@@ -189,6 +191,25 @@ declare_internal (list, local_var)
*flags |= att_exported;
array_needs_making = 1;
break;
#if defined (CASEMOD_ATTRS)
# if defined (CASEMOD_CAPCASE)
case 'c':
*flags |= att_capcase;
if (flags == &flags_on)
flags_off |= att_uppercase|att_lowercase;
break;
# endif
case 'l':
*flags |= att_lowercase;
if (flags == &flags_on)
flags_off |= att_capcase|att_uppercase;
break;
case 'u':
*flags |= att_uppercase;
if (flags == &flags_on)
flags_off |= att_capcase|att_lowercase;
break;
#endif /* CASEMOD_ATTRS */
default:
builtin_usage ();
return (EX_USAGE);
+106
View File
@@ -336,6 +336,112 @@ parse_and_execute (string, from_file, flags)
return (last_result);
}
/* Parse a command contained in STRING according to FLAGS and return the
number of characters consumed from the string. If non-NULL, set *ENDP
to the position in the string where the parse ended. Used to validate
command substitutions during parsing to obey Posix rules about finding
the end of the command and balancing parens. */
int
parse_string (string, from_file, flags, endp)
char *string;
const char *from_file;
int flags;
char **endp;
{
int code, nc;
volatile int should_jump_to_top_level;
COMMAND *volatile command, *oglobal;
char *ostring;
parse_prologue (string, flags, PS_TAG);
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
0; the first line number is 1). */
push_stream (0);
code = should_jump_to_top_level = 0;
oglobal = global_command;
with_input_from_string (string, from_file);
while (*(bash_input.location.string))
{
command = (COMMAND *)NULL;
#if 0
if (interrupt_state)
break;
#endif
/* Provide a location for functions which `longjmp (top_level)' to
jump to. */
code = setjmp (top_level);
if (code)
{
#if defined (DEBUG)
itrace("parse_string: longjmp executed: code = %d", code);
#endif
should_jump_to_top_level = 0;
switch (code)
{
case FORCE_EOF:
case ERREXIT:
case EXITPROG:
case DISCARD: /* XXX */
if (command)
dispose_command (command);
/* Remember to call longjmp (top_level) after the old
value for it is restored. */
should_jump_to_top_level = 1;
goto out;
default:
command_error ("parse_string", CMDERR_BADJUMP, code, 0);
break;
}
}
if (parse_command () == 0)
{
dispose_command (global_command);
global_command = (COMMAND *)NULL;
}
else
{
if ((flags & SEVAL_NOLONGJMP) == 0)
{
should_jump_to_top_level = 1;
code = DISCARD;
}
else
reset_parser (); /* XXX - sets token_to_read */
break;
}
if (current_token == yacc_EOF || current_token == shell_eof_token)
{
itrace("parse_string: current_token = %d; breaking", current_token);
break;
}
}
out:
global_command = oglobal;
nc = bash_input.location.string - ostring;
if (endp)
*endp = bash_input.location.string;
run_unwind_frame (PS_TAG);
if (should_jump_to_top_level)
jump_to_top_level (code);
return (nc);
}
/* Handle a $( < file ) command substitution. This expands the filename,
returning errors as appropriate, then just cats the file to the standard
output. */
+9
View File
@@ -377,6 +377,15 @@ show_var_attributes (var, pattr, nodefs)
if (exported_p (var))
flags[i++] = 'x';
if (capcase_p (var))
flags[i++] = 'c';
if (lowercase_p (var))
flags[i++] = 'l';
if (uppercase_p (var))
flags[i++] = 'u';
}
else
{
+1
View File
@@ -28,6 +28,7 @@ $SHORT_DOC suspend [-f]
Suspend shell execution.
Suspend the execution of this shell until it receives a SIGCONT signal.
Unless forced, login shells cannot be suspended.
Options:
-f force the suspend, even if the shell is a login shell
+4
View File
@@ -92,3 +92,7 @@
for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment,
which can be fooled under certain not-uncommon circumstances. */
/* #define SSH_SOURCE_BASHRC */
/* Define if you want the case-capitalizing operators (~[~]) and the
`capcase' variable attribute (declare -c). */
#define CASEMOD_CAPCASE
+7
View File
@@ -123,6 +123,10 @@
=~ binary operator in the [[...]] conditional command. */
#define COND_REGEXP
/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and
the `coproc' reserved word */
#define COPROCESS_SUPPORT
/* Define ARITH_FOR_COMMAND if you want the ksh93-style
for (( init; test; step )) do list; done
arithmetic for command. */
@@ -538,6 +542,9 @@
/* Define if you have the fcntl function. */
#undef HAVE_FCNTL
/* Define if you have the fdprintf function. */
#undef HAVE_FDPRINTF
/* Define if you have the fpurge/__fpurge function. */
#undef HAVE_FPURGE
#undef HAVE___FPURGE
+14
View File
@@ -123,6 +123,10 @@
=~ binary operator in the [[...]] conditional command. */
#define COND_REGEXP
/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and
the `coproc' reserved word */
#define COPROCESS_SUPPORT
/* Define ARITH_FOR_COMMAND if you want the ksh93-style
for (( init; test; step )) do list; done
arithmetic for command. */
@@ -155,6 +159,13 @@
/* Define AFS if you are using Transarc's AFS. */
#undef AFS
/* Define for case-modifying variable attributes; variables modified on
assignment */
#undef CASEMOD_ATTRS
/* Define for case-modifying word expansions */
#undef CASEMOD_EXPANSIONS
#undef ENABLE_NLS
/* End of configuration settings controllable by autoconf. */
@@ -686,6 +697,9 @@
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setitimer function. */
#undef HAVE_SETITIMER
/* Define if you have the setlinebuf function. */
#undef HAVE_SETLINEBUF
Vendored
+5780 -1617
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 4.0, version 4.002])dnl
AC_REVISION([for Bash 4.0, version 4.003])dnl
define(bashvers, 4.0)
define(relstatus, devel)
@@ -176,6 +176,7 @@ opt_xpg_echo=no
opt_strict_posix=no
opt_cond_command=yes
opt_cond_regexp=yes
opt_coproc=yes
opt_arith_for_command=yes
opt_net_redirs=yes
opt_progcomp=yes
@@ -203,7 +204,7 @@ if test $opt_minimal_config = yes; then
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
opt_multibyte=yes opt_cond_regexp=no
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
opt_casemod_attrs=no opt_casemod_expansions=no
fi
@@ -217,6 +218,7 @@ AC_ARG_ENABLE(casemod-expansions, AC_HELP_STRING([--enable-casemod-expansions],
AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
@@ -301,6 +303,9 @@ fi
if test $opt_cond_regexp = yes ; then
AC_DEFINE(COND_REGEXP)
fi
if test $opt_coproc = yes; then
AC_DEFINE(COPROCESS_SUPPORT)
fi
if test $opt_arith_for_command = yes; then
AC_DEFINE(ARITH_FOR_COMMAND)
fi
@@ -724,6 +729,7 @@ AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit)
AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
AC_REPLACE_FUNCS(getcwd memset strcasecmp strerror strftime strnlen strpbrk strstr)
AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
AC_REPLACE_FUNCS(fdprintf)
AC_CHECK_DECLS([confstr])
AC_CHECK_DECLS([printf])
+19 -3
View File
@@ -22,7 +22,7 @@ dnl Process this file with autoconf to produce a configure script.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_REVISION([for Bash 4.0, version 4.001])dnl
AC_REVISION([for Bash 4.0, version 4.003])dnl
define(bashvers, 4.0)
define(relstatus, devel)
@@ -176,6 +176,7 @@ opt_xpg_echo=no
opt_strict_posix=no
opt_cond_command=yes
opt_cond_regexp=yes
opt_coproc=yes
opt_arith_for_command=yes
opt_net_redirs=yes
opt_progcomp=yes
@@ -183,6 +184,8 @@ opt_separate_help=no
opt_multibyte=yes
opt_debugger=yes
opt_single_longdoc_strings=yes
opt_casemod_attrs=yes
opt_casemod_expansions=yes
dnl options that affect how bash is compiled and linked
opt_static_link=no
@@ -201,7 +204,8 @@ if test $opt_minimal_config = yes; then
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
opt_multibyte=yes opt_cond_regexp=no
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
opt_casemod_attrs=no opt_casemod_expansions=no
fi
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
@@ -209,9 +213,12 @@ AC_ARG_ENABLE(arith-for-command, AC_HELP_STRING([--enable-arith-for-command], [e
AC_ARG_ENABLE(array-variables, AC_HELP_STRING([--enable-array-variables], [include shell array variables]), opt_array_variables=$enableval)
AC_ARG_ENABLE(bang-history, AC_HELP_STRING([--enable-bang-history], [turn on csh-style history substitution]), opt_bang_history=$enableval)
AC_ARG_ENABLE(brace-expansion, AC_HELP_STRING([--enable-brace-expansion], [include brace expansion]), opt_brace_expansion=$enableval)
AC_ARG_ENABLE(casemod-attributes, AC_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval)
AC_ARG_ENABLE(casemod-expansions, AC_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$enableval)
AC_ARG_ENABLE(command-timing, AC_HELP_STRING([--enable-command-timing], [enable the time reserved word and command timing]), opt_command_timing=$enableval)
AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the conditional command]), opt_cond_command=$enableval)
AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
@@ -296,6 +303,9 @@ fi
if test $opt_cond_regexp = yes ; then
AC_DEFINE(COND_REGEXP)
fi
if test $opt_coproc = yes; then
AC_DEFINE(COPROCESS_SUPPORT)
fi
if test $opt_arith_for_command = yes; then
AC_DEFINE(ARITH_FOR_COMMAND)
fi
@@ -311,6 +321,12 @@ fi
if test $opt_debugger = yes; then
AC_DEFINE(DEBUGGER)
fi
if test $opt_casemod_attrs = yes; then
AC_DEFINE(CASEMOD_ATTRS)
fi
if test $opt_casemod_expansions = yes; then
AC_DEFINE(CASEMOD_EXPANSIONS)
fi
if test $opt_memscramble = yes; then
AC_DEFINE(MEMSCRAMBLE)
@@ -698,7 +714,7 @@ dnl checks for system calls
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat readlink sbrk select setdtablesize \
tcgetpgrp uname ulimit waitpid)
setitimer tcgetpgrp uname ulimit waitpid)
AC_REPLACE_FUNCS(rename)
dnl checks for c library functions
+18
View File
@@ -40,6 +40,7 @@ static ARITH_FOR_COM *copy_arith_for_command __P((ARITH_FOR_COM *));
#endif
static GROUP_COM *copy_group_command __P((GROUP_COM *));
static SUBSHELL_COM *copy_subshell_command __P((SUBSHELL_COM *));
static COPROC_COM *copy_coproc_command __P((COPROC_COM *));
static CASE_COM *copy_case_command __P((CASE_COM *));
static WHILE_COM *copy_while_command __P((WHILE_COM *));
static IF_COM *copy_if_command __P((IF_COM *));
@@ -215,6 +216,19 @@ copy_subshell_command (com)
return (new_subshell);
}
static COPROC_COM *
copy_coproc_command (com)
COPROC_COM *com;
{
COPROC_COM *new_coproc;
new_coproc = (COPROC_COM *)xmalloc (sizeof (COPROC_COM));
new_coproc->name = savestring (com->name);
new_coproc->command = copy_command (com->command);
new_coproc->flags = com->flags;
return (new_coproc);
}
static CASE_COM *
copy_case_command (com)
CASE_COM *com;
@@ -375,6 +389,10 @@ copy_command (command)
new_command->value.Subshell = copy_subshell_command (command->value.Subshell);
break;
case cm_coproc:
new_command->value.Coproc = copy_coproc_command (command->value.Coproc);
break;
case cm_case:
new_command->value.Case = copy_case_command (command->value.Case);
break;
+2
View File
@@ -85,6 +85,7 @@ copy_case_clause (clause)
new_clause = (PATTERN_LIST *)xmalloc (sizeof (PATTERN_LIST));
new_clause->patterns = copy_word_list (clause->patterns);
new_clause->action = copy_command (clause->action);
new_clause->flags = clause->flags;
return (new_clause);
}
@@ -124,6 +125,7 @@ copy_redirect (redirect)
case r_input_direction:
case r_inputa_direction:
case r_err_and_out:
case r_append_err_and_out:
case r_input_output:
case r_output_force:
case r_duplicating_input_word:
+8
View File
@@ -92,6 +92,14 @@ dispose_command (command)
break;
}
case cm_coproc:
{
free (command->value.Coproc->name);
dispose_command (command->value.Coproc->command);
free (command->value.Coproc);
break;
}
case cm_case:
{
register CASE_COM *c;
+1 -1
View File
@@ -1,6 +1,6 @@
/* dispose_command.c -- dispose of a COMMAND structure. */
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+784 -728
View File
File diff suppressed because it is too large Load Diff
+112 -25
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Sun Jun 29 22:44:15 EDT 2008
.\" Last Change: Sun Jul 6 14:33:52 EDT 2008
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2008 June 29" "GNU Bash-4.0"
.TH BASH 1 "2008 July 6" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -871,6 +871,42 @@ The exit status of the \fBwhile\fP and \fBuntil\fP commands
is the exit status
of the last \fBdo\fP \fIlist\fP command executed, or zero if
none was executed.
.SS Coprocesses
.PP
A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved
word.
A coprocess is executed asynchronously in a subshell, as if the command
had been terminated with the \fB&\fP control operator, with a two-way pipe
established between the executing shell and the coprocess.
.PP
The format for a coprocess is:
.RS
.PP
\fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP]
.RE
.PP
This creates a coprocess named \fINAME\fP.
If \fINAME\fP is not supplied, the default name is \fICOPROC\fP.
When the coproc is executed, the shell creates an array variable (see
.B Arrays
below) named \fINAME\fP in the context of the executing shell.
The standard output of
.I command
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to \fINAME\fP[0].
The standard input of
.I command
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to \fINAME\fP[1].
This pipe is established before any redirections specified by the
command (see
.SM
.B REDIRECTION
below).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
.PP
The return status of a coprocess is the exit status of \fIcommand\fP.
.SS Shell Function Definitions
.PP
A shell function is an object that is called like a simple command and
@@ -2116,15 +2152,15 @@ parser to treat the rest of the line as a comment.
.SS Arrays
.B Bash
provides one-dimensional indexed and associative array variables.
Any variable may be used as an array; the
Any variable may be used as an indexed array; the
.B declare
builtin will explicitly declare an array.
There is no maximum
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously.
Indexed arrays are referenced using integers (including arithmetic
expressions) and are zero-based; associative arrays use arbitrary
strings.
expressions) and are zero-based; associative arrays are referenced
using arbitrary strings.
.PP
An indexed array is created automatically if any variable is assigned to
using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
@@ -2138,21 +2174,24 @@ use
.B SHELL BUILTIN COMMANDS
below).
.B declare \-a \fIname\fP[\fIsubscript\fP]
is also accepted; the \fIsubscript\fP is ignored. Attributes may be
is also accepted; the \fIsubscript\fP is ignored.
.PP
Associative arrays are created using
.BR "declare \-A \fIname\fP" .
.PP
Attributes may be
specified for an array variable using the
.B declare
and
.B readonly
builtins. Each attribute applies to all members of an array.
.PP
Associative arrays are created using
.BR declare \-A \fIname\fP .
.PP
Arrays are assigned to using compound assignments of the form
\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
\fIstring\fP is required. When using indexed arrays, if
the optional brackets and subscript are supplied, that index is assigned to;
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP.
Indexed array assignments do not require the bracket and subscript.
When assigning to indexed arrays, if the optional brackets and subscript
are supplied, that index is assigned to;
otherwise the index of the element assigned is the last index assigned
to by the statement plus one. Indexing starts at zero.
.PP
@@ -2508,11 +2547,13 @@ If \fIoffset\fP evaluates to a number less than zero, the value
is used as an offset from the end of the value of \fIparameter\fP.
If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
parameters beginning at \fIoffset\fP.
If \fIparameter\fP is an array name indexed by @ or *,
If \fIparameter\fP is an indexed array name subscripted by @ or *,
the result is the \fIlength\fP
members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
A negative \fIoffset\fP is taken relative to one greater than the maximum
index of the specified array.
Substring expansion applied to an associative array produces undefined
results.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the :- expansion.
Substring indexing is zero-based unless the positional parameters
@@ -2653,6 +2694,43 @@ or
.BR * ,
the substitution operation is applied to each member of the
array in turn, and the expansion is the resultant list.
.TP
${\fIparameter\fP\fB^\fP\fIpattern\fP}
.PD 0
.TP
${\fIparameter\fP\fB^^\fP\fIpattern\fP}
.TP
${\fIparameter\fP\fB,\fP\fIpattern\fP}
.TP
${\fIparameter\fP\fB,,\fP\fIpattern\fP}
.PD
This expansion modifies the case of alphabetic characters in \fIparameter\fP.
The \fIpattern\fP is expanded to produce a pattern just as in
pathname expansion.
The \fB^\fP operator converts lowercase letters matching \fIpattern\fP
to uppercase; the \fB,\fP operator converts matching uppercase letters
to lowercase.
The \fB^^\fP and \fB,,\fP expansions convert each matched character in the
expanded value; the \fB^\fP and \fB,\fP expansions match and convert only
the first character.
If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches
every character.
If
.I parameter
is
.B @
or
.BR * ,
the case modification operation is applied to each positional
parameter in turn, and the expansion is the resultant list.
If
.I parameter
is an array variable subscripted with
.B @
or
.BR * ,
the case modification operation is applied to each member of the
array in turn, and the expansion is the resultant list.
.SS Command Substitution
.PP
\fICommand substitution\fP allows the output of a command to replace
@@ -6645,10 +6723,10 @@ is greater than the number of enclosing loops, the last enclosing loop
(the ``top-level'' loop) is resumed.
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
.TP
\fBdeclare\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
\fBdeclare\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
.PD 0
.TP
\fBtypeset\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
\fBtypeset\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
.PD
Declare variables and/or give them attributes.
If no \fIname\fPs are given then display the values of variables.
@@ -6702,6 +6780,11 @@ The variable is treated as an integer; arithmetic evaluation (see
.B "ARITHMETIC EVALUATION" ") "
is performed when the variable is assigned a value.
.TP
.B \-l
When the variable is assigned a value, all upper-case characters are
converted to lower-case.
The upper-case attribute is disabled.
.TP
.B \-r
Make \fIname\fPs readonly. These names cannot then be assigned values
by subsequent assignment statements or unset.
@@ -6712,6 +6795,11 @@ Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
the calling shell.
The trace attribute has no special meaning for variables.
.TP
.B \-u
When the variable is assigned a value, all lower-case characters are
converted to upper-case.
The lower-case attribute is disabled.
.TP
.B \-x
Mark \fIname\fPs for export to subsequent commands via the environment.
.PD
@@ -7505,9 +7593,7 @@ is supplied, or
.B logout
Exit a login shell.
.TP
\fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcou
nt\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \f
Iquantum\fP] [\fIarray\fP]
\fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
Read lines from the standard input into array variable
.IR array ,
or from file descriptor
@@ -7709,7 +7795,7 @@ The return status is 0 unless an error occurs while
reading the name of the current directory or an
invalid option is supplied.
.TP
\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fb\-\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
One line is read from the standard input, or from the file descriptor
\fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
is assigned to the first
@@ -7798,8 +7884,8 @@ are supplied, the line read is assigned to the variable
.SM
.BR REPLY .
The return code is zero, unless end-of-file is encountered, \fBread\fP
times out, or an invalid file descriptor is supplied as the argument to
\fB\-u\fP.
times out (in which case the return code is greater than 128), or an
invalid file descriptor is supplied as the argument to \fB\-u\fP.
.RE
.TP
\fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
@@ -8555,11 +8641,10 @@ by default.
Suspend the execution of this shell until it receives a
.SM
.B SIGCONT
signal. The
signal. A login shell cannot be suspended; the
.B \-f
option says not to complain if this is
a login shell; just suspend anyway. The return status is 0 unless
the shell is a login shell and
option can be used to override this and force the suspension.
The return status is 0 unless the shell is a login shell and
.B \-f
is not supplied, or if job control is not enabled.
.TP
@@ -9249,5 +9334,7 @@ unmatched parentheses, even inside shell comments, will result in
error messages while the construct is being read.
.PP
Array variables may not (yet) be exported.
.PP
There may be only one active coprocess at a time.
.zZ
.zY
+112 -25
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Mon Jun 2 20:32:53 EDT 2008
.\" Last Change: Sun Jul 6 14:33:52 EDT 2008
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2008 June 2" "GNU Bash-4.0"
.TH BASH 1 "2008 July 6" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -871,6 +871,42 @@ The exit status of the \fBwhile\fP and \fBuntil\fP commands
is the exit status
of the last \fBdo\fP \fIlist\fP command executed, or zero if
none was executed.
.SS Coprocesses
.PP
A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved
word.
A coprocess is executed asynchronously in a subshell, as if the command
had been terminated with the \fB&\fP control operator, with a two-way pipe
established between the executing shell and the coprocess.
.PP
The format for a coprocess is:
.RS
.PP
\fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP]
.RE
.PP
This creates a coprocess named \fINAME\fP.
If \fINAME\fP is not supplied, the default name is \fICOPROC\fP.
When the coproc is executed, the shell creates an array variable (see
.B arrays
below) named \fINAME\fP in the context of the executing shell.
The standard output of
.I command
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to \fINAME\fP[0].
The standard input of
.I command
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to \fINAME\fP[1].
This pipe is established before any redirections specified by the
command (see
.SM
.B REDIRECTION
below).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
.PP
The return status of a coprocess is the exit status of \fIcommand\fP.
.SS Shell Function Definitions
.PP
A shell function is an object that is called like a simple command and
@@ -2116,15 +2152,15 @@ parser to treat the rest of the line as a comment.
.SS Arrays
.B Bash
provides one-dimensional indexed and associative array variables.
Any variable may be used as an array; the
Any variable may be used as an indexed array; the
.B declare
builtin will explicitly declare an array.
There is no maximum
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously.
Indexed arrays are referenced using integers (including arithmetic
expressions) and are zero-based; associative arrays use arbitrary
strings.
expressions) and are zero-based; associative arrays are referenced
using arbitrary strings.
.PP
An indexed array is created automatically if any variable is assigned to
using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
@@ -2138,21 +2174,24 @@ use
.B SHELL BUILTIN COMMANDS
below).
.B declare \-a \fIname\fP[\fIsubscript\fP]
is also accepted; the \fIsubscript\fP is ignored. Attributes may be
is also accepted; the \fIsubscript\fP is ignored.
.PP
Associative arrays are created using
.BR "declare \-A \fIname\fP" .
.PP
Attributes may be
specified for an array variable using the
.B declare
and
.B readonly
builtins. Each attribute applies to all members of an array.
.PP
Associative arrays are created using
.BR declare \-A \fIname\fP .
.PP
Arrays are assigned to using compound assignments of the form
\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
\fIstring\fP is required. When using indexed arrays, if
the optional brackets and subscript are supplied, that index is assigned to;
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP.
Indexed array assignments do not require the bracket and subscript.
When assigning to indexed arrays, if the optional brackets and subscript
are supplied, that index is assigned to;
otherwise the index of the element assigned is the last index assigned
to by the statement plus one. Indexing starts at zero.
.PP
@@ -2508,11 +2547,13 @@ If \fIoffset\fP evaluates to a number less than zero, the value
is used as an offset from the end of the value of \fIparameter\fP.
If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
parameters beginning at \fIoffset\fP.
If \fIparameter\fP is an array name indexed by @ or *,
If \fIparameter\fP is an indexed array name subscripted by @ or *,
the result is the \fIlength\fP
members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
A negative \fIoffset\fP is taken relative to one greater than the maximum
index of the specified array.
Substring expansion applied to an associative array produces undefined
results.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the :- expansion.
Substring indexing is zero-based unless the positional parameters
@@ -2653,6 +2694,43 @@ or
.BR * ,
the substitution operation is applied to each member of the
array in turn, and the expansion is the resultant list.
.TP
${\fIparameter\fP\fB^\fP\fIpattern\fP}
.PD 0
.TP
${\fIparameter\fP\fB^^\fP\fIpattern\fP}
.TP
${\fIparameter\fP\fB,\fP\fIpattern\fP}
.TP
${\fIparameter\fP\fB,,\fP\fIpattern\fP}
.PD
This expansion modifies the case of alphabetic characters in \fIparameter\fP.
The \fIpattern\fP is expanded to produce a pattern just as in
pathname expansion.
The \fB^\fP operator converts lowercase letters matching \fIpattern\fP
to uppercase; the \fB,\fP operator converts matching uppercase letters
to lowercase.
The \fB^^\fP and \fB,,\fP expansions convert each matched character in the
expanded value; the \fB^\fP and \fB,\fP expansions match and convert only
the first character.
If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches
every character.
If
.I parameter
is
.B @
or
.BR * ,
the case modification operation is applied to each positional
parameter in turn, and the expansion is the resultant list.
If
.I parameter
is an array variable subscripted with
.B @
or
.BR * ,
the case modification operation is applied to each member of the
array in turn, and the expansion is the resultant list.
.SS Command Substitution
.PP
\fICommand substitution\fP allows the output of a command to replace
@@ -6645,10 +6723,10 @@ is greater than the number of enclosing loops, the last enclosing loop
(the ``top-level'' loop) is resumed.
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
.TP
\fBdeclare\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
\fBdeclare\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
.PD 0
.TP
\fBtypeset\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
\fBtypeset\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
.PD
Declare variables and/or give them attributes.
If no \fIname\fPs are given then display the values of variables.
@@ -6702,6 +6780,11 @@ The variable is treated as an integer; arithmetic evaluation (see
.B "ARITHMETIC EVALUATION" ") "
is performed when the variable is assigned a value.
.TP
.B \-l
When the variable is assigned a value, all upper-case characters are
converted to lower-case.
The upper-case attribute is disabled.
.TP
.B \-r
Make \fIname\fPs readonly. These names cannot then be assigned values
by subsequent assignment statements or unset.
@@ -6712,6 +6795,11 @@ Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
the calling shell.
The trace attribute has no special meaning for variables.
.TP
.B \-u
When the variable is assigned a value, all lower-case characters are
converted to upper-case.
The lower-case attribute is disabled.
.TP
.B \-x
Mark \fIname\fPs for export to subsequent commands via the environment.
.PD
@@ -7505,9 +7593,7 @@ is supplied, or
.B logout
Exit a login shell.
.TP
\fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcou
nt\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \f
Iquantum\fP] [\fIarray\fP]
\fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
Read lines from the standard input into array variable
.IR array ,
or from file descriptor
@@ -7709,7 +7795,7 @@ The return status is 0 unless an error occurs while
reading the name of the current directory or an
invalid option is supplied.
.TP
\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fb\-\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
\fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
One line is read from the standard input, or from the file descriptor
\fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
is assigned to the first
@@ -7798,8 +7884,8 @@ are supplied, the line read is assigned to the variable
.SM
.BR REPLY .
The return code is zero, unless end-of-file is encountered, \fBread\fP
times out, or an invalid file descriptor is supplied as the argument to
\fB\-u\fP.
times out (in which case the return code is greater than 128), or an
invalid file descriptor is supplied as the argument to \fB\-u\fP.
.RE
.TP
\fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
@@ -8555,11 +8641,10 @@ by default.
Suspend the execution of this shell until it receives a
.SM
.B SIGCONT
signal. The
signal. A login shell cannot be suspended; the
.B \-f
option says not to complain if this is
a login shell; just suspend anyway. The return status is 0 unless
the shell is a login shell and
option can be used to override this and force the suspension.
The return status is 0 unless the shell is a login shell and
.B \-f
is not supplied, or if job control is not enabled.
.TP
@@ -9249,5 +9334,7 @@ unmatched parentheses, even inside shell comments, will result in
error messages while the construct is being read.
.PP
Array variables may not (yet) be exported.
.PP
There may be only one active coprocess at a time.
.zZ
.zY
+135 -33
View File
@@ -3,7 +3,7 @@
</HEAD>
<BODY><TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2008 May 25<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2008 June 29<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<BR><A HREF="#index">Index</A>
@@ -1467,7 +1467,9 @@ When += is applied to an array variable using compound assignment (see
below), the
variable's value is not unset (as it is when using =), and new values are
appended to the array beginning at one greater than the array's maximum index.
appended to the array beginning at one greater than the array's maximum index
(for indexed arrays) or added as additional key-value pairs in an
associative array.
When applied to a string-valued variable, <I>value</I> is expanded and
appended to the variable's value.
<A NAME="lbAT">&nbsp;</A>
@@ -1644,6 +1646,13 @@ Expands to the full file name used to invoke this instance of
Expands to the process id of the current <B>bash</B> process.
This differs from <B>$$</B> under certain circumstances, such as subshells
that do not require <B>bash</B> to be re-initialized.
<DT><B>BASH_ALIASES</B>
<DD>
An associative array variable whose members correspond to the internal
list of aliases as maintained by the <B>alias</B> builtin
Elements added to this array appear in the alias list; unsetting array
elements cause aliases to be removed from the alias list.
<DT><B>BASH_ARGC</B>
<DD>
@@ -1678,6 +1687,13 @@ option to the
<B>shopt</B>
builtin below)
<DT><B>BASH_CMDS</B>
<DD>
An associative array variable whose members correspond to the internal
hash table of commands as maintained by the <B>hash</B> builtin.
Elements added to this array appear in the hash table; unsetting array
elements cause commands to be removed from the hash table.
<DT><B>BASH_COMMAND</B>
<DD>
@@ -2501,6 +2517,16 @@ had been executed.
<DD>
If set, the value is executed as a command prior to issuing each primary
prompt.
<DT><B>PROMPT_DIRTRIM</B>
<DD>
If set to a number greater than zero, the value is used as the number of
trailing directory components to retain when expanding the <B>\w and
\W</B> prompt string escapes (see
<FONT SIZE=-1><B>PROMPTING</B>
</FONT>
below). Characters removed are replaced with an ellipsis.
<DT><B>PS1</B>
<DD>
@@ -2688,22 +2714,26 @@ parser to treat the rest of the line as a comment.
<B>Bash</B>
provides one-dimensional array variables. Any variable may be used as
an array; the
provides one-dimensional indexed and associative array variables.
Any variable may be used as an indexed array; the
<B>declare</B>
builtin will explicitly declare an array. There is no maximum
builtin will explicitly declare an array.
There is no maximum
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously. Arrays are indexed using
integers and are zero-based.
be indexed or assigned contiguously.
Indexed arrays are referenced using integers (including arithmetic
expressions) and are zero-based; associative arrays are referenced
using arbitrary strings.
<P>
An array is created automatically if any variable is assigned to using
the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
An indexed array is created automatically if any variable is assigned to
using the syntax <I>name</I>[<I>subscript</I>]=<I>value</I>. The
<I>subscript</I>
is treated as an arithmetic expression that must evaluate to a number
greater than or equal to zero. To explicitly declare an array, use
greater than or equal to zero. To explicitly declare an indexed array,
use
<B>declare -a </B><I>name</I>
(see
@@ -2713,7 +2743,15 @@ greater than or equal to zero. To explicitly declare an array, use
below).
<B>declare -a </B><I>name</I>[<I>subscript</I>]
is also accepted; the <I>subscript</I> is ignored. Attributes may be
is also accepted; the <I>subscript</I> is ignored.
<P>
Associative arrays are created using
<B>declare -A </B><I>name</I>.
<P>
Attributes may be
specified for an array variable using the
<B>declare</B>
@@ -2725,11 +2763,17 @@ builtins. Each attribute applies to all members of an array.
Arrays are assigned to using compound assignments of the form
<I>name</I>=<B>(</B>value<I>1</I> ... value<I>n</I><B>)</B>, where each
<I>value</I> is of the form [<I>subscript</I>]=<I>string</I>. Only
<I>string</I> is required. If
the optional brackets and subscript are supplied, that index is assigned to;
<I>value</I> is of the form [<I>subscript</I>]=<I>string</I>.
Indexed array assignments do not require the bracket and subscript.
When assigning to indexed arrays, if the optional brackets and subscript
are supplied, that index is assigned to;
otherwise the index of the element assigned is the last index assigned
to by the statement plus one. Indexing starts at zero.
<P>
When assigning to an associative array, the subscript is required.
<P>
This syntax is also accepted by the
<B>declare</B>
@@ -2764,7 +2808,7 @@ above). ${#<I>name</I>[<I>subscript</I>]} expands to the length of
${<I>name</I>[<I>subscript</I>]}. If <I>subscript</I> is <B>*</B> or
<B>@</B>, the expansion is the number of elements in the array.
Referencing an array variable without a subscript is equivalent to
referencing element zero.
referencing the array with a subscript of 0.
<P>
The
@@ -2790,7 +2834,11 @@ and
builtins each accept a
<B>-a</B>
option to specify an array. The
option to specify an indexed array and a
<B>-A</B>
option to specify an associative array.
The
<B>read</B>
builtin accepts a
@@ -3166,11 +3214,13 @@ If <I>offset</I> evaluates to a number less than zero, the value
is used as an offset from the end of the value of <I>parameter</I>.
If <I>parameter</I> is <B>@</B>, the result is <I>length</I> positional
parameters beginning at <I>offset</I>.
If <I>parameter</I> is an array name indexed by @ or *,
If <I>parameter</I> is an indexed array name subscripted by @ or *,
the result is the <I>length</I>
members of the array beginning with ${<I>parameter</I>[<I>offset</I>]}.
A negative <I>offset</I> is taken relative to one greater than the maximum
index of the specified array.
Substring expansion applied to an associative array produces undefined
results.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the :- expansion.
Substring indexing is zero-based unless the positional parameters
@@ -3331,6 +3381,45 @@ or
the substitution operation is applied to each member of the
array in turn, and the expansion is the resultant list.
<DT>${<I>parameter</I><B>^</B><I>pattern</I>}<DD>
<DT>${<I>parameter</I><B>^^</B><I>pattern</I>}<DD>
<DT>${<I>parameter</I><B>,</B><I>pattern</I>}<DD>
<DT>${<I>parameter</I><B>,,</B><I>pattern</I>}<DD>
This expansion modifies the case of alphabetic characters in <I>parameter</I>.
The <I>pattern</I> is expanded to produce a pattern just as in
pathname expansion.
The <B>^</B> operator converts lowercase letters matching <I>pattern</I>
to uppercase; the <B>,</B> operator converts matching uppercase letters
to lowercase.
The <B>^^</B> and <B>,,</B> expansions convert each matched character in the
expanded value; the <B>^</B> and <B>,</B> expansions match and convert only
the first character.
If <I>pattern</I> is omitted, it is treated like a <B>?</B>, which matches
every character.
If
<I>parameter</I>
is
<B>@</B>
or
<B>*</B>,
the case modification operation is applied to each positional
parameter in turn, and the expansion is the resultant list.
If
<I>parameter</I>
is an array variable subscripted with
<B>@</B>
or
<B>*</B>,
the case modification operation is applied to each member of the
array in turn, and the expansion is the resultant list.
</DL>
<A NAME="lbBB">&nbsp;</A>
<H4>Command Substitution</H4>
@@ -5477,6 +5566,8 @@ The
may be referenced using
<B>%-</B>.
If there is only a single job, <B>%+</B> and <B>%-</B> can both be used
to refer to that job.
In output pertaining to jobs (e.g., the output of the
<B>jobs</B>
@@ -5645,6 +5736,7 @@ the release of <B>bash</B>, version + patch level (e.g., 2.00.0)
<DD>
the current working directory, with <B>$HOME</B> abbreviated with a tilde
(uses the <B>$PROMPT_DIRTRIM</B> variable)
<DT><B>\W</B>
<DD>
@@ -8525,9 +8617,9 @@ must be >= 1. If
is greater than the number of enclosing loops, the last enclosing loop
(the ``top-level'' loop) is resumed.
The return value is 0 unless <I>n</I> is not greater than or equal to 1.
<DT><B>declare</B> [<B>-afFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
<DT><B>declare</B> [<B>-aAfFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
<DT><B>typeset</B> [<B>-afFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
<DT><B>typeset</B> [<B>-aAfFirtx</B>] [<B>-p</B>] [<I>name</I>[=<I>value</I>] ...]<DD>
Declare variables and/or give them attributes.
If no <I>name</I>s are given then display the values of variables.
@@ -8572,7 +8664,14 @@ to give variables attributes:
<DT><B>-a</B>
<DD>
Each <I>name</I> is an array variable (see
Each <I>name</I> is an indexed array variable (see
<B>Arrays</B>
above).
<DT><B>-A</B>
<DD>
Each <I>name</I> is an associative array variable (see
<B>Arrays</B>
above).
@@ -9588,8 +9687,7 @@ is supplied, or
<DD>
Exit a login shell.
<DT><B>mapfile</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>cou<DD>
nt</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> Iquantum] [<I>array</I>]
<DT><B>mapfile</B> [<B>-n</B> <I>count</I>] [<B>-O</B> <I>origin</I>] [<B>-s</B> <I>count</I>] [<B>-t</B>] [<B>-u</B> <I>fd</I>] [<B>-C</B> <I>callback</I>] [<B>-c</B> <I>quantum</I>] [<I>array</I>]<DD>
Read lines from the standard input into array variable
<I>array</I>,
@@ -9834,7 +9932,7 @@ 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.
<DT><B>read</B> [<B>-ers</B>] [<B>-a</B> <I>aname</I>] [<B>-d</B> <I>delim</I>] [- <I>text</I>] [<B>-n</B> <I>nchars</I>] [<B>-p</B> <I>prompt</I>] [<B>-t</B> <I>timeout</I>] [<B>-u</B> <I>fd</I>] [<I>name</I> ...]<DD>
<DT><B>read</B> [<B>-ers</B>] [<B>-a</B> <I>aname</I>] [<B>-d</B> <I>delim</I>] [<B>-</B> <I>text</I>] [<B>-n</B> <I>nchars</I>] [<B>-p</B> <I>prompt</I>] [<B>-t</B> <I>timeout</I>] [<B>-u</B> <I>fd</I>] [<I>name</I> ...]<DD>
One line is read from the standard input, or from the file descriptor
<I>fd</I> supplied as an argument to the <B>-u</B> option, and the first word
is assigned to the first
@@ -9927,8 +10025,10 @@ Cause <B>read</B> to time out and return failure if a complete line of
input is not read within <I>timeout</I> seconds.
<I>timeout</I> may be a decimal number with a fractional portion following
the decimal point.
This option has no effect if <B>read</B> is not reading input from the
terminal or a pipe.
This option is only effective if <B>read</B> is reading input from a
terminal, pipe, or other special file; it has no effect when reading
from regular files.
The exit status is greater than 128 if the timeout is exceeded.
<DT><B>-u </B><I>fd</I>
<DD>
@@ -9949,7 +10049,7 @@ times out, or an invalid file descriptor is supplied as the argument to
<B>-u</B>.
</DL>
<DT><B>readonly</B> [<B>-apf</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
<DT><B>readonly</B> [<B>-aApf</B>] [<I>name</I>[=<I>word</I>] ...]<DD>
The given
<I>names</I> are marked readonly; the values of these
@@ -9965,7 +10065,10 @@ marked.
The
<B>-a</B>
option restricts the variables to arrays.
option restricts the variables to indexed arrays; the
<B>-A</B>
option restricts the variables to associative arrays.
If no
<I>name</I>
@@ -10925,12 +11028,11 @@ Suspend the execution of this shell until it receives a
<FONT SIZE=-1><B>SIGCONT</B>
</FONT>
signal. The
signal. A login shell cannot be suspended; the
<B>-f</B>
option says not to complain if this is
a login shell; just suspend anyway. The return status is 0 unless
the shell is a login shell and
option can be used to override this and force the suspension.
The return status is 0 unless the shell is a login shell and
<B>-f</B>
is not supplied, or if job control is not enabled.
@@ -11823,7 +11925,7 @@ Array variables may not (yet) be exported.
<HR>
<TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>GNU Bash-4.0<TH ALIGN=CENTER width=33%>2008 May 25<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>GNU Bash-4.0<TH ALIGN=CENTER width=33%>2008 June 29<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<HR>
@@ -11928,6 +12030,6 @@ Array variables may not (yet) be exported.
</DL>
<HR>
This document was created by man2html from bash.1.<BR>
Time: 29 May 2008 11:48:48 EDT
Time: 02 July 2008 09:08:29 EDT
</BODY>
</HTML>
BIN
View File
Binary file not shown.
+5945 -5848
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -92,16 +92,16 @@
@xrdef{Command Substitution-pg}{22}
@xrdef{Command Substitution-snt}{Section@tie 3.5.4}
@xrdef{Arithmetic Expansion-title}{Arithmetic Expansion}
@xrdef{Arithmetic Expansion-pg}{22}
@xrdef{Arithmetic Expansion-pg}{23}
@xrdef{Arithmetic Expansion-snt}{Section@tie 3.5.5}
@xrdef{Process Substitution-title}{Process Substitution}
@xrdef{Process Substitution-pg}{22}
@xrdef{Process Substitution-pg}{23}
@xrdef{Process Substitution-snt}{Section@tie 3.5.6}
@xrdef{Word Splitting-title}{Word Splitting}
@xrdef{Word Splitting-pg}{23}
@xrdef{Word Splitting-snt}{Section@tie 3.5.7}
@xrdef{Filename Expansion-title}{Filename Expansion}
@xrdef{Filename Expansion-pg}{23}
@xrdef{Filename Expansion-pg}{24}
@xrdef{Filename Expansion-snt}{Section@tie 3.5.8}
@xrdef{Pattern Matching-title}{Pattern Matching}
@xrdef{Pattern Matching-pg}{24}
@@ -110,7 +110,7 @@
@xrdef{Quote Removal-pg}{25}
@xrdef{Quote Removal-snt}{Section@tie 3.5.9}
@xrdef{Redirections-title}{Redirections}
@xrdef{Redirections-pg}{25}
@xrdef{Redirections-pg}{26}
@xrdef{Redirections-snt}{Section@tie 3.6}
@xrdef{Executing Commands-title}{Executing Commands}
@xrdef{Executing Commands-pg}{29}
@@ -122,16 +122,16 @@
@xrdef{Command Search and Execution-pg}{30}
@xrdef{Command Search and Execution-snt}{Section@tie 3.7.2}
@xrdef{Command Execution Environment-title}{Command Execution Environment}
@xrdef{Command Execution Environment-pg}{30}
@xrdef{Command Execution Environment-pg}{31}
@xrdef{Command Execution Environment-snt}{Section@tie 3.7.3}
@xrdef{Environment-title}{Environment}
@xrdef{Environment-pg}{31}
@xrdef{Environment-pg}{32}
@xrdef{Environment-snt}{Section@tie 3.7.4}
@xrdef{Exit Status-title}{Exit Status}
@xrdef{Exit Status-pg}{32}
@xrdef{Exit Status-snt}{Section@tie 3.7.5}
@xrdef{Signals-title}{Signals}
@xrdef{Signals-pg}{32}
@xrdef{Signals-pg}{33}
@xrdef{Signals-snt}{Section@tie 3.7.6}
@xrdef{Shell Scripts-title}{Shell Scripts}
@xrdef{Shell Scripts-pg}{33}
@@ -203,7 +203,7 @@
@xrdef{The Directory Stack-pg}{79}
@xrdef{The Directory Stack-snt}{Section@tie 6.8}
@xrdef{Directory Stack Builtins-title}{Directory Stack Builtins}
@xrdef{Directory Stack Builtins-pg}{79}
@xrdef{Directory Stack Builtins-pg}{80}
@xrdef{Directory Stack Builtins-snt}{Section@tie 6.8.1}
@xrdef{Printing a Prompt-title}{Controlling the Prompt}
@xrdef{Printing a Prompt-pg}{81}
@@ -212,7 +212,7 @@
@xrdef{The Restricted Shell-pg}{82}
@xrdef{The Restricted Shell-snt}{Section@tie 6.10}
@xrdef{Bash POSIX Mode-title}{Bash POSIX Mode}
@xrdef{Bash POSIX Mode-pg}{82}
@xrdef{Bash POSIX Mode-pg}{83}
@xrdef{Bash POSIX Mode-snt}{Section@tie 6.11}
@xrdef{Job Control-title}{Job Control}
@xrdef{Job Control-pg}{87}
+3 -3
View File
@@ -17,7 +17,7 @@
\entry{[}{39}{\code {[}}
\entry{times}{40}{\code {times}}
\entry{trap}{40}{\code {trap}}
\entry{umask}{40}{\code {umask}}
\entry{umask}{41}{\code {umask}}
\entry{unset}{41}{\code {unset}}
\entry{alias}{41}{\code {alias}}
\entry{bind}{41}{\code {bind}}
@@ -32,7 +32,7 @@
\entry{local}{46}{\code {local}}
\entry{logout}{46}{\code {logout}}
\entry{mapfile}{46}{\code {mapfile}}
\entry{printf}{46}{\code {printf}}
\entry{printf}{47}{\code {printf}}
\entry{read}{47}{\code {read}}
\entry{source}{48}{\code {source}}
\entry{type}{48}{\code {type}}
@@ -41,7 +41,7 @@
\entry{unalias}{50}{\code {unalias}}
\entry{set}{50}{\code {set}}
\entry{shopt}{54}{\code {shopt}}
\entry{dirs}{79}{\code {dirs}}
\entry{dirs}{80}{\code {dirs}}
\entry{popd}{80}{\code {popd}}
\entry{pushd}{80}{\code {pushd}}
\entry{bg}{88}{\code {bg}}
+3 -3
View File
@@ -21,7 +21,7 @@
\entry {\code {continue}}{36}
\initial {D}
\entry {\code {declare}}{43}
\entry {\code {dirs}}{79}
\entry {\code {dirs}}{80}
\entry {\code {disown}}{89}
\initial {E}
\entry {\code {echo}}{44}
@@ -51,7 +51,7 @@
\entry {\code {mapfile}}{46}
\initial {P}
\entry {\code {popd}}{80}
\entry {\code {printf}}{46}
\entry {\code {printf}}{47}
\entry {\code {pushd}}{80}
\entry {\code {pwd}}{38}
\initial {R}
@@ -72,7 +72,7 @@
\entry {\code {typeset}}{49}
\initial {U}
\entry {\code {ulimit}}{49}
\entry {\code {umask}}{40}
\entry {\code {umask}}{41}
\entry {\code {unalias}}{50}
\entry {\code {unset}}{41}
\initial {W}
+12 -12
View File
@@ -51,24 +51,24 @@
\entry{parameter expansion}{19}{parameter expansion}
\entry{expansion, parameter}{19}{expansion, parameter}
\entry{command substitution}{22}{command substitution}
\entry{expansion, arithmetic}{22}{expansion, arithmetic}
\entry{arithmetic expansion}{22}{arithmetic expansion}
\entry{process substitution}{22}{process substitution}
\entry{expansion, arithmetic}{23}{expansion, arithmetic}
\entry{arithmetic expansion}{23}{arithmetic expansion}
\entry{process substitution}{23}{process substitution}
\entry{word splitting}{23}{word splitting}
\entry{expansion, filename}{23}{expansion, filename}
\entry{expansion, pathname}{23}{expansion, pathname}
\entry{filename expansion}{23}{filename expansion}
\entry{pathname expansion}{23}{pathname expansion}
\entry{expansion, filename}{24}{expansion, filename}
\entry{expansion, pathname}{24}{expansion, pathname}
\entry{filename expansion}{24}{filename expansion}
\entry{pathname expansion}{24}{pathname expansion}
\entry{pattern matching}{24}{pattern matching}
\entry{matching, pattern}{24}{matching, pattern}
\entry{redirection}{25}{redirection}
\entry{redirection}{26}{redirection}
\entry{command expansion}{29}{command expansion}
\entry{command execution}{30}{command execution}
\entry{command search}{30}{command search}
\entry{execution environment}{30}{execution environment}
\entry{environment}{31}{environment}
\entry{execution environment}{31}{execution environment}
\entry{environment}{32}{environment}
\entry{exit status}{32}{exit status}
\entry{signal handling}{32}{signal handling}
\entry{signal handling}{33}{signal handling}
\entry{shell script}{33}{shell script}
\entry{special builtin}{58}{special builtin}
\entry{login shell}{71}{login shell}
@@ -87,7 +87,7 @@
\entry{directory stack}{79}{directory stack}
\entry{prompting}{81}{prompting}
\entry{restricted shell}{82}{restricted shell}
\entry{POSIX Mode}{82}{POSIX Mode}
\entry{POSIX Mode}{83}{POSIX Mode}
\entry{job control}{87}{job control}
\entry{foreground}{87}{foreground}
\entry{background}{87}{background}
+12 -12
View File
@@ -1,7 +1,7 @@
\initial {A}
\entry {alias expansion}{77}
\entry {arithmetic evaluation}{76}
\entry {arithmetic expansion}{22}
\entry {arithmetic expansion}{23}
\entry {arithmetic, shell}{76}
\entry {arrays}{78}
\initial {B}
@@ -35,24 +35,24 @@
\entry {directory stack}{79}
\initial {E}
\entry {editing command lines}{91}
\entry {environment}{31}
\entry {environment}{32}
\entry {evaluation, arithmetic}{76}
\entry {event designators}{122}
\entry {execution environment}{30}
\entry {execution environment}{31}
\entry {exit status}{3, 32}
\entry {expansion}{17}
\entry {expansion, arithmetic}{22}
\entry {expansion, arithmetic}{23}
\entry {expansion, brace}{18}
\entry {expansion, filename}{23}
\entry {expansion, filename}{24}
\entry {expansion, parameter}{19}
\entry {expansion, pathname}{23}
\entry {expansion, pathname}{24}
\entry {expansion, tilde}{18}
\entry {expressions, arithmetic}{76}
\entry {expressions, conditional}{75}
\initial {F}
\entry {field}{3}
\entry {filename}{3}
\entry {filename expansion}{23}
\entry {filename expansion}{24}
\entry {foreground}{87}
\entry {functions, shell}{14}
\initial {H}
@@ -91,14 +91,14 @@
\entry {parameters}{15}
\entry {parameters, positional}{16}
\entry {parameters, special}{16}
\entry {pathname expansion}{23}
\entry {pathname expansion}{24}
\entry {pattern matching}{24}
\entry {pipeline}{8}
\entry {POSIX}{3}
\entry {POSIX Mode}{82}
\entry {POSIX Mode}{83}
\entry {process group}{3}
\entry {process group ID}{3}
\entry {process substitution}{22}
\entry {process substitution}{23}
\entry {programmable completion}{112}
\entry {prompting}{81}
\initial {Q}
@@ -106,7 +106,7 @@
\entry {quoting, ANSI}{6}
\initial {R}
\entry {Readline, how to use}{90}
\entry {redirection}{25}
\entry {redirection}{26}
\entry {reserved word}{3}
\entry {restricted shell}{82}
\entry {return status}{3}
@@ -117,7 +117,7 @@
\entry {shell variable}{15}
\entry {shell, interactive}{73}
\entry {signal}{4}
\entry {signal handling}{32}
\entry {signal handling}{33}
\entry {special builtin}{4, 58}
\entry {startup files}{71}
\entry {suspending jobs}{87}
BIN
View File
Binary file not shown.
+915 -806
View File
File diff suppressed because it is too large Load Diff
+354 -275
View File
@@ -1,10 +1,10 @@
This is bashref.info, produced by makeinfo version 4.11 from
/Users/chet/src/bash/src/doc/bashref.texi.
/usr/homes/chet/src/bash/src/doc/bashref.texi.
This text is a brief description of the features that are present in
the Bash shell (version 4.0, 25 May 2008).
the Bash shell (version 4.0, 29 June 2008).
This is Edition 4.0, last updated 25 May 2008, of `The GNU Bash
This is Edition 4.0, last updated 29 June 2008, of `The GNU Bash
Reference Manual', for `Bash', Version 4.0.
Copyright (C) 1988-2007 Free Software Foundation, Inc.
@@ -38,9 +38,9 @@ Bash Features
*************
This text is a brief description of the features that are present in
the Bash shell (version 4.0, 25 May 2008).
the Bash shell (version 4.0, 29 June 2008).
This is Edition 4.0, last updated 25 May 2008, of `The GNU Bash
This is Edition 4.0, last updated 29 June 2008, of `The GNU Bash
Reference Manual', for `Bash', Version 4.0.
Bash contains features that appear in other popular shells, and some
@@ -1064,8 +1064,10 @@ variable's current value, which is also evaluated. When `+=' is
applied to an array variable using compound assignment (*note
Arrays::), the variable's value is not unset (as it is when using `='),
and new values are appended to the array beginning at one greater than
the array's maximum index. When applied to a string-valued variable,
VALUE is expanded and appended to the variable's value.
the array's maximum index (for indexed arrays), or added as additional
key-value pairs in an associative array. When applied to a
string-valued variable, VALUE is expanded and appended to the
variable's value.

File: bashref.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters
@@ -1404,12 +1406,15 @@ if the colon is omitted, the operator tests only for existence.
If OFFSET evaluates to a number less than zero, the value is used
as an offset from the end of the value of PARAMETER. If PARAMETER
is `@', the result is LENGTH positional parameters beginning at
OFFSET. If PARAMETER is an array name indexed by `@' or `*', the
result is the LENGTH members of the array beginning with
`${PARAMETER[OFFSET]}'. A negative OFFSET is taken relative to
one greater than the maximum index of the specified array. Note
that a negative offset must be separated from the colon by at least
one space to avoid being confused with the `:-' expansion.
OFFSET. If PARAMETER is an indexed array name subscripted by `@'
or `*', the result is the LENGTH members of the array beginning
with `${PARAMETER[OFFSET]}'. A negative OFFSET is taken relative
to one greater than the maximum index of the specified array.
Substring expansion applied to an associative array produces
undefined results.
Note that a negative offset must be separated from the colon by at
least one space to avoid being confused with the `:-' expansion.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1 by default. If
OFFSET is 0, and the positional parameters are used, `$@' is
@@ -1482,6 +1487,25 @@ if the colon is omitted, the operator tests only for existence.
member of the array in turn, and the expansion is the resultant
list.
`${PARAMETER^PATTERN}'
`${PARAMETER^^PATTERN}'
`${PARAMETER,PATTERN}'
`${PARAMETER,,PATTERN}'
This expansion modifies the case of alphabetic characters in
PARAMETER. The PATTERN is expanded to produce a pattern just as in
pathname expansion. The `^' operator converts lowercase letters
matching PATTERN to uppercase; the `,' operator converts matching
uppercase letters to lowercase. The `^^' and `,,' expansions
convert each matched character in the expanded value; the `^' and
`,' expansions match and convert only the first character. If
PATTERN is omitted, it is treated like a `?', which matches every
character. If PARAMETER is `@' or `*', the case modification
operation is applied to each positional parameter in turn, and the
expansion is the resultant list. If PARAMETER is an array
variable subscripted with `@' or `*', the case modification
operation is applied to each member of the array in turn, and the
expansion is the resultant list.

File: bashref.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions
@@ -2506,19 +2530,20 @@ standard.
current directory or an invalid option is supplied.
`readonly'
readonly [-apf] [NAME[=VALUE]] ...
readonly [-aApf] [NAME[=VALUE]] ...
Mark each NAME as readonly. The values of these names may not be
changed by subsequent assignment. If the `-f' option is supplied,
each NAME refers to a shell function. The `-a' option means each
NAME refers to an array variable. If no NAME arguments are given,
or if the `-p' option is supplied, a list of all readonly names is
printed. The `-p' option causes output to be displayed in a
format that may be reused as input. If a variable name is
followed by =VALUE, the value of the variable is set to VALUE.
The return status is zero unless an invalid option is supplied,
one of the NAME arguments is not a valid shell variable or
function name, or the `-f' option is supplied with a name that is
not a shell function.
NAME refers to an indexed array variable; the `-A' option means
each NAME refers to an associative array variable. If no NAME
arguments are given, or if the `-p' option is supplied, a list of
all readonly names is printed. The `-p' option causes output to
be displayed in a format that may be reused as input. If a
variable name is followed by =VALUE, the value of the variable is
set to VALUE. The return status is zero unless an invalid option
is supplied, one of the NAME arguments is not a valid shell
variable or function name, or the `-f' option is supplied with a
name that is not a shell function.
`return'
return [N]
@@ -2827,7 +2852,7 @@ POSIX standard.
non-zero if not.
`declare'
declare [-afFirtx] [-p] [NAME[=VALUE] ...]
declare [-aAfFirtx] [-p] [NAME[=VALUE] ...]
Declare variables and give them attributes. If no NAMEs are
given, then display the values of variables instead.
@@ -2852,7 +2877,10 @@ POSIX standard.
attributes or to give variables attributes:
`-a'
Each NAME is an array variable (*note Arrays::).
Each NAME is an indexed array variable (*note Arrays::).
`-A'
Each NAME is an associative array variable (*note Arrays::).
`-f'
Use function names only.
@@ -3138,8 +3166,10 @@ POSIX standard.
Cause `read' to time out and return failure if a complete
line of input is not read within TIMEOUT seconds. TIMEOUT
may be a decimal number with a fractional portion following
the decimal point. This option has no effect if `read' is
not reading input from the terminal or a pipe.
the decimal point. This option is only effective if `read'
is reading input from a terminal, pipe, or other special
file; it has no effect when reading from regular files. The
exit status is greater than 128 if the timeout is exceeded.
`-u FD'
Read input from file descriptor FD.
@@ -3937,6 +3967,13 @@ Variables::).
differs from `$$' under certain circumstances, such as subshells
that do not require Bash to be re-initialized.
`BASH_ALIASES'
An associative array variable whose members correspond to the
internal list of aliases as maintained by the `alias' builtin
(*note Bourne Shell Builtins::). Elements added to this array
appear in the alias list; unsetting array elements cause aliases
to be removed from the alias list.
`BASH_ARGC'
An array variable whose values are the number of parameters in each
frame of the current bash execution call stack. The number of
@@ -3957,6 +3994,13 @@ Variables::).
The Shopt Builtin:: for a description of the `extdebug' option to
the `shopt' builtin).
`BASH_CMDS'
An associative array variable whose members correspond to the
internal hash table of commands as maintained by the `hash' builtin
(*note Bourne Shell Builtins::). Elements added to this array
appear in the hash table; unsetting array elements cause commands
to be removed from the hash table.
`BASH_COMMAND'
The command currently being executed or about to be executed,
unless the shell is executing a command as the result of a trap,
@@ -4321,6 +4365,12 @@ Variables::).
If set, the value is interpreted as a command to execute before
the printing of each primary prompt (`$PS1').
`PROMPT_DIRTRIM'
If set to a number greater than zero, the value is used as the
number of trailing directory components to retain when expanding
the `\w' and `\W' prompt string escapes (*note Printing a
Prompt::). Characters removed are replaced with an ellipsis.
`PS3'
The value of this variable is used as the prompt for the `select'
command. If this variable is not set, the `select' command
@@ -5125,14 +5175,16 @@ File: bashref.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases,
6.7 Arrays
==========
Bash provides one-dimensional array variables. Any variable may be
used as an array; the `declare' builtin will explicitly declare an
array. There is no maximum limit on the size of an array, nor any
requirement that members be indexed or assigned contiguously. Arrays
are zero-based.
Bash provides one-dimensional indexed and associative array variables.
Any variable may be used as an indexed array; the `declare' builtin
will explicitly declare an array. There is no maximum limit on the
size of an array, nor any requirement that members be indexed or
assigned contiguously. Indexed arrays are referenced using integers
(including arithmetic expressions (*note Shell Arithmetic::) and are
zero-based; associative arrays use arbitrary strings.
An array is created automatically if any variable is assigned to
using the syntax
An indexed array is created automatically if any variable is
assigned to using the syntax
name[SUBSCRIPT]=VALUE
The SUBSCRIPT is treated as an arithmetic expression that must evaluate
@@ -5141,18 +5193,28 @@ array, use
declare -a NAME
The syntax
declare -a NAME[SUBSCRIPT]
is also accepted; the SUBSCRIPT is ignored. Attributes may be
specified for an array variable using the `declare' and `readonly'
builtins. Each attribute applies to all members of an array.
is also accepted; the SUBSCRIPT is ignored.
Associative arrays are created using
declare -A NAME.
Attributes may be specified for an array variable using the
`declare' and `readonly' builtins. Each attribute applies to all
members of an array.
Arrays are assigned to using compound assignments of the form
name=(value1 ... valueN)
where each VALUE is of the form `[[SUBSCRIPT]=]'STRING. If the
optional subscript is supplied, that index is assigned to; otherwise
the index of the element assigned is the last index assigned to by the
statement plus one. Indexing starts at zero. This syntax is also
accepted by the `declare' builtin. Individual array elements may be
assigned to using the `name['SUBSCRIPT`]='VALUE syntax introduced above.
where each VALUE is of the form `[SUBSCRIPT]='STRING. Indexed array
assignments do not require the bracket and subscript. When assigning
to indexed arrays, if the optional subscript is supplied, that index is
assigned to; otherwise the index of the element assigned is the last
index assigned to by the statement plus one. Indexing starts at zero.
When assigning to an associative array, the subscript is required.
This syntax is also accepted by the `declare' builtin. Individual
array elements may be assigned to using the `name['SUBSCRIPT`]='VALUE
syntax introduced above.
Any element of an array may be referenced using
`${name['SUBSCRIPT`]}'. The braces are required to avoid conflicts
@@ -5171,7 +5233,7 @@ expansion of the special parameters `@' and `*'.
`${#name['SUBSCRIPT`]}' expands to the length of `${name['SUBSCRIPT`]}'.
If SUBSCRIPT is `@' or `*', the expansion is the number of elements in
the array. Referencing an array variable without a subscript is
equivalent to referencing element zero.
equivalent to referencing with a subscript of 0.
The `unset' builtin is used to destroy arrays. `unset'
NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT. Care
@@ -5180,11 +5242,12 @@ generation. `unset' NAME, where NAME is an array, removes the entire
array. A subscript of `*' or `@' also removes the entire array.
The `declare', `local', and `readonly' builtins each accept a `-a'
option to specify an array. The `read' builtin accepts a `-a' option
to assign a list of words read from the standard input to an array, and
can read values from the standard input into individual array elements.
The `set' and `declare' builtins display array values in a way that
allows them to be reused as input.
option to specify an indexed array and a `-A' option to specify an
associative array. The `read' builtin accepts a `-a' option to assign
a list of words read from the standard input to an array, and can read
values from the standard input into individual array elements. The
`set' and `declare' builtins display array values in a way that allows
them to be reused as input.

File: bashref.info, Node: The Directory Stack, Next: Printing a Prompt, Prev: Arrays, Up: Bash Features
@@ -5364,7 +5427,7 @@ which can appear in the prompt variables:
`\w'
The current working directory, with `$HOME' abbreviated with a
tilde.
tilde (uses the `$PROMPT_DIRTRIM' variable).
`\W'
The basename of `$PWD', with `$HOME' abbreviated with a tilde.
@@ -5619,6 +5682,9 @@ startup files.
interpret any arguments to `echo' as options. Each argument is
displayed, after escape characters are converted.
42. The `ulimit' builtin uses a block size of 512 bytes for the `-c'
and `-f' options.
There is other POSIX behavior that Bash does not implement by
default even when in POSIX mode. Specifically:
@@ -5705,10 +5771,11 @@ character `%' introduces a job name.
`%+' refer to the shell's notion of the current job, which is the last
job stopped while it was in the foreground or started in the background.
A single `%' (with no accompanying job specification) also refers to
the current job. The previous job may be referenced using `%-'. In
output pertaining to jobs (e.g., the output of the `jobs' command), the
current job is always flagged with a `+', and the previous job with a
`-'.
the current job. The previous job may be referenced using `%-'. If
there is only a single job, `%+' and `%-' can both be used to refer to
that job. In output pertaining to jobs (e.g., the output of the `jobs'
command), the current job is always flagged with a `+', and the
previous job with a `-'.
A job may also be referred to using a prefix of the name used to
start it, or using a substring that appears in its command line. For
@@ -5833,8 +5900,8 @@ File: bashref.info, Node: Job Control Builtins, Next: Job Control Variables,
`suspend'
suspend [-f]
Suspend the execution of this shell until it receives a `SIGCONT'
signal. The `-f' option means to suspend even if the shell is a
login shell.
signal. A login shell cannot be suspended; the `-f' option can be
used to override this and force the suspension.
When job control is not active, the `kill' and `wait' builtins do
@@ -8270,6 +8337,15 @@ does not provide the necessary support.
Include `csh'-like brace expansion ( `b{a,b}c' ==> `bac bbc' ).
See *note Brace Expansion::, for a complete description.
`--enable-casemod-attributes'
Include support for case-modifying attributes in the `declare'
builtin and assignment statements. Variables with the UPPERCASE
attribute, for example, will have their values converted to
uppercase upon assignment.
`--enable-casemod-expansion'
Include support for case-modifying word expansions.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
displaying timing statistics for the pipeline following `time'
@@ -9246,7 +9322,7 @@ D.1 Index of Shell Builtin Commands
* :: Bourne Shell Builtins.
(line 11)
* [: Bourne Shell Builtins.
(line 212)
(line 213)
* alias: Bash Builtins. (line 11)
* bg: Job Control Builtins.
(line 7)
@@ -9271,8 +9347,8 @@ D.1 Index of Shell Builtin Commands
(line 7)
* disown: Job Control Builtins.
(line 83)
* echo: Bash Builtins. (line 208)
* enable: Bash Builtins. (line 260)
* echo: Bash Builtins. (line 211)
* enable: Bash Builtins. (line 263)
* eval: Bourne Shell Builtins.
(line 63)
* exec: Bourne Shell Builtins.
@@ -9289,50 +9365,50 @@ D.1 Index of Shell Builtin Commands
(line 103)
* hash: Bourne Shell Builtins.
(line 145)
* help: Bash Builtins. (line 288)
* help: Bash Builtins. (line 291)
* history: Bash History Builtins.
(line 39)
* jobs: Job Control Builtins.
(line 25)
* kill: Job Control Builtins.
(line 57)
* let: Bash Builtins. (line 308)
* local: Bash Builtins. (line 315)
* logout: Bash Builtins. (line 325)
* mapfile: Bash Builtins. (line 329)
* let: Bash Builtins. (line 311)
* local: Bash Builtins. (line 318)
* logout: Bash Builtins. (line 328)
* mapfile: Bash Builtins. (line 332)
* popd: Directory Stack Builtins.
(line 37)
* printf: Bash Builtins. (line 370)
* printf: Bash Builtins. (line 373)
* pushd: Directory Stack Builtins.
(line 58)
* pwd: Bourne Shell Builtins.
(line 163)
* read: Bash Builtins. (line 395)
* read: Bash Builtins. (line 398)
* readonly: Bourne Shell Builtins.
(line 172)
* return: Bourne Shell Builtins.
(line 187)
(line 188)
* set: The Set Builtin. (line 11)
* shift: Bourne Shell Builtins.
(line 200)
(line 201)
* shopt: The Shopt Builtin. (line 9)
* source: Bash Builtins. (line 461)
* source: Bash Builtins. (line 466)
* suspend: Job Control Builtins.
(line 94)
* test: Bourne Shell Builtins.
(line 212)
(line 213)
* times: Bourne Shell Builtins.
(line 280)
(line 281)
* trap: Bourne Shell Builtins.
(line 285)
* type: Bash Builtins. (line 465)
* typeset: Bash Builtins. (line 496)
* ulimit: Bash Builtins. (line 502)
(line 286)
* type: Bash Builtins. (line 470)
* typeset: Bash Builtins. (line 501)
* ulimit: Bash Builtins. (line 507)
* umask: Bourne Shell Builtins.
(line 326)
* unalias: Bash Builtins. (line 588)
(line 327)
* unalias: Bash Builtins. (line 593)
* unset: Bourne Shell Builtins.
(line 343)
(line 344)
* wait: Job Control Builtins.
(line 73)
@@ -9399,17 +9475,19 @@ D.3 Parameter and Variable Index
* auto_resume: Job Control Variables.
(line 6)
* BASH: Bash Variables. (line 13)
* BASH_ARGC: Bash Variables. (line 21)
* BASH_ARGV: Bash Variables. (line 31)
* BASH_COMMAND: Bash Variables. (line 41)
* BASH_ENV: Bash Variables. (line 46)
* BASH_EXECUTION_STRING: Bash Variables. (line 52)
* BASH_LINENO: Bash Variables. (line 55)
* BASH_REMATCH: Bash Variables. (line 64)
* BASH_SOURCE: Bash Variables. (line 72)
* BASH_SUBSHELL: Bash Variables. (line 76)
* BASH_VERSINFO: Bash Variables. (line 80)
* BASH_VERSION: Bash Variables. (line 104)
* BASH_ALIASES: Bash Variables. (line 21)
* BASH_ARGC: Bash Variables. (line 28)
* BASH_ARGV: Bash Variables. (line 38)
* BASH_CMDS: Bash Variables. (line 48)
* BASH_COMMAND: Bash Variables. (line 55)
* BASH_ENV: Bash Variables. (line 60)
* BASH_EXECUTION_STRING: Bash Variables. (line 66)
* BASH_LINENO: Bash Variables. (line 69)
* BASH_REMATCH: Bash Variables. (line 78)
* BASH_SOURCE: Bash Variables. (line 86)
* BASH_SUBSHELL: Bash Variables. (line 90)
* BASH_VERSINFO: Bash Variables. (line 94)
* BASH_VERSION: Bash Variables. (line 118)
* BASHPID: Bash Variables. (line 16)
* bell-style: Readline Init File Syntax.
(line 38)
@@ -9417,81 +9495,81 @@ D.3 Parameter and Variable Index
(line 45)
* CDPATH: Bourne Shell Variables.
(line 9)
* COLUMNS: Bash Variables. (line 107)
* COLUMNS: Bash Variables. (line 121)
* comment-begin: Readline Init File Syntax.
(line 50)
* COMP_CWORD: Bash Variables. (line 112)
* COMP_KEY: Bash Variables. (line 141)
* COMP_LINE: Bash Variables. (line 118)
* COMP_POINT: Bash Variables. (line 123)
* COMP_TYPE: Bash Variables. (line 131)
* COMP_WORDBREAKS: Bash Variables. (line 145)
* COMP_WORDS: Bash Variables. (line 151)
* COMP_CWORD: Bash Variables. (line 126)
* COMP_KEY: Bash Variables. (line 155)
* COMP_LINE: Bash Variables. (line 132)
* COMP_POINT: Bash Variables. (line 137)
* COMP_TYPE: Bash Variables. (line 145)
* COMP_WORDBREAKS: Bash Variables. (line 159)
* COMP_WORDS: Bash Variables. (line 165)
* completion-prefix-display-length: Readline Init File Syntax.
(line 60)
* completion-query-items: Readline Init File Syntax.
(line 67)
* COMPREPLY: Bash Variables. (line 158)
* COMPREPLY: Bash Variables. (line 172)
* convert-meta: Readline Init File Syntax.
(line 77)
* DIRSTACK: Bash Variables. (line 163)
* DIRSTACK: Bash Variables. (line 177)
* disable-completion: Readline Init File Syntax.
(line 83)
* editing-mode: Readline Init File Syntax.
(line 88)
* EMACS: Bash Variables. (line 173)
* EMACS: Bash Variables. (line 187)
* enable-keypad: Readline Init File Syntax.
(line 94)
* EUID: Bash Variables. (line 178)
* EUID: Bash Variables. (line 192)
* expand-tilde: Readline Init File Syntax.
(line 99)
* FCEDIT: Bash Variables. (line 182)
* FIGNORE: Bash Variables. (line 186)
* FUNCNAME: Bash Variables. (line 192)
* GLOBIGNORE: Bash Variables. (line 201)
* GROUPS: Bash Variables. (line 207)
* histchars: Bash Variables. (line 213)
* HISTCMD: Bash Variables. (line 228)
* HISTCONTROL: Bash Variables. (line 233)
* HISTFILE: Bash Variables. (line 249)
* HISTFILESIZE: Bash Variables. (line 253)
* HISTIGNORE: Bash Variables. (line 261)
* FCEDIT: Bash Variables. (line 196)
* FIGNORE: Bash Variables. (line 200)
* FUNCNAME: Bash Variables. (line 206)
* GLOBIGNORE: Bash Variables. (line 215)
* GROUPS: Bash Variables. (line 221)
* histchars: Bash Variables. (line 227)
* HISTCMD: Bash Variables. (line 242)
* HISTCONTROL: Bash Variables. (line 247)
* HISTFILE: Bash Variables. (line 263)
* HISTFILESIZE: Bash Variables. (line 267)
* HISTIGNORE: Bash Variables. (line 275)
* history-preserve-point: Readline Init File Syntax.
(line 103)
* history-size: Readline Init File Syntax.
(line 109)
* HISTSIZE: Bash Variables. (line 280)
* HISTTIMEFORMAT: Bash Variables. (line 284)
* HISTSIZE: Bash Variables. (line 294)
* HISTTIMEFORMAT: Bash Variables. (line 298)
* HOME: Bourne Shell Variables.
(line 13)
* horizontal-scroll-mode: Readline Init File Syntax.
(line 114)
* HOSTFILE: Bash Variables. (line 293)
* HOSTNAME: Bash Variables. (line 304)
* HOSTTYPE: Bash Variables. (line 307)
* HOSTFILE: Bash Variables. (line 307)
* HOSTNAME: Bash Variables. (line 318)
* HOSTTYPE: Bash Variables. (line 321)
* IFS: Bourne Shell Variables.
(line 18)
* IGNOREEOF: Bash Variables. (line 310)
* IGNOREEOF: Bash Variables. (line 324)
* input-meta: Readline Init File Syntax.
(line 121)
* INPUTRC: Bash Variables. (line 320)
* INPUTRC: Bash Variables. (line 334)
* isearch-terminators: Readline Init File Syntax.
(line 128)
* keymap: Readline Init File Syntax.
(line 135)
* LANG: Bash Variables. (line 324)
* LC_ALL: Bash Variables. (line 328)
* LC_COLLATE: Bash Variables. (line 332)
* LC_CTYPE: Bash Variables. (line 339)
* LANG: Bash Variables. (line 338)
* LC_ALL: Bash Variables. (line 342)
* LC_COLLATE: Bash Variables. (line 346)
* LC_CTYPE: Bash Variables. (line 353)
* LC_MESSAGES <1>: Locale Translation. (line 11)
* LC_MESSAGES: Bash Variables. (line 344)
* LC_NUMERIC: Bash Variables. (line 348)
* LINENO: Bash Variables. (line 352)
* LINES: Bash Variables. (line 356)
* MACHTYPE: Bash Variables. (line 361)
* LC_MESSAGES: Bash Variables. (line 358)
* LC_NUMERIC: Bash Variables. (line 362)
* LINENO: Bash Variables. (line 366)
* LINES: Bash Variables. (line 370)
* MACHTYPE: Bash Variables. (line 375)
* MAIL: Bourne Shell Variables.
(line 22)
* MAILCHECK: Bash Variables. (line 365)
* MAILCHECK: Bash Variables. (line 379)
* MAILPATH: Bourne Shell Variables.
(line 27)
* mark-modified-lines: Readline Init File Syntax.
@@ -9502,48 +9580,49 @@ D.3 Parameter and Variable Index
(line 158)
* meta-flag: Readline Init File Syntax.
(line 121)
* OLDPWD: Bash Variables. (line 373)
* OLDPWD: Bash Variables. (line 387)
* OPTARG: Bourne Shell Variables.
(line 34)
* OPTERR: Bash Variables. (line 376)
* OPTERR: Bash Variables. (line 390)
* OPTIND: Bourne Shell Variables.
(line 38)
* OSTYPE: Bash Variables. (line 380)
* OSTYPE: Bash Variables. (line 394)
* output-meta: Readline Init File Syntax.
(line 165)
* page-completions: Readline Init File Syntax.
(line 170)
* PATH: Bourne Shell Variables.
(line 42)
* PIPESTATUS: Bash Variables. (line 383)
* POSIXLY_CORRECT: Bash Variables. (line 388)
* PPID: Bash Variables. (line 397)
* PROMPT_COMMAND: Bash Variables. (line 401)
* PIPESTATUS: Bash Variables. (line 397)
* POSIXLY_CORRECT: Bash Variables. (line 402)
* PPID: Bash Variables. (line 411)
* PROMPT_COMMAND: Bash Variables. (line 415)
* PROMPT_DIRTRIM: Bash Variables. (line 419)
* PS1: Bourne Shell Variables.
(line 48)
* PS2: Bourne Shell Variables.
(line 53)
* PS3: Bash Variables. (line 405)
* PS4: Bash Variables. (line 410)
* PWD: Bash Variables. (line 416)
* RANDOM: Bash Variables. (line 419)
* REPLY: Bash Variables. (line 424)
* PS3: Bash Variables. (line 425)
* PS4: Bash Variables. (line 430)
* PWD: Bash Variables. (line 436)
* RANDOM: Bash Variables. (line 439)
* REPLY: Bash Variables. (line 444)
* revert-all-at-newline: Readline Init File Syntax.
(line 180)
* SECONDS: Bash Variables. (line 427)
* SHELL: Bash Variables. (line 433)
* SHELLOPTS: Bash Variables. (line 438)
* SHLVL: Bash Variables. (line 447)
* SECONDS: Bash Variables. (line 447)
* SHELL: Bash Variables. (line 453)
* SHELLOPTS: Bash Variables. (line 458)
* SHLVL: Bash Variables. (line 467)
* show-all-if-ambiguous: Readline Init File Syntax.
(line 186)
* show-all-if-unmodified: Readline Init File Syntax.
(line 192)
* TEXTDOMAIN: Locale Translation. (line 11)
* TEXTDOMAINDIR: Locale Translation. (line 11)
* TIMEFORMAT: Bash Variables. (line 452)
* TMOUT: Bash Variables. (line 490)
* TMPDIR: Bash Variables. (line 502)
* UID: Bash Variables. (line 506)
* TIMEFORMAT: Bash Variables. (line 472)
* TMOUT: Bash Variables. (line 510)
* TMPDIR: Bash Variables. (line 522)
* UID: Bash Variables. (line 526)
* visible-stats: Readline Init File Syntax.
(line 201)
@@ -9809,131 +9888,131 @@ D.5 Concept Index

Tag Table:
Node: Top1338
Node: Introduction3167
Node: What is Bash?3395
Node: What is a shell?4508
Node: Definitions7048
Node: Basic Shell Features9828
Node: Shell Syntax11047
Node: Shell Operation12077
Node: Quoting13371
Node: Escape Character14674
Node: Single Quotes15159
Node: Double Quotes15507
Node: ANSI-C Quoting16632
Node: Locale Translation17588
Node: Comments18484
Node: Shell Commands19102
Node: Simple Commands19868
Node: Pipelines20499
Node: Lists22755
Node: Compound Commands24484
Node: Looping Constructs25268
Node: Conditional Constructs27715
Node: Command Grouping35721
Node: Shell Functions37200
Node: Shell Parameters41661
Node: Positional Parameters43991
Node: Special Parameters44891
Node: Shell Expansions47855
Node: Brace Expansion49780
Node: Tilde Expansion52533
Node: Shell Parameter Expansion54884
Node: Command Substitution62584
Node: Arithmetic Expansion63917
Node: Process Substitution64767
Node: Word Splitting65817
Node: Filename Expansion67440
Node: Pattern Matching69580
Node: Quote Removal73219
Node: Redirections73514
Node: Executing Commands81657
Node: Simple Command Expansion82327
Node: Command Search and Execution84257
Node: Command Execution Environment86594
Node: Environment89393
Node: Exit Status91053
Node: Signals92674
Node: Shell Scripts94642
Node: Shell Builtin Commands97160
Node: Bourne Shell Builtins98837
Node: Bash Builtins116067
Node: Modifying Shell Behavior138853
Node: The Set Builtin139198
Node: The Shopt Builtin148046
Node: Special Builtins158908
Node: Shell Variables159887
Node: Bourne Shell Variables160327
Node: Bash Variables162308
Node: Bash Features183680
Node: Invoking Bash184563
Node: Bash Startup Files190372
Node: Interactive Shells195341
Node: What is an Interactive Shell?195751
Node: Is this Shell Interactive?196400
Node: Interactive Shell Behavior197215
Node: Bash Conditional Expressions200495
Node: Shell Arithmetic204074
Node: Aliases206820
Node: Arrays209392
Node: The Directory Stack212741
Node: Directory Stack Builtins213455
Node: Printing a Prompt216347
Node: The Restricted Shell219061
Node: Bash POSIX Mode220893
Node: Job Control228652
Node: Job Control Basics229112
Node: Job Control Builtins233621
Node: Job Control Variables237948
Node: Command Line Editing239106
Node: Introduction and Notation240101
Node: Readline Interaction241723
Node: Readline Bare Essentials242914
Node: Readline Movement Commands244703
Node: Readline Killing Commands245668
Node: Readline Arguments247588
Node: Searching248632
Node: Readline Init File250818
Node: Readline Init File Syntax251965
Node: Conditional Init Constructs265199
Node: Sample Init File267732
Node: Bindable Readline Commands270849
Node: Commands For Moving272056
Node: Commands For History272917
Node: Commands For Text276072
Node: Commands For Killing278745
Node: Numeric Arguments280887
Node: Commands For Completion282026
Node: Keyboard Macros285793
Node: Miscellaneous Commands286364
Node: Readline vi Mode291675
Node: Programmable Completion292589
Node: Programmable Completion Builtins298422
Node: Using History Interactively306805
Node: Bash History Facilities307489
Node: Bash History Builtins310403
Node: History Interaction314260
Node: Event Designators316965
Node: Word Designators317980
Node: Modifiers319619
Node: Installing Bash321023
Node: Basic Installation322160
Node: Compilers and Options324852
Node: Compiling For Multiple Architectures325593
Node: Installation Names327257
Node: Specifying the System Type328075
Node: Sharing Defaults328791
Node: Operation Controls329464
Node: Optional Features330422
Node: Reporting Bugs339353
Node: Major Differences From The Bourne Shell340547
Node: GNU Free Documentation License357234
Node: Indexes379695
Node: Builtin Index380149
Node: Reserved Word Index386903
Node: Variable Index389351
Node: Function Index400938
Node: Concept Index407670
Node: Top1344
Node: Introduction3175
Node: What is Bash?3403
Node: What is a shell?4516
Node: Definitions7056
Node: Basic Shell Features9836
Node: Shell Syntax11055
Node: Shell Operation12085
Node: Quoting13379
Node: Escape Character14682
Node: Single Quotes15167
Node: Double Quotes15515
Node: ANSI-C Quoting16640
Node: Locale Translation17596
Node: Comments18492
Node: Shell Commands19110
Node: Simple Commands19876
Node: Pipelines20507
Node: Lists22763
Node: Compound Commands24492
Node: Looping Constructs25276
Node: Conditional Constructs27723
Node: Command Grouping35729
Node: Shell Functions37208
Node: Shell Parameters41669
Node: Positional Parameters44085
Node: Special Parameters44985
Node: Shell Expansions47949
Node: Brace Expansion49874
Node: Tilde Expansion52627
Node: Shell Parameter Expansion54978
Node: Command Substitution63809
Node: Arithmetic Expansion65142
Node: Process Substitution65992
Node: Word Splitting67042
Node: Filename Expansion68665
Node: Pattern Matching70805
Node: Quote Removal74444
Node: Redirections74739
Node: Executing Commands82882
Node: Simple Command Expansion83552
Node: Command Search and Execution85482
Node: Command Execution Environment87819
Node: Environment90618
Node: Exit Status92278
Node: Signals93899
Node: Shell Scripts95867
Node: Shell Builtin Commands98385
Node: Bourne Shell Builtins100062
Node: Bash Builtins117380
Node: Modifying Shell Behavior140408
Node: The Set Builtin140753
Node: The Shopt Builtin149601
Node: Special Builtins160463
Node: Shell Variables161442
Node: Bourne Shell Variables161882
Node: Bash Variables163863
Node: Bash Features186181
Node: Invoking Bash187064
Node: Bash Startup Files192873
Node: Interactive Shells197842
Node: What is an Interactive Shell?198252
Node: Is this Shell Interactive?198901
Node: Interactive Shell Behavior199716
Node: Bash Conditional Expressions202996
Node: Shell Arithmetic206575
Node: Aliases209321
Node: Arrays211893
Node: The Directory Stack215735
Node: Directory Stack Builtins216449
Node: Printing a Prompt219341
Node: The Restricted Shell222093
Node: Bash POSIX Mode223925
Node: Job Control231778
Node: Job Control Basics232238
Node: Job Control Builtins236832
Node: Job Control Variables241196
Node: Command Line Editing242354
Node: Introduction and Notation243349
Node: Readline Interaction244971
Node: Readline Bare Essentials246162
Node: Readline Movement Commands247951
Node: Readline Killing Commands248916
Node: Readline Arguments250836
Node: Searching251880
Node: Readline Init File254066
Node: Readline Init File Syntax255213
Node: Conditional Init Constructs268447
Node: Sample Init File270980
Node: Bindable Readline Commands274097
Node: Commands For Moving275304
Node: Commands For History276165
Node: Commands For Text279320
Node: Commands For Killing281993
Node: Numeric Arguments284135
Node: Commands For Completion285274
Node: Keyboard Macros289041
Node: Miscellaneous Commands289612
Node: Readline vi Mode294923
Node: Programmable Completion295837
Node: Programmable Completion Builtins301670
Node: Using History Interactively310053
Node: Bash History Facilities310737
Node: Bash History Builtins313651
Node: History Interaction317508
Node: Event Designators320213
Node: Word Designators321228
Node: Modifiers322867
Node: Installing Bash324271
Node: Basic Installation325408
Node: Compilers and Options328100
Node: Compiling For Multiple Architectures328841
Node: Installation Names330505
Node: Specifying the System Type331323
Node: Sharing Defaults332039
Node: Operation Controls332712
Node: Optional Features333670
Node: Reporting Bugs342954
Node: Major Differences From The Bourne Shell344148
Node: GNU Free Documentation License360835
Node: Indexes383296
Node: Builtin Index383750
Node: Reserved Word Index390504
Node: Variable Index392952
Node: Function Index404758
Node: Concept Index411490

End Tag Table
+22 -22
View File
@@ -1,6 +1,6 @@
This is TeX, Version 3.141592 (Web2C 7.5.4) (format=tex 2008.4.8) 29 MAY 2008 11:48
**/Users/chet/src/bash/src/doc/bashref.texi
(/Users/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
This is TeX, Version 3.141592 (Web2C 7.5.4) (format=tex 2008.4.8) 2 JUL 2008 09:08
**/usr/homes/chet/src/bash/src/doc/bashref.texi
(/usr/homes/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
Loading texinfo [version 2003-02-03.16]: Basics,
\bindingoffset=\dimen16
\normaloffset=\dimen17
@@ -173,7 +173,7 @@ textttsl pat-tern@texttt ][]) @textttsl command-list @texttt ;;][] esac[][]
[11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]
[26] [27] [28] [29] [30] [31] [32] [33] Chapter 4 [34] [35] [36] [37] [38]
[39] [40] [41]
Underfull \hbox (badness 5231) in paragraph at lines 3194--3207
Underfull \hbox (badness 5231) in paragraph at lines 3223--3236
@texttt emacs-meta[]@textrm , @texttt emacs-ctlx[]@textrm , @texttt vi[]@textr
m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
@@ -186,7 +186,7 @@ m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
.etc.
[42] [43] [44] [45] [46]
Overfull \hbox (102.08961pt too wide) in paragraph at lines 3602--3602
Overfull \hbox (102.08961pt too wide) in paragraph at lines 3634--3634
[]@texttt read [-ers] [-a @textttsl aname@texttt ] [-d @textttsl de-lim@texttt
] [-i @textttsl text@texttt ] [-n @textttsl nchars@texttt ] [-p @textttsl prom
pt@texttt ] [-t @textttsl time-
@@ -199,8 +199,8 @@ pt@texttt ] [-t @textttsl time-
.@texttt a
.etc.
[47] [48] [49] [50] [51] [52] [53] [54]
Underfull \hbox (badness 2573) in paragraph at lines 4251--4255
[47] [48] [49] [50] [51] [52] [53] [54] [55]
Underfull \hbox (badness 2573) in paragraph at lines 4285--4289
[] []@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,9 +215,9 @@ Underfull \hbox (badness 2573) in paragraph at lines 4251--4255
.@textrm E
.etc.
[55] [56] [57] Chapter 5 [58] [59] [60] [61] [62] [63] [64] [65] [66]
Chapter 6 [67] [68]
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5074--5074
[56] [57] Chapter 5 [58] [59] [60] [61] [62] [63] [64] [65] [66] Chapter 6
[67] [68]
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5128--5128
[]@texttt bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@t
exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -230,7 +230,7 @@ exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5075--5075
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5129--5129
[]@texttt bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@texttt
] [-O @textttsl shopt_option@texttt ] -c @textttsl string @texttt [@textttsl ar
-
@@ -244,7 +244,7 @@ Overfull \hbox (76.23077pt too wide) in paragraph at lines 5075--5075
.etc.
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5076--5076
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5130--5130
[]@texttt bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@text
tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
@@ -257,7 +257,7 @@ tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
.etc.
[69] [70]
Underfull \hbox (badness 2245) in paragraph at lines 5250--5252
Underfull \hbox (badness 2245) in paragraph at lines 5304--5306
[]@textrm When a lo-gin shell ex-its, Bash reads and ex-e-cutes com-mands from
the file
@@ -270,7 +270,7 @@ the file
.etc.
[71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83] [84]
Underfull \hbox (badness 2521) in paragraph at lines 6366--6369
Underfull \hbox (badness 2521) in paragraph at lines 6441--6444
@textrm `@texttt --enable-strict-posix-default[]@textrm '[] to @texttt configur
e[] @textrm when build-ing (see Sec-tion 10.8
@@ -283,8 +283,8 @@ e[] @textrm when build-ing (see Sec-tion 10.8
.etc.
Chapter 7 [85] [86] [87] [88] [89]
(/Users/chet/src/bash/src/lib/readline/doc/rluser.texi Chapter 8 [90] [91]
[92] [93] [94] [95] [96]
(/usr/homes/chet/src/bash/src/lib/readline/doc/rluser.texi Chapter 8 [90]
[91] [92] [93] [94] [95] [96]
Underfull \hbox (badness 5231) in paragraph at lines 514--530
@texttt emacs-meta[]@textrm , @texttt emacs-ctlx[]@textrm , @texttt vi[]@textr
m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
@@ -323,10 +323,10 @@ Underfull \hbox (badness 2753) in paragraph at lines 1795--1798
.@texttt o
.etc.
[116]) (/Users/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[116]) (/usr/homes/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[117] [118] [119] [120] [121] [122]) Chapter 10 [123] [124] [125] [126]
[127]
Underfull \hbox (badness 2772) in paragraph at lines 6962--6966
Underfull \hbox (badness 2772) in paragraph at lines 7040--7044
[]@textrm Enable sup-port for large files (@texttt http://www.sas.com/standard
s/large_
@@ -345,11 +345,11 @@ s/large_
[155] [156] )
Here is how much of TeX's memory you used:
1732 strings out of 97980
23635 string characters out of 1221006
51884 words of memory out of 1500000
23667 string characters out of 1221006
51886 words of memory out of 1500000
2583 multiletter control sequences out of 10000+50000
31953 words of font info for 111 fonts, out of 1200000 for 2000
19 hyphenation exceptions out of 8191
15i,8n,11p,269b,471s stack positions out of 5000i,500n,6000p,200000b,5000s
15i,8n,11p,273b,471s stack positions out of 5000i,500n,6000p,200000b,5000s
Output written on bashref.dvi (162 pages, 624132 bytes).
Output written on bashref.dvi (162 pages, 629552 bytes).
BIN
View File
Binary file not shown.
+3096 -2984
View File
File diff suppressed because it is too large Load Diff
+97 -16
View File
@@ -16,7 +16,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Bash Reference Manual},
for @code{Bash}, Version @value{VERSION}.
Copyright @copyright{} 1988--2007 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2008 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -584,6 +584,7 @@ some other grouping.
commands.
* Lists:: How to execute commands sequentially.
* Compound Commands:: Shell commands for control flow.
* Coprocesses:: Two-way communication between commands.
@end menu
@node Simple Commands
@@ -1074,6 +1075,41 @@ from the @var{list} by whitespace.
The exit status of both of these constructs is the exit status of
@var{list}.
@node Coprocesses
@subsection Coprocesses
@cindex coprocess
A @code{coprocess} is a shell command preceded by the @code{coproc}
reserved word.
A coprocess is executed asynchronously in a subshell, as if the command
had been terminated with the @samp{&} control operator, with a two-way pipe
established between the executing shell and the coprocess.
The format for a coprocess is:
@example
@code{coproc} [@var{NAME}] @var{command} [@var{redirections}]
@end example
@noindent
This creates a coprocess named @var{NAME}.
If @var{NAME} is not supplied, the default name is @var{COPROC}.
When the coproc is executed, the shell creates an array variable
(@pxref{Arrays})
named @var{NAME} in the context of the executing shell.
The standard output of @var{command}
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to @var{NAME}[0].
The standard input of @var{command}
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to @var{NAME}[1].
This pipe is established before any redirections specified by the
command (@pxref{Redirections}).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
The return status of a coprocess is the exit status of @var{command}.
@node Shell Functions
@section Shell Functions
@cindex shell function
@@ -1620,11 +1656,14 @@ If @var{offset} evaluates to a number less than zero, the value
is used as an offset from the end of the value of @var{parameter}.
If @var{parameter} is @samp{@@}, the result is @var{length} positional
parameters beginning at @var{offset}.
If @var{parameter} is an array name indexed by @samp{@@} or @samp{*},
the result is the @var{length}
If @var{parameter} is an indexed array name subscripted
by @samp{@@} or @samp{*}, the result is the @var{length}
members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}.
A negative @var{offset} is taken relative to one greater than the maximum
index of the specified array.
Substring expansion applied to an associative array produces undefined
results.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the @samp{:-} expansion.
Substring indexing is zero-based unless the positional parameters
@@ -1711,6 +1750,29 @@ is an array variable subscripted with @samp{@@} or @samp{*},
the substitution operation is applied to each member of the
array in turn, and the expansion is the resultant list.
@item $@{@var{parameter}^@var{pattern}@}
@itemx $@{@var{parameter}^^@var{pattern}@}
@itemx $@{@var{parameter},@var{pattern}@}
@itemx $@{@var{parameter},,@var{pattern}@}
This expansion modifies the case of alphabetic characters in @var{parameter}.
The @var{pattern} is expanded to produce a pattern just as in
pathname expansion.
The @samp{^} operator converts lowercase letters matching @var{pattern}
to uppercase; the @samp{,} operator converts matching uppercase letters
to lowercase.
The @samp{^^} and @samp{,,} expansions convert each matched character in the
expanded value; the @samp{^} and @samp{,} expansions match and convert only
the first character.
If @var{pattern} is omitted, it is treated like a @samp{?}, which matches
every character.
If @var{parameter} is @samp{@@} or @samp{*},
the case modification operation is applied to each positional
parameter in turn, and the expansion is the resultant list.
If @var{parameter}
is an array variable subscripted with @samp{@@} or @samp{*},
the case modification operation is applied to each member of the
array in turn, and the expansion is the resultant list.
@end table
@node Command Substitution
@@ -3321,7 +3383,7 @@ zero if @var{command} is found, and non-zero if not.
@item declare
@btindex declare
@example
declare [-aAfFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
declare [-aAfFilrtux] [-p] [@var{name}[=@var{value}] @dots{}]
@end example
Declare variables and give them attributes. If no @var{name}s
@@ -3363,6 +3425,11 @@ The variable is to be treated as
an integer; arithmetic evaluation (@pxref{Shell Arithmetic}) is
performed when the variable is assigned a value.
@item -l
When the variable is assigned a value, all upper-case characters are
converted to lower-case.
The upper-case attribute is disabled.
@item -r
Make @var{name}s readonly. These names cannot then be assigned values
by subsequent assignment statements or unset.
@@ -3373,6 +3440,11 @@ Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from
the calling shell.
The trace attribute has no special meaning for variables.
@item -u
When the variable is assigned a value, all lower-case characters are
converted to upper-case.
The lower-case attribute is disabled.
@item -x
Mark each @var{name} for export to subsequent commands via
the environment.
@@ -3621,8 +3693,9 @@ meaning for the next character read and for line continuation.
If no names are supplied, the line read is assigned to the
variable @env{REPLY}.
The return code is zero, unless end-of-file is encountered, @code{read}
times out, or an invalid file descriptor is supplied as the argument to
@option{-u}.
times out (in which case the return code is greater than 128), or an
invalid file descriptor is supplied as the argument to @option{-u}.
Options, if supplied, have the following meanings:
@table @code
@@ -5828,8 +5901,8 @@ For almost every purpose, shell functions are preferred over aliases.
@cindex arrays
Bash provides one-dimensional indexed and associative array variables.
Any variable may be used as an array; the @code{declare} builtin will
explicitly declare an array.
Any variable may be used as an indexed array;
the @code{declare} builtin will explicitly declare an array.
There is no maximum
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously.
@@ -5856,24 +5929,27 @@ The syntax
declare -a @var{name}[@var{subscript}]
@end example
@noindent
is also accepted; the @var{subscript} is ignored. Attributes may be
specified for an array variable using the @code{declare} and
@code{readonly} builtins. Each attribute applies to all members of
an array.
is also accepted; the @var{subscript} is ignored.
Associative arrays are created using
@example
declare -A @var{name}.
@end example
Attributes may be
specified for an array variable using the @code{declare} and
@code{readonly} builtins. Each attribute applies to all members of
an array.
Arrays are assigned to using compound assignments of the form
@example
name=(value@var{1} @dots{} value@var{n})
@end example
@noindent
where each
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}.
When using indexed arrays, if
@var{value} is of the form @code{[@var{subscript}]=}@var{string}.
Indexed array assignments do not require the bracket and subscript.
When assigning to indexed arrays, if
the optional subscript is supplied, that index is assigned to;
otherwise the index of the element assigned is the last index assigned
to by the statement plus one. Indexing starts at zero.
@@ -6655,8 +6731,9 @@ argument restricts operation to running jobs.
suspend [-f]
@end example
Suspend the execution of this shell until it receives a
@code{SIGCONT} signal. The @option{-f} option means to suspend
even if the shell is a login shell.
@code{SIGCONT} signal.
A login shell cannot be suspended; the @option{-f}
option can be used to override this and force the suspension.
@end table
@@ -7076,6 +7153,10 @@ Include support for matching POSIX regular expressions using the
@samp{=~} binary operator in the @code{[[} conditional command.
(@pxref{Conditional Constructs}).
@item --enable-coprocesses
Include support for coprocesses and the @code{coproc} reserved word
(@pxref{Pipelines}).
@item --enable-debugger
Include support for the bash debugger (distributed separately).
+98 -17
View File
@@ -16,7 +16,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Bash Reference Manual},
for @code{Bash}, Version @value{VERSION}.
Copyright @copyright{} 1988--2007 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2008 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -584,6 +584,7 @@ some other grouping.
commands.
* Lists:: How to execute commands sequentially.
* Compound Commands:: Shell commands for control flow.
* Coprocesses:: Two-way communication between commands.
@end menu
@node Simple Commands
@@ -1074,6 +1075,41 @@ from the @var{list} by whitespace.
The exit status of both of these constructs is the exit status of
@var{list}.
@node Coprocesses
@subsection Coprocesses
@cindex coprocess
A @code{coprocess} is a shell command preceded by the @code{coproc}
reserved word.
A coprocess is executed asynchronously in a subshell, as if the command
had been terminated with the @samp{&} control operator, with a two-way pipe
established between the executing shell and the coprocess.
The format for a coprocess is:
@example
@code{coproc} [@var{NAME}] @var{command} [@var{redirections}]
@end example
@noindent
This creates a coprocess named @var{NAME}.
If @var{NAME} is not supplied, the default name is @var{COPROC}.
When the coproc is executed, the shell creates an array variable
(@pxref{Arrays})
named @var{NAME} in the context of the executing shell.
The standard output of @var{command}
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to @var{NAME}[0].
The standard input of @var{command}
is connected via a pipe to a file descriptor in the executing shell,
and that file descriptor is assigned to @var{NAME}[1].
This pipe is established before any redirections specified by the
command (@pxref{Redirections}).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
The return status of a coprocess is the exit status of @var{command}.
@node Shell Functions
@section Shell Functions
@cindex shell function
@@ -1620,11 +1656,14 @@ If @var{offset} evaluates to a number less than zero, the value
is used as an offset from the end of the value of @var{parameter}.
If @var{parameter} is @samp{@@}, the result is @var{length} positional
parameters beginning at @var{offset}.
If @var{parameter} is an array name indexed by @samp{@@} or @samp{*},
the result is the @var{length}
If @var{parameter} is an indexed array name subscripted
by @samp{@@} or @samp{*}, the result is the @var{length}
members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}.
A negative @var{offset} is taken relative to one greater than the maximum
index of the specified array.
Substring expansion applied to an associative array produces undefined
results.
Note that a negative offset must be separated from the colon by at least
one space to avoid being confused with the @samp{:-} expansion.
Substring indexing is zero-based unless the positional parameters
@@ -1711,6 +1750,29 @@ is an array variable subscripted with @samp{@@} or @samp{*},
the substitution operation is applied to each member of the
array in turn, and the expansion is the resultant list.
@item $@{@var{parameter}^@var{pattern}@}
@itemx $@{@var{parameter}^^@var{pattern}@}
@itemx $@{@var{parameter},@var{pattern}@}
@itemx $@{@var{parameter},,@var{pattern}@}
This expansion modifies the case of alphabetic characters in @var{parameter}.
The @var{pattern} is expanded to produce a pattern just as in
pathname expansion.
The @samp{^} operator converts lowercase letters matching @var{pattern}
to uppercase; the @samp{,} operator converts matching uppercase letters
to lowercase.
The @samp{^^} and @samp{,,} expansions convert each matched character in the
expanded value; the @samp{^} and @samp{,} expansions match and convert only
the first character.
If @var{pattern} is omitted, it is treated like a @samp{?}, which matches
every character.
If @var{parameter} is @samp{@@} or @samp{*},
the case modification operation is applied to each positional
parameter in turn, and the expansion is the resultant list.
If @var{parameter}
is an array variable subscripted with @samp{@@} or @samp{*},
the case modification operation is applied to each member of the
array in turn, and the expansion is the resultant list.
@end table
@node Command Substitution
@@ -3321,7 +3383,7 @@ zero if @var{command} is found, and non-zero if not.
@item declare
@btindex declare
@example
declare [-aAfFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
declare [-aAfFilrtux] [-p] [@var{name}[=@var{value}] @dots{}]
@end example
Declare variables and give them attributes. If no @var{name}s
@@ -3363,6 +3425,11 @@ The variable is to be treated as
an integer; arithmetic evaluation (@pxref{Shell Arithmetic}) is
performed when the variable is assigned a value.
@item -l
When the variable is assigned a value, all upper-case characters are
converted to lower-case.
The upper-case attribute is disabled.
@item -r
Make @var{name}s readonly. These names cannot then be assigned values
by subsequent assignment statements or unset.
@@ -3373,6 +3440,11 @@ Traced functions inherit the @code{DEBUG} and @code{RETURN} traps from
the calling shell.
The trace attribute has no special meaning for variables.
@item -u
When the variable is assigned a value, all lower-case characters are
converted to upper-case.
The lower-case attribute is disabled.
@item -x
Mark each @var{name} for export to subsequent commands via
the environment.
@@ -3621,8 +3693,9 @@ meaning for the next character read and for line continuation.
If no names are supplied, the line read is assigned to the
variable @env{REPLY}.
The return code is zero, unless end-of-file is encountered, @code{read}
times out, or an invalid file descriptor is supplied as the argument to
@option{-u}.
times out (in which case the return code is greater than 128), or an
invalid file descriptor is supplied as the argument to @option{-u}.
Options, if supplied, have the following meanings:
@table @code
@@ -4558,7 +4631,7 @@ builtin).
An associative array variable whose members correspond to the internal
hash table of commands as maintained by the @code{hash} builtin
(@pxref{Bourne Shell Builtins}).
Elements are to this array appear in the hash table; unsetting array
Elements added to this array appear in the hash table; unsetting array
elements cause commands to be removed from the hash table.
@item BASH_COMMAND
@@ -5828,8 +5901,8 @@ For almost every purpose, shell functions are preferred over aliases.
@cindex arrays
Bash provides one-dimensional indexed and associative array variables.
Any variable may be used as an array; the @code{declare} builtin will
explicitly declare an array.
Any variable may be used as an indexed array;
the @code{declare} builtin will explicitly declare an array.
There is no maximum
limit on the size of an array, nor any requirement that members
be indexed or assigned contiguously.
@@ -5856,24 +5929,27 @@ The syntax
declare -a @var{name}[@var{subscript}]
@end example
@noindent
is also accepted; the @var{subscript} is ignored. Attributes may be
specified for an array variable using the @code{declare} and
@code{readonly} builtins. Each attribute applies to all members of
an array.
is also accepted; the @var{subscript} is ignored.
Associative arrays are created using
@example
declare -A @var{name}.
@end example
Attributes may be
specified for an array variable using the @code{declare} and
@code{readonly} builtins. Each attribute applies to all members of
an array.
Arrays are assigned to using compound assignments of the form
@example
name=(value@var{1} @dots{} value@var{n})
@end example
@noindent
where each
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}.
When using indexed arrays, if
@var{value} is of the form @code{[@var{subscript}]=}@var{string}.
Indexed array assignments do not require the bracket and subscript.
When assigning to indexed arrays, if
the optional subscript is supplied, that index is assigned to;
otherwise the index of the element assigned is the last index assigned
to by the statement plus one. Indexing starts at zero.
@@ -6655,8 +6731,9 @@ argument restricts operation to running jobs.
suspend [-f]
@end example
Suspend the execution of this shell until it receives a
@code{SIGCONT} signal. The @option{-f} option means to suspend
even if the shell is a login shell.
@code{SIGCONT} signal.
A login shell cannot be suspended; the @option{-f}
option can be used to override this and force the suspension.
@end table
@@ -7076,6 +7153,10 @@ Include support for matching POSIX regular expressions using the
@samp{=~} binary operator in the @code{[[} conditional command.
(@pxref{Conditional Constructs}).
@item --enable-coprocesses
Include support for coprocesses and the @code{coproc} reserved word
(@pxref{Pipelines}).
@item --enable-debugger
Include support for the bash debugger (distributed separately).
+10 -10
View File
@@ -30,21 +30,21 @@
\subsecentry{Shell Parameter Expansion}{3}{5}{3}{19}
\subsecentry{Command Substitution}{3}{5}{4}{22}
\subsecentry{Arithmetic Expansion}{3}{5}{5}{22}
\subsecentry{Process Substitution}{3}{5}{6}{22}
\subsecentry{Process Substitution}{3}{5}{6}{23}
\subsecentry{Word Splitting}{3}{5}{7}{23}
\subsecentry{Filename Expansion}{3}{5}{8}{23}
\subsecentry{Filename Expansion}{3}{5}{8}{24}
\subsubsecentry{Pattern Matching}{3}{5}{8}{1}{24}
\subsecentry{Quote Removal}{3}{5}{9}{25}
\secentry{Redirections}{3}{6}{25}
\subsecentry{Redirecting Input}{3}{6}{1}{26}
\subsecentry{Redirecting Output}{3}{6}{2}{26}
\subsecentry{Redirecting Output}{3}{6}{2}{27}
\subsecentry{Appending Redirected Output}{3}{6}{3}{27}
\subsecentry{Redirecting Standard Output and Standard Error}{3}{6}{4}{27}
\subsecentry{Appending Standard Output and Standard Error}{3}{6}{5}{27}
\subsecentry{Here Documents}{3}{6}{6}{27}
\subsecentry{Here Documents}{3}{6}{6}{28}
\subsecentry{Here Strings}{3}{6}{7}{28}
\subsecentry{Duplicating File Descriptors}{3}{6}{8}{28}
\subsecentry{Moving File Descriptors}{3}{6}{9}{28}
\subsecentry{Moving File Descriptors}{3}{6}{9}{29}
\subsecentry{Opening File Descriptors for Reading and Writing}{3}{6}{10}{29}
\secentry{Executing Commands}{3}{7}{29}
\subsecentry{Simple Command Expansion}{3}{7}{1}{29}
@@ -59,7 +59,7 @@
\secentry{Bash Builtin Commands}{4}{2}{41}
\secentry{Modifying Shell Behavior}{4}{3}{50}
\subsecentry{The Set Builtin}{4}{3}{1}{50}
\subsecentry{The Shopt Builtin}{4}{3}{2}{53}
\subsecentry{The Shopt Builtin}{4}{3}{2}{54}
\secentry{Special Builtins}{4}{4}{58}
\chapentry{Shell Variables}{5}{59}
\secentry{Bourne Shell Variables}{5}{1}{59}
@@ -76,14 +76,14 @@
\secentry{Aliases}{6}{6}{77}
\secentry{Arrays}{6}{7}{78}
\secentry{The Directory Stack}{6}{8}{79}
\subsecentry{Directory Stack Builtins}{6}{8}{1}{79}
\secentry{Controlling the Prompt}{6}{9}{80}
\subsecentry{Directory Stack Builtins}{6}{8}{1}{80}
\secentry{Controlling the Prompt}{6}{9}{81}
\secentry{The Restricted Shell}{6}{10}{82}
\secentry{Bash POSIX Mode}{6}{11}{82}
\secentry{Bash POSIX Mode}{6}{11}{83}
\chapentry{Job Control}{7}{87}
\secentry{Job Control Basics}{7}{1}{87}
\secentry{Job Control Builtins}{7}{2}{88}
\secentry{Job Control Variables}{7}{3}{89}
\secentry{Job Control Variables}{7}{3}{90}
\chapentry{Command Line Editing}{8}{91}
\secentry{Introduction to Line Editing}{8}{1}{91}
\secentry{Readline Interaction}{8}{2}{91}
+20 -17
View File
@@ -22,49 +22,51 @@
\entry{PS2}{59}{\code {PS2}}
\entry{BASH}{59}{\code {BASH}}
\entry{BASHPID}{60}{\code {BASHPID}}
\entry{BASH_ALIASES}{60}{\code {BASH_ALIASES}}
\entry{BASH_ARGC}{60}{\code {BASH_ARGC}}
\entry{BASH_ARGV}{60}{\code {BASH_ARGV}}
\entry{BASH_CMDS}{60}{\code {BASH_CMDS}}
\entry{BASH_COMMAND}{60}{\code {BASH_COMMAND}}
\entry{BASH_ENV}{60}{\code {BASH_ENV}}
\entry{BASH_EXECUTION_STRING}{60}{\code {BASH_EXECUTION_STRING}}
\entry{BASH_LINENO}{60}{\code {BASH_LINENO}}
\entry{BASH_REMATCH}{60}{\code {BASH_REMATCH}}
\entry{BASH_SOURCE}{60}{\code {BASH_SOURCE}}
\entry{BASH_REMATCH}{61}{\code {BASH_REMATCH}}
\entry{BASH_SOURCE}{61}{\code {BASH_SOURCE}}
\entry{BASH_SUBSHELL}{61}{\code {BASH_SUBSHELL}}
\entry{BASH_VERSINFO}{61}{\code {BASH_VERSINFO}}
\entry{BASH_VERSION}{61}{\code {BASH_VERSION}}
\entry{COLUMNS}{61}{\code {COLUMNS}}
\entry{COMP_CWORD}{61}{\code {COMP_CWORD}}
\entry{COMP_LINE}{61}{\code {COMP_LINE}}
\entry{COMP_POINT}{61}{\code {COMP_POINT}}
\entry{COMP_TYPE}{61}{\code {COMP_TYPE}}
\entry{COMP_POINT}{62}{\code {COMP_POINT}}
\entry{COMP_TYPE}{62}{\code {COMP_TYPE}}
\entry{COMP_KEY}{62}{\code {COMP_KEY}}
\entry{COMP_WORDBREAKS}{62}{\code {COMP_WORDBREAKS}}
\entry{COMP_WORDS}{62}{\code {COMP_WORDS}}
\entry{COMPREPLY}{62}{\code {COMPREPLY}}
\entry{DIRSTACK}{62}{\code {DIRSTACK}}
\entry{EMACS}{62}{\code {EMACS}}
\entry{EUID}{62}{\code {EUID}}
\entry{FCEDIT}{62}{\code {FCEDIT}}
\entry{FIGNORE}{62}{\code {FIGNORE}}
\entry{FUNCNAME}{62}{\code {FUNCNAME}}
\entry{EUID}{63}{\code {EUID}}
\entry{FCEDIT}{63}{\code {FCEDIT}}
\entry{FIGNORE}{63}{\code {FIGNORE}}
\entry{FUNCNAME}{63}{\code {FUNCNAME}}
\entry{GLOBIGNORE}{63}{\code {GLOBIGNORE}}
\entry{GROUPS}{63}{\code {GROUPS}}
\entry{histchars}{63}{\code {histchars}}
\entry{HISTCMD}{63}{\code {HISTCMD}}
\entry{HISTCONTROL}{63}{\code {HISTCONTROL}}
\entry{HISTFILE}{63}{\code {HISTFILE}}
\entry{HISTFILESIZE}{63}{\code {HISTFILESIZE}}
\entry{HISTIGNORE}{63}{\code {HISTIGNORE}}
\entry{HISTFILE}{64}{\code {HISTFILE}}
\entry{HISTFILESIZE}{64}{\code {HISTFILESIZE}}
\entry{HISTIGNORE}{64}{\code {HISTIGNORE}}
\entry{HISTSIZE}{64}{\code {HISTSIZE}}
\entry{HISTTIMEFORMAT}{64}{\code {HISTTIMEFORMAT}}
\entry{HOSTFILE}{64}{\code {HOSTFILE}}
\entry{HOSTNAME}{64}{\code {HOSTNAME}}
\entry{HOSTTYPE}{64}{\code {HOSTTYPE}}
\entry{IGNOREEOF}{64}{\code {IGNOREEOF}}
\entry{INPUTRC}{64}{\code {INPUTRC}}
\entry{LANG}{64}{\code {LANG}}
\entry{LC_ALL}{64}{\code {LC_ALL}}
\entry{INPUTRC}{65}{\code {INPUTRC}}
\entry{LANG}{65}{\code {LANG}}
\entry{LC_ALL}{65}{\code {LC_ALL}}
\entry{LC_COLLATE}{65}{\code {LC_COLLATE}}
\entry{LC_CTYPE}{65}{\code {LC_CTYPE}}
\entry{LC_MESSAGES}{65}{\code {LC_MESSAGES}}
@@ -77,9 +79,10 @@
\entry{OPTERR}{65}{\code {OPTERR}}
\entry{OSTYPE}{65}{\code {OSTYPE}}
\entry{PIPESTATUS}{65}{\code {PIPESTATUS}}
\entry{POSIXLY_CORRECT}{65}{\code {POSIXLY_CORRECT}}
\entry{POSIXLY_CORRECT}{66}{\code {POSIXLY_CORRECT}}
\entry{PPID}{66}{\code {PPID}}
\entry{PROMPT_COMMAND}{66}{\code {PROMPT_COMMAND}}
\entry{PROMPT_DIRTRIM}{66}{\code {PROMPT_DIRTRIM}}
\entry{PS3}{66}{\code {PS3}}
\entry{PS4}{66}{\code {PS4}}
\entry{PWD}{66}{\code {PWD}}
@@ -88,8 +91,8 @@
\entry{SECONDS}{66}{\code {SECONDS}}
\entry{SHELL}{66}{\code {SHELL}}
\entry{SHELLOPTS}{66}{\code {SHELLOPTS}}
\entry{SHLVL}{66}{\code {SHLVL}}
\entry{TIMEFORMAT}{66}{\code {TIMEFORMAT}}
\entry{SHLVL}{67}{\code {SHLVL}}
\entry{TIMEFORMAT}{67}{\code {TIMEFORMAT}}
\entry{TMOUT}{67}{\code {TMOUT}}
\entry{TMPDIR}{67}{\code {TMPDIR}}
\entry{UID}{67}{\code {UID}}
+20 -17
View File
@@ -20,14 +20,16 @@
\entry {\code {auto_resume}}{90}
\initial {B}
\entry {\code {BASH}}{59}
\entry {\code {BASH_ALIASES}}{60}
\entry {\code {BASH_ARGC}}{60}
\entry {\code {BASH_ARGV}}{60}
\entry {\code {BASH_CMDS}}{60}
\entry {\code {BASH_COMMAND}}{60}
\entry {\code {BASH_ENV}}{60}
\entry {\code {BASH_EXECUTION_STRING}}{60}
\entry {\code {BASH_LINENO}}{60}
\entry {\code {BASH_REMATCH}}{60}
\entry {\code {BASH_SOURCE}}{60}
\entry {\code {BASH_REMATCH}}{61}
\entry {\code {BASH_SOURCE}}{61}
\entry {\code {BASH_SUBSHELL}}{61}
\entry {\code {BASH_VERSINFO}}{61}
\entry {\code {BASH_VERSION}}{61}
@@ -41,8 +43,8 @@
\entry {\code {COMP_CWORD}}{61}
\entry {\code {COMP_KEY}}{62}
\entry {\code {COMP_LINE}}{61}
\entry {\code {COMP_POINT}}{61}
\entry {\code {COMP_TYPE}}{61}
\entry {\code {COMP_POINT}}{62}
\entry {\code {COMP_TYPE}}{62}
\entry {\code {COMP_WORDBREAKS}}{62}
\entry {\code {COMP_WORDS}}{62}
\entry {\code {completion-prefix-display-length}}{95}
@@ -56,12 +58,12 @@
\entry {\code {editing-mode}}{96}
\entry {\code {EMACS}}{62}
\entry {\code {enable-keypad}}{96}
\entry {\code {EUID}}{62}
\entry {\code {EUID}}{63}
\entry {\code {expand-tilde}}{96}
\initial {F}
\entry {\code {FCEDIT}}{62}
\entry {\code {FIGNORE}}{62}
\entry {\code {FUNCNAME}}{62}
\entry {\code {FCEDIT}}{63}
\entry {\code {FIGNORE}}{63}
\entry {\code {FUNCNAME}}{63}
\initial {G}
\entry {\code {GLOBIGNORE}}{63}
\entry {\code {GROUPS}}{63}
@@ -69,9 +71,9 @@
\entry {\code {histchars}}{63}
\entry {\code {HISTCMD}}{63}
\entry {\code {HISTCONTROL}}{63}
\entry {\code {HISTFILE}}{63}
\entry {\code {HISTFILESIZE}}{63}
\entry {\code {HISTIGNORE}}{63}
\entry {\code {HISTFILE}}{64}
\entry {\code {HISTFILESIZE}}{64}
\entry {\code {HISTIGNORE}}{64}
\entry {\code {history-preserve-point}}{96}
\entry {\code {history-size}}{96}
\entry {\code {HISTSIZE}}{64}
@@ -85,13 +87,13 @@
\entry {\code {IFS}}{59}
\entry {\code {IGNOREEOF}}{64}
\entry {\code {input-meta}}{96}
\entry {\code {INPUTRC}}{64}
\entry {\code {INPUTRC}}{65}
\entry {\code {isearch-terminators}}{97}
\initial {K}
\entry {\code {keymap}}{97}
\initial {L}
\entry {\code {LANG}}{64}
\entry {\code {LC_ALL}}{64}
\entry {\code {LANG}}{65}
\entry {\code {LC_ALL}}{65}
\entry {\code {LC_COLLATE}}{65}
\entry {\code {LC_CTYPE}}{65}
\entry {\code {LC_MESSAGES}}{7, 65}
@@ -118,9 +120,10 @@
\entry {\code {page-completions}}{97}
\entry {\code {PATH}}{59}
\entry {\code {PIPESTATUS}}{65}
\entry {\code {POSIXLY_CORRECT}}{65}
\entry {\code {POSIXLY_CORRECT}}{66}
\entry {\code {PPID}}{66}
\entry {\code {PROMPT_COMMAND}}{66}
\entry {\code {PROMPT_DIRTRIM}}{66}
\entry {\code {PS1}}{59}
\entry {\code {PS2}}{59}
\entry {\code {PS3}}{66}
@@ -134,13 +137,13 @@
\entry {\code {SECONDS}}{66}
\entry {\code {SHELL}}{66}
\entry {\code {SHELLOPTS}}{66}
\entry {\code {SHLVL}}{66}
\entry {\code {SHLVL}}{67}
\entry {\code {show-all-if-ambiguous}}{98}
\entry {\code {show-all-if-unmodified}}{98}
\initial {T}
\entry {\code {TEXTDOMAIN}}{7}
\entry {\code {TEXTDOMAINDIR}}{7}
\entry {\code {TIMEFORMAT}}{66}
\entry {\code {TIMEFORMAT}}{67}
\entry {\code {TMOUT}}{67}
\entry {\code {TMPDIR}}{67}
\initial {U}
+101 -94
View File
@@ -330,8 +330,8 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
loop) is resumed. The return value is 0 unless _n is not greater
than or equal to 1.
ddeeccllaarree [--aaffFFiirrttxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...]
ttyyppeesseett [--aaffFFiirrttxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...]
ddeeccllaarree [--aaAAffFFiirrttxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...]
ttyyppeesseett [--aaAAffFFiirrttxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...]
Declare variables and/or give them attributes. If no _n_a_m_es are
given then display the values of variables. The --pp option will
display the attributes and values of each _n_a_m_e. When --pp is used
@@ -348,7 +348,10 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
played as well. The --FF option implies --ff. The following
options can be used to restrict output to variables with the
specified attribute or to give variables attributes:
--aa Each _n_a_m_e is an array variable (see AArrrraayyss above).
--aa Each _n_a_m_e is an indexed array variable (see AArrrraayyss
above).
--AA Each _n_a_m_e is an associative array variable (see AArrrraayyss
above).
--ff Use function names only.
--ii The variable is treated as an integer; arithmetic evalua-
tion (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN )) is performed when the
@@ -722,126 +725,126 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
llooggoouutt Exit a login shell.
mmaappffiillee [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u
nt_] _[--tt_] _[--uu _f_d_] _[--CC _c_a_l_l_b_a_c_k_] _[--cc _I_q_u_a_n_t_u_m]] [[_a_r_r_a_y]] RReeaadd lliinneess
ffrroomm tthhee ssttaannddaarrdd iinnppuutt iinnttoo aarrrraayy vvaarriiaabbllee _a_r_r_a_y, or from file
descriptor _f_d if the --uu option is supplied. The variable MMAAPP--
FFIILLEE is the default _a_r_r_a_y. Options, if supplied, have the fol-
lowing meanings:
--nn Copy at most _c_o_u_n_t lines. If _c_o_u_n_t is 0, all lines are
mmaappffiillee [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC _c_a_l_l_b_a_c_k]
[--cc _q_u_a_n_t_u_m] [_a_r_r_a_y]
Read lines from the standard input into array variable _a_r_r_a_y, or
from file descriptor _f_d if the --uu option is supplied. The vari-
able MMAAPPFFIILLEE is the default _a_r_r_a_y. Options, if supplied, have
the following meanings:
--nn Copy at most _c_o_u_n_t lines. If _c_o_u_n_t is 0, all lines are
copied.
--OO Begin assigning to _a_r_r_a_y at index _o_r_i_g_i_n. The default
--OO Begin assigning to _a_r_r_a_y at index _o_r_i_g_i_n. The default
index is 0.
--ss Discard the first _c_o_u_n_t lines read.
--tt Remove a trailing line from each line read.
--uu Read lines from file descriptor _f_d instead of the stan-
--uu Read lines from file descriptor _f_d instead of the stan-
dard input.
--CC Evaluate _c_a_l_l_b_a_c_k each time _q_u_a_n_t_u_m lines are read. The
--CC Evaluate _c_a_l_l_b_a_c_k each time _q_u_a_n_t_u_m lines are read. The
--cc option specifies _q_u_a_n_t_u_m.
--cc Specify the number of lines read between each call to
--cc Specify the number of lines read between each call to
_c_a_l_l_b_a_c_k.
If --CC is specified without --cc, the default quantum is 5000.
If not supplied with an explicit origin, mmaappffiillee will clear
If not supplied with an explicit origin, mmaappffiillee will clear
_a_r_r_a_y before assigning to it.
mmaappffiillee returns successfully unless an invalid option or option
mmaappffiillee returns successfully unless an invalid option or option
argument is supplied, or _a_r_r_a_y is invalid or unassignable.
ppooppdd [-nn] [+_n] [-_n]
Removes entries from the directory stack. With no arguments,
removes the top directory from the stack, and performs a ccdd to
Removes entries from the directory stack. With no arguments,
removes the top directory from the stack, and performs a ccdd to
the new top directory. Arguments, if supplied, have the follow-
ing meanings:
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
--nn Suppresses the normal change of directory when removing
directories from the stack, so that only the stack is
manipulated.
++_n Removes the _nth entry counting from the left of the list
shown by ddiirrss, starting with zero. For example: ``popd
++_n Removes the _nth entry counting from the left of the list
shown by ddiirrss, starting with zero. For example: ``popd
+0'' removes the first directory, ``popd +1'' the second.
--_n Removes the _nth entry counting from the right of the list
shown by ddiirrss, starting with zero. For example: ``popd
-0'' removes the last directory, ``popd -1'' the next to
shown by ddiirrss, starting with zero. For example: ``popd
-0'' removes the last directory, ``popd -1'' the next to
last.
If the ppooppdd command is successful, a ddiirrss is performed as well,
and the return status is 0. ppooppdd returns false if an invalid
If the ppooppdd command is successful, a ddiirrss is performed as well,
and the return status is 0. ppooppdd returns false if an invalid
option is encountered, the directory stack is empty, a non-exis-
tent directory stack entry is specified, or the directory change
fails.
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
simply copied to standard output, character escape sequences,
which are converted and copied to the standard output, and for-
mat specifications, each of which causes printing of the next
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
simply copied to standard output, character escape sequences,
which are converted and copied to the standard output, and for-
mat specifications, each of which causes printing of the next
successive _a_r_g_u_m_e_n_t. In addition to the standard _p_r_i_n_t_f(1) for-
mats, %%bb causes pprriinnttff to expand backslash escape sequences in
the corresponding _a_r_g_u_m_e_n_t (except that \\cc terminates output,
mats, %%bb causes pprriinnttff to expand backslash escape sequences in
the corresponding _a_r_g_u_m_e_n_t (except that \\cc terminates output,
backslashes in \\'', \\"", and \\?? are not removed, and octal escapes
beginning with \\00 may contain up to four digits), and %%qq causes
beginning with \\00 may contain up to four digits), and %%qq causes
pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a format that can
be reused as shell input.
The --vv option causes the output to be assigned to the variable
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_-
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] [+_n] [-_n]
ppuusshhdd [--nn] [_d_i_r]
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:
--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.
++_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.
_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] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [-- _t_e_x_t] [--nn _n_c_h_a_r_s] [--pp _p_r_o_m_p_t] [--tt
rreeaadd [--eerrss] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [-- _t_e_x_t] [--nn _n_c_h_a_r_s] [--pp _p_r_o_m_p_t] [--tt
_t_i_m_e_o_u_t] [--uu _f_d] [_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
@@ -849,52 +852,56 @@ 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.
--ii _t_e_x_t
If rreeaaddlliinnee is being used to read the line, _t_e_x_t is
If rreeaaddlliinnee is being used to read the line, _t_e_x_t is
placed into the editing buffer before editing begins.
--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 particu-
lar, a backslash-newline pair may not be used as a line
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. _t_i_m_e_-
_o_u_t may be a decimal number with a fractional portion
following the decimal point. This option has no effect
if rreeaadd is not reading input from the terminal or a pipe.
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. _t_i_m_e_-
_o_u_t may be a decimal number with a fractional portion
following the decimal point. This option is only effec-
tive if rreeaadd is reading input from a terminal, pipe, or
other special file; it has no effect when reading from
regular files. The exit status is greater than 128 if
the timeout is exceeded.
--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
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
variable name, or --ff is supplied with a _n_a_m_e that is not a func-
tion.
rreeaaddoonnllyy [--aaAAppff] [_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
marked. The --aa option restricts the variables to indexed
arrays; the --AA option restricts the variables to associative
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 variable 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 function.
rreettuurrnn [_n]
Causes a function to exit with the return value specified by _n.
@@ -1286,10 +1293,10 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
sequences by default.
ssuussppeenndd [--ff]
Suspend the execution of this shell until it receives a SSIIGGCCOONNTT
signal. The --ff option says not to complain if this is a login
shell; just suspend anyway. The return status is 0 unless the
shell is a login shell and --ff is not supplied, or if job control
is not enabled.
signal. A login shell cannot be suspended; the --ff option can be
used to override this and force the suspension. The return sta-
tus is 0 unless the shell is a login shell and --ff is not sup-
plied, or if job control is not enabled.
tteesstt _e_x_p_r
[[ _e_x_p_r ]]
Return a status of 0 or 1 depending on the evaluation of the
+721 -710
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.19.2
%%CreationDate: Thu May 29 11:48:42 2008
%%CreationDate: Wed Jul 2 09:08:26 2008
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.19 2
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2008 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Sun Jun 29 22:41:25 EDT 2008
@set LASTCHANGE Sun Jul 6 14:33:52 EDT 2008
@set EDITION 4.0
@set VERSION 4.0
@set UPDATED 29 June 2008
@set UPDATED-MONTH June 2008
@set UPDATED 6 July 2008
@set UPDATED-MONTH July 2008
+3 -3
View File
@@ -2,9 +2,9 @@
Copyright (C) 1988-2008 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Thu Jun 26 10:59:10 EDT 2008
@set LASTCHANGE Thu Jul 3 14:56:28 EDT 2008
@set EDITION 4.0
@set VERSION 4.0
@set UPDATED 26 June 2008
@set UPDATED-MONTH June 2008
@set UPDATED 3 July 2008
@set UPDATED-MONTH July 2008
+2 -1
View File
@@ -256,7 +256,8 @@ internal_warning (format, va_alist)
{
va_list args;
fprintf (stderr, _("%s: warning: "), get_name_for_error ());
error_prolog (1);
fprintf (stderr, _("warning: "));
SH_VA_START (args, format);
+327 -3
View File
@@ -181,6 +181,9 @@ static void execute_disk_command __P((WORD_LIST *, REDIRECT *, char *,
static char *getinterp __P((char *, int, int *));
static void initialize_subshell __P((void));
static int execute_in_subshell __P((COMMAND *, int, int, int, struct fd_bitmap *));
#if defined (COPROCESS_SUPPORT)
static int execute_coproc __P((COMMAND *, int, int, struct fd_bitmap *));
#endif
static int execute_pipeline __P((COMMAND *, int, int, int, struct fd_bitmap *));
@@ -540,6 +543,11 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (command->type == cm_subshell && (command->flags & CMD_NO_FORK))
return (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
#if defined (COPROCESS_SUPPORT)
if (command->type == cm_coproc)
return (execute_coproc (command, pipe_in, pipe_out, fds_to_close));
#endif
if (command->type == cm_subshell ||
(command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) ||
(shell_control_structure (command->type) &&
@@ -1199,10 +1207,11 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
struct fd_bitmap *fds_to_close;
{
int user_subshell, return_code, function_value, should_redir_stdin, invert;
int ois;
int ois, user_coproc;
COMMAND *tcom;
USE_VAR(user_subshell);
USE_VAR(user_coproc);
USE_VAR(invert);
USE_VAR(tcom);
USE_VAR(asynchronous);
@@ -1214,6 +1223,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
invert = (command->flags & CMD_INVERT_RETURN) != 0;
user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
user_coproc = command->type == cm_coproc;
command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
@@ -1266,6 +1276,8 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
subshell_environment |= SUBSHELL_ASYNC;
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
subshell_environment |= SUBSHELL_PIPE;
if (user_coproc)
subshell_environment |= SUBSHELL_COPROC;
}
reset_terminating_signals (); /* in sig.c */
@@ -1299,6 +1311,10 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
do_piping (pipe_in, pipe_out);
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
/* If this is a user subshell, set a flag if stdin was redirected.
This is used later to decide whether to redirect fd 0 to
/dev/null for async commands in the subshell. This adds more
@@ -1325,7 +1341,12 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
command->redirects = (REDIRECT *)NULL;
}
tcom = (command->type == cm_subshell) ? command->value.Subshell->command : command;
if (command->type == cm_subshell)
tcom = command->value.Subshell->command;
else if (user_coproc)
tcom = command->value.Coproc->command;
else
tcom = command;
if (command->flags & CMD_TIME_PIPELINE)
tcom->flags |= CMD_TIME_PIPELINE;
@@ -1341,7 +1362,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
This means things like ( sleep 10 ) will only cause one fork.
If we're timing the command or inverting its return value, however,
we cannot do this optimization. */
if (user_subshell && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
if ((user_subshell || user_coproc) && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
((tcom->flags & CMD_TIME_PIPELINE) == 0) &&
((tcom->flags & CMD_INVERT_RETURN) == 0))
{
@@ -1382,6 +1403,302 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
/* NOTREACHED */
}
#if defined (COPROCESS_SUPPORT)
Coproc sh_coproc = { 0, NO_PID, -1, -1, 0, 0 };
/* These currently use a single global "shell coproc" but are written in a
way to not preclude additional coprocs later */
struct coproc *
getcoprocbypid (pid)
pid_t pid;
{
return (pid == sh_coproc.c_pid ? &sh_coproc : 0);
}
struct coproc *
getcoprocbyname (name)
const char *name;
{
return ((sh_coproc.c_name && STREQ (sh_coproc.c_name, name)) ? &sh_coproc : 0);
}
void
coproc_init (cp)
struct coproc *cp;
{
cp->c_name = 0;
cp->c_pid = NO_PID;
cp->c_rfd = cp->c_wfd = -1;
cp->c_rsave = cp->c_wsave = -1;
cp->c_flags = cp->c_status = 0;
}
struct coproc *
coproc_alloc (name, pid)
char *name;
pid_t pid;
{
struct coproc *cp;
cp = &sh_coproc;
coproc_init (cp);
cp->c_name = savestring (name);
cp->c_pid = pid;
return (cp);
}
void
coproc_dispose (cp)
struct coproc *cp;
{
if (cp == 0)
return;
coproc_unsetvars (cp);
FREE (cp->c_name);
coproc_close (cp);
coproc_init (cp);
}
void
coproc_close (cp)
struct coproc *cp;
{
if (cp->c_rfd >= 0)
{
close (cp->c_rfd);
cp->c_rfd = -1;
}
if (cp->c_wfd >= 0)
{
close (cp->c_wfd);
cp->c_wfd = -1;
}
cp->c_rsave = cp->c_wsave = -1;
}
void
coproc_rclose (cp, fd)
struct coproc *cp;
int fd;
{
if (cp->c_rfd >= 0 && cp->c_rfd == fd)
{
close (cp->c_rfd);
cp->c_rfd = -1;
}
}
void
coproc_wclose (cp, fd)
struct coproc *cp;
int fd;
{
if (cp->c_wfd >= 0 && cp->c_wfd == fd)
{
close (cp->c_wfd);
cp->c_wfd = -1;
}
}
void
coproc_fdchk (cp, fd)
struct coproc *cp;
int fd;
{
int update;
update = 0;
if (cp->c_rfd >= 0 && cp->c_rfd == fd)
update = cp->c_rfd = -1;
if (cp->c_wfd >= 0 && cp->c_wfd == fd)
update = cp->c_wfd = -1;
if (update)
coproc_setvars (cp);
}
void
coproc_fdclose (cp, fd)
struct coproc *cp;
int fd;
{
coproc_rclose (cp, fd);
coproc_wclose (cp, fd);
coproc_setvars (cp);
}
void
coproc_fdsave (cp)
struct coproc *cp;
{
cp->c_rsave = cp->c_rfd;
cp->c_wsave = cp->c_wfd;
}
void
coproc_fdrestore (cp)
struct coproc *cp;
{
cp->c_rfd = cp->c_rsave;
cp->c_wfd = cp->c_wsave;
}
void
coproc_pidchk (pid)
pid_t pid;
{
struct coproc *cp;
cp = getcoprocbypid (pid);
if (cp)
coproc_dispose (cp);
}
void
coproc_setvars (cp)
struct coproc *cp;
{
SHELL_VAR *v;
char *namevar, *t;
int l;
#if defined (ARRAY_VARS)
arrayind_t ind;
#endif
if (cp->c_name == 0)
return;
l = strlen (cp->c_name);
namevar = xmalloc (l + 16);
#if defined (ARRAY_VARS)
v = find_variable (cp->c_name);
if (v == 0)
v = make_new_array_variable (cp->c_name);
if (array_p (v) == 0)
v = convert_var_to_array (v);
t = itos (cp->c_rfd);
ind = 0;
v = bind_array_variable (cp->c_name, ind, t, 0);
free (t);
t = itos (cp->c_wfd);
ind = 1;
bind_array_variable (cp->c_name, ind, t, 0);
free (t);
#else
sprintf (namevar, "%s_READ", cp->c_name);
t = itos (cp->c_rfd);
bind_variable (namevar, t, 0);
free (t);
sprintf (namevar, "%s_WRITE", cp->c_name);
t = itos (cp->c_wfd);
bind_variable (namevar, t, 0);
free (t);
#endif
sprintf (namevar, "%s_PID", cp->c_name);
t = itos (cp->c_pid);
bind_variable (namevar, t, 0);
free (t);
free (namevar);
}
void
coproc_unsetvars (cp)
struct coproc *cp;
{
int l;
char *namevar;
if (cp->c_name == 0)
return;
l = strlen (cp->c_name);
namevar = xmalloc (l + 16);
sprintf (namevar, "%s_PID", cp->c_name);
unbind_variable (namevar);
#if defined (ARRAY_VARS)
unbind_variable (cp->c_name);
#else
sprintf (namevar, "%s_READ", cp->c_name);
unbind_variable (namevar);
sprintf (namevar, "%s_WRITE", cp->c_name);
unbind_variable (namevar);
#endif
free (namevar);
}
static int
execute_coproc (command, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
int pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
int rpipe[2], wpipe[2];
pid_t coproc_pid;
Coproc *cp;
char *tcmd;
if (sh_coproc.c_pid != -1)
{
internal_error ("execute_coproc: coproc [%d:%s] already exists", sh_coproc.c_pid, sh_coproc.c_name);
return (last_command_exit_value = EXECUTION_FAILURE);
}
coproc_init (&sh_coproc);
command_string_index = 0;
tcmd = make_command_string (command);
sh_openpipe ((int *)&rpipe); /* 0 = parent read, 1 = child write */
sh_openpipe ((int *)&wpipe); /* 0 = child read, 1 = parent write */
coproc_pid = make_child (savestring (tcmd), 1);
if (coproc_pid == 0)
{
close (rpipe[0]);
close (wpipe[1]);
exit (execute_in_subshell (command, 1, wpipe[0], rpipe[1], fds_to_close));
}
close (rpipe[1]);
close (wpipe[0]);
cp = coproc_alloc (command->value.Coproc->name, coproc_pid);
cp->c_rfd = rpipe[0];
cp->c_wfd = wpipe[1];
SET_CLOSE_ON_EXEC (cp->c_rfd);
SET_CLOSE_ON_EXEC (cp->c_wfd);
coproc_setvars (cp);
#if defined (DEBUG)
itrace ("execute_coproc: [%d] %s", coproc_pid, the_printed_command);
#endif
close_pipes (pipe_in, pipe_out);
#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
unlink_fifo_list ();
#endif
stop_pipeline (1, (COMMAND *)NULL);
DESCRIBE_PID (coproc_pid);
run_pending_traps ();
return (EXECUTION_SUCCESS);
}
#endif
static int
execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
@@ -2692,6 +3009,10 @@ execute_null_command (redirects, pipe_in, pipe_out, async)
do_piping (pipe_in, pipe_out);
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
subshell_environment = 0;
if (async)
subshell_environment |= SUBSHELL_ASYNC;
@@ -2894,6 +3215,9 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
do_piping (pipe_in, pipe_out);
pipe_in = pipe_out = NO_PIPE;
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
last_asynchronous_pid = old_last_async_pid;
}
+332 -3
View File
@@ -181,6 +181,9 @@ static void execute_disk_command __P((WORD_LIST *, REDIRECT *, char *,
static char *getinterp __P((char *, int, int *));
static void initialize_subshell __P((void));
static int execute_in_subshell __P((COMMAND *, int, int, int, struct fd_bitmap *));
#if defined (COPROCESS_SUPPORT)
static int execute_coproc __P((COMMAND *, int, int, struct fd_bitmap *));
#endif
static int execute_pipeline __P((COMMAND *, int, int, int, struct fd_bitmap *));
@@ -506,8 +509,15 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
volatile int last_pid;
volatile int save_line_number;
#if 0
if (command == 0 || breaking || continuing || read_but_dont_execute)
return (EXECUTION_SUCCESS);
#else
if (breaking || continuing)
return (last_command_exit_value);
if (command == 0 || read_but_dont_execute)
return (EXECUTION_SUCCESS);
#endif
QUIT;
run_pending_traps ();
@@ -533,6 +543,11 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
if (command->type == cm_subshell && (command->flags & CMD_NO_FORK))
return (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
#if defined (COPROCESS_SUPPORT)
if (command->type == cm_coproc)
return (execute_coproc (command, pipe_in, pipe_out, fds_to_close));
#endif
if (command->type == cm_subshell ||
(command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) ||
(shell_control_structure (command->type) &&
@@ -1192,10 +1207,11 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
struct fd_bitmap *fds_to_close;
{
int user_subshell, return_code, function_value, should_redir_stdin, invert;
int ois;
int ois, user_coproc;
COMMAND *tcom;
USE_VAR(user_subshell);
USE_VAR(user_coproc);
USE_VAR(invert);
USE_VAR(tcom);
USE_VAR(asynchronous);
@@ -1207,6 +1223,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
invert = (command->flags & CMD_INVERT_RETURN) != 0;
user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
user_coproc = command->type == cm_coproc;
command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
@@ -1259,6 +1276,8 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
subshell_environment |= SUBSHELL_ASYNC;
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
subshell_environment |= SUBSHELL_PIPE;
if (user_coproc)
subshell_environment |= SUBSHELL_COPROC;
}
reset_terminating_signals (); /* in sig.c */
@@ -1292,6 +1311,10 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
do_piping (pipe_in, pipe_out);
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
/* If this is a user subshell, set a flag if stdin was redirected.
This is used later to decide whether to redirect fd 0 to
/dev/null for async commands in the subshell. This adds more
@@ -1318,7 +1341,12 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
command->redirects = (REDIRECT *)NULL;
}
tcom = (command->type == cm_subshell) ? command->value.Subshell->command : command;
if (command->type == cm_subshell)
tcom = command->value.Subshell->command;
else if (user_coproc)
tcom = command->value.Coproc->command;
else
tcom = command;
if (command->flags & CMD_TIME_PIPELINE)
tcom->flags |= CMD_TIME_PIPELINE;
@@ -1334,7 +1362,7 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
This means things like ( sleep 10 ) will only cause one fork.
If we're timing the command or inverting its return value, however,
we cannot do this optimization. */
if (user_subshell && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
if ((user_subshell || user_coproc) && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
((tcom->flags & CMD_TIME_PIPELINE) == 0) &&
((tcom->flags & CMD_INVERT_RETURN) == 0))
{
@@ -1375,6 +1403,300 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
/* NOTREACHED */
}
#if defined (COPROCESS_SUPPORT)
Coproc sh_coproc = { 0, NO_PID, -1, -1, 0, 0 };
/* These currently use a single global "shell coproc" but are written in a
way to not preclude additional coprocs later */
struct coproc *
getcoprocbypid (pid)
pid_t pid;
{
return (pid == sh_coproc.c_pid ? &sh_coproc : 0);
}
struct coproc *
getcoprocbyname (name)
const char *name;
{
return ((sh_coproc.c_name && STREQ (sh_coproc.c_name, name)) ? &sh_coproc : 0);
}
void
coproc_init (cp)
struct coproc *cp;
{
cp->c_name = 0;
cp->c_pid = NO_PID;
cp->c_rfd = cp->c_wfd = -1;
cp->c_rsave = cp->c_wsave = -1;
cp->c_flags = cp->c_status = 0;
}
struct coproc *
coproc_alloc (name, pid)
char *name;
pid_t pid;
{
struct coproc *cp;
cp = &sh_coproc;
coproc_init (cp);
cp->c_name = savestring (name);
cp->c_pid = pid;
return (cp);
}
void
coproc_dispose (cp)
struct coproc *cp;
{
if (cp == 0)
return;
coproc_unsetvars (cp);
FREE (cp->c_name);
coproc_close (cp);
coproc_init (cp);
}
void
coproc_close (cp)
struct coproc *cp;
{
if (cp->c_rfd >= 0)
{
close (cp->c_rfd);
cp->c_rfd = -1;
}
if (cp->c_wfd >= 0)
{
close (cp->c_wfd);
cp->c_wfd = -1;
}
cp->c_rsave = cp->c_wsave = -1;
}
void
coproc_rclose (cp, fd)
struct coproc *cp;
int fd;
{
if (cp->c_rfd >= 0 && cp->c_rfd == fd)
{
close (cp->c_rfd);
cp->c_rfd = -1;
}
}
void
coproc_wclose (cp, fd)
struct coproc *cp;
int fd;
{
if (cp->c_wfd >= 0 && cp->c_wfd == fd)
{
close (cp->c_wfd);
cp->c_wfd = -1;
}
}
void
coproc_fdchk (cp, fd)
struct coproc *cp;
int fd;
{
int update;
update = 0;
if (cp->c_rfd >= 0 && cp->c_rfd == fd)
update = cp->c_rfd = -1;
if (cp->c_wfd >= 0 && cp->c_wfd == fd)
update = cp->c_wfd = -1;
if (update)
coproc_setvars (cp);
}
void
coproc_fdclose (cp, fd)
struct coproc *cp;
int fd;
{
coproc_rclose (cp, fd);
coproc_wclose (cp, fd);
coproc_setvars (cp);
}
void
coproc_fdsave (cp)
struct coproc *cp;
{
cp->c_rsave = cp->c_rfd;
cp->c_wsave = cp->c_wfd;
}
void
coproc_fdrestore (cp)
struct coproc *cp;
{
cp->c_rfd = cp->c_rsave;
cp->c_wfd = cp->c_wsave;
}
void
coproc_pidchk (pid)
pid_t pid;
{
struct coproc *cp;
cp = getcoprocbypid (pid);
if (cp)
coproc_dispose (cp);
}
void
coproc_setvars (cp)
struct coproc *cp;
{
SHELL_VAR *v;
char *namevar, *t;
int l;
#if defined (ARRAY_VARS)
arrayind_t ind;
#endif
if (cp->c_name == 0)
return;
l = strlen (cp->c_name);
namevar = xmalloc (l + 16);
#if defined (ARRAY_VARS)
v = find_variable (cp->c_name);
if (v == 0)
v = make_new_array_variable (cp->c_name);
if (array_p (v) == 0)
v = convert_var_to_array (v);
t = itos (cp->c_rfd);
ind = 0;
v = bind_array_variable (cp->c_name, ind, t, 0);
free (t);
t = itos (cp->c_wfd);
ind = 1;
bind_array_variable (cp->c_name, ind, t, 0);
free (t);
#else
sprintf (namevar, "%s_READ", cp->c_name);
t = itos (cp->c_rfd);
bind_variable (namevar, t, 0);
free (t);
sprintf (namevar, "%s_WRITE", cp->c_name);
t = itos (cp->c_wfd);
bind_variable (namevar, t, 0);
free (t);
#endif
sprintf (namevar, "%s_PID", cp->c_name);
t = itos (cp->c_pid);
bind_variable (namevar, t, 0);
free (t);
free (namevar);
}
void
coproc_unsetvars (cp)
struct coproc *cp;
{
int l;
char *namevar;
if (cp->c_name == 0)
return;
l = strlen (cp->c_name);
namevar = xmalloc (l + 16);
sprintf (namevar, "%s_PID", cp->c_name);
unbind_variable (namevar);
#if defined (ARRAY_VARS)
unbind_variable (cp->c_name);
#else
sprintf (namevar, "%s_READ", cp->c_name);
unbind_variable (namevar);
sprintf (namevar, "%s_WRITE", cp->c_name);
unbind_variable (namevar);
#endif
free (namevar);
}
static int
execute_coproc (command, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
int pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
int rpipe[2], wpipe[2];
pid_t coproc_pid;
Coproc *cp;
char *tcmd;
if (sh_coproc.c_pid != -1)
{
internal_error ("execute_coproc: coproc [%d:%s] already exists", sh_coproc.c_pid, sh_coproc.c_name);
return (last_command_exit_value = EXECUTION_FAILURE);
}
coproc_init (&sh_coproc);
command_string_index = 0;
tcmd = make_command_string (command);
sh_openpipe ((int *)&rpipe); /* 0 = parent read, 1 = child write */
sh_openpipe ((int *)&wpipe); /* 0 = child read, 1 = parent write */
coproc_pid = make_child (savestring (tcmd), 1);
if (coproc_pid == 0)
{
close (rpipe[0]);
close (wpipe[1]);
exit (execute_in_subshell (command, 1, wpipe[0], rpipe[1], fds_to_close));
}
close (rpipe[1]);
close (wpipe[0]);
cp = coproc_alloc (command->value.Coproc->name, coproc_pid);
cp->c_rfd = rpipe[0];
cp->c_wfd = wpipe[1];
SET_CLOSE_ON_EXEC (cp->c_rfd);
SET_CLOSE_ON_EXEC (cp->c_wfd);
coproc_setvars (cp);
itrace ("execute_coproc: [%d] %s", coproc_pid, the_printed_command);
close_pipes (pipe_in, pipe_out);
#if defined (PROCESS_SUBSTITUTION) && defined (HAVE_DEV_FD)
unlink_fifo_list ();
#endif
stop_pipeline (1, (COMMAND *)NULL);
DESCRIBE_PID (coproc_pid);
run_pending_traps ();
return (EXECUTION_SUCCESS);
}
#endif
static int
execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
@@ -2685,6 +3007,10 @@ execute_null_command (redirects, pipe_in, pipe_out, async)
do_piping (pipe_in, pipe_out);
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
subshell_environment = 0;
if (async)
subshell_environment |= SUBSHELL_ASYNC;
@@ -2887,6 +3213,9 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
do_piping (pipe_in, pipe_out);
pipe_in = pipe_out = NO_PIPE;
#if defined (COPROCESS_SUPPORT)
coproc_close (&sh_coproc);
#endif
last_asynchronous_pid = old_last_async_pid;
}
+66
View File
@@ -0,0 +1,66 @@
/* fdprintf -- printf to a file descriptor
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if !HAVE_FDPRINTF
#include <stdc.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdio.h>
int
#if defined (PREFER_STDARG)
fdprintf(int fd, const char *format, ...)
#else
fdprintf(fd, format, va_alist)
int fd;
const char *format;
va_dcl
#endif
{
FILE *fp;
int rc, r2;
va_list args;
fp = fdopen (dup (fd), "w");
if (fp == 0)
return -1;
SH_VA_START (args, format);
rc = vfprintf (fp, fmt, ap);
fflush (fp);
va_end (args);
r2 = fclose (fp); /* check here */
return rc;
}
#endif
+21
View File
@@ -47,6 +47,18 @@
extern int errno;
#endif /* !errno */
#if defined (EAGAIN)
# define X_EAGAIN EAGAIN
#else
# define X_EAGAIN -99
#endif
#if defined (EWOULDBLOCK)
# define X_EWOULDBLOCK EWOULDBLOCK
#else
# define X_EWOULDBLOCK -99
#endif
extern void termsig_handler __P((int));
/* Functions to handle reading input on systems that don't restart read(2)
@@ -75,6 +87,15 @@ getc_with_restart (stream)
local_bufused = read (fileno (stream), localbuf, sizeof(localbuf));
if (local_bufused > 0)
break;
else if (errno == X_EAGAIN || errno == X_EWOULDBLOCK)
{
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
{
sys_error (_("cannot reset nodelay mode for fd %d"), fileno (stream));
return EOF;
}
continue;
}
else if (local_bufused == 0 || errno != EINTR)
{
local_index = 0;
+4
View File
@@ -3074,6 +3074,10 @@ waitchld (wpid, block)
/* Locate our PROCESS for this pid. */
child = find_process (pid, 1, &job); /* want living procs only */
#if defined (COPROCESS_SUPPORT)
coproc_pidchk (pid);
#endif
/* It is not an error to have a child terminate that we did
not have a record of. This child could have been part of
a pipeline in backquote substitution. Even so, I'm not
+1 -1
View File
@@ -3122,7 +3122,7 @@ waitchld (wpid, block)
if (job_control && signal_is_trapped (SIGCHLD) && children_exited &&
trap_list[SIGCHLD] != (char *)IGNORE_SIG)
{
if (posixly_correct && this_shell_builtin && this_shell_builtin == wait_builtin)
if (this_shell_builtin && this_shell_builtin == wait_builtin)
{
interrupt_immediately = 0;
trap_handler (SIGCHLD); /* set pending_traps[SIGCHLD] */
+2 -2
View File
@@ -660,13 +660,13 @@ fnprint (to_print, prefix_bytes)
const char *to_print;
int prefix_bytes;
{
int printed_len;
int printed_len, w;
const char *s;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
const char *end;
size_t tlen;
int width, w;
int width;
wchar_t wc;
end = to_print + strlen (to_print) + 1;
+1 -1
View File
@@ -92,7 +92,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
strtoll.c strtoull.c strtoimax.c strtoumax.c memset.c strstr.c \
mktime.c strftime.c xstrchr.c zcatfd.c zmapfd.c winsize.c eaccess.c \
wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \
casemod.c
casemod.c fdprintf.c
# The header files for this library.
HSOURCES =
+3 -2
View File
@@ -92,7 +92,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
strtoll.c strtoull.c strtoimax.c strtoumax.c memset.c strstr.c \
mktime.c strftime.c xstrchr.c zcatfd.c zmapfd.c winsize.c eaccess.c \
wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \
casemod.c
casemod.c fdprintf.c
# The header files for this library.
HSOURCES =
@@ -104,7 +104,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
netconn.o netopen.o timeval.o makepath.o pathcanon.o \
pathphys.o tmpfile.o stringlist.o stringvec.o spell.o shquote.o \
strtrans.o strindex.o snprintf.o mailstat.o fmtulong.o \
fmtullong.o fmtumax.o xstrchr.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
fmtullong.o fmtumax.o xstrchr.o zcatfd.o zmapfd.o winsize.o wcsdup.o
fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o ${LIBOBJS}
SUPPORT = Makefile
@@ -204,6 +204,7 @@ strtoull.o: strtol.c
# all files in the library depend on config.h
casemod.o: ${BUILD_DIR}/config.h
clktck.o: ${BUILD_DIR}/config.h
clock.o: ${BUILD_DIR}/config.h
eaccess.o: ${BUILD_DIR}/config.h
fmtullong.o: ${BUILD_DIR}/config.h
+63
View File
@@ -0,0 +1,63 @@
/* fdprintf -- printf to a file descriptor
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdc.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdio.h>
int
#if defined (PREFER_STDARG)
fdprintf(int fd, const char *format, ...)
#else
fdprintf(fd, format, va_alist)
int fd;
const char *format;
va_dcl
#endif
{
FILE *fp;
int rc, r2;
va_list args;
fp = fdopen (dup (fd), "w");
if (fp == 0)
return -1;
SH_VA_START (args, format);
rc = vfprintf (fp, format, args);
fflush (fp);
va_end (args);
r2 = fclose (fp); /* check here */
return rc;
}
+63
View File
@@ -0,0 +1,63 @@
/* fdprintf -- printf to a file descriptor
Copyright (C) 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdc.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (PREFER_STDARG)
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include <stdio.h>
int
#if defined (PREFER_STDARG)
fdprintf(int fd, const char *format, ...)
#else
fdprintf(fd, format, va_alist)
int fd;
const char *format;
va_dcl
#endif
{
FILE *fp;
int rc, r2;
va_list args;
fp = fdopen (dup (fd), "w");
if (fp == 0)
return -1;
SH_VA_START (args, format);
rc = vfprintf (fp, fmt, ap);
fflush (fp);
va_end (args);
r2 = fclose (fp); /* check here */
return rc;
}
+17
View File
@@ -647,6 +647,9 @@ make_here_document (temp, lineno)
document_index += len;
}
if (full_line == 0)
internal_warning (_("here-document at line %d delimited by end-of-file (wanted `%s')"), lineno, redir_word);
document_done:
if (document)
document[document_index] = '\0';
@@ -793,6 +796,20 @@ make_subshell_command (command)
return (make_command (cm_subshell, (SIMPLE_COM *)temp));
}
COMMAND *
make_coproc_command (name, command)
char *name;
COMMAND *command;
{
COPROC_COM *temp;
temp = (COPROC_COM *)xmalloc (sizeof (COPROC_COM));
temp->name = savestring (name);
temp->command = command;
temp->flags = CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
return (make_command (cm_coproc, (SIMPLE_COM *)temp));
}
/* Reverse the word list and redirection list in the simple command
has just been parsed. It seems simpler to do this here the one
time then by any other method that I can think of. */
+3
View File
@@ -647,6 +647,9 @@ make_here_document (temp, lineno)
document_index += len;
}
if (full_line == 0)
internal_warning (_("here-document at line %d delimited by end-of-file (wanted `%s')"), lineno, redir_word);
document_done:
if (document)
document[document_index] = '\0';
+2 -1
View File
@@ -1,6 +1,6 @@
/* make_cmd.h -- Declarations of functions found in make_cmd.c */
/* Copyright (C) 1993-2005 Free Software Foundation, Inc.
/* Copyright (C) 1993-2008 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -63,6 +63,7 @@ extern COMMAND *make_cond_command __P((COND_COM *));
extern COMMAND *make_arith_for_command __P((WORD_LIST *, COMMAND *, int));
extern COMMAND *make_subshell_command __P((COMMAND *));
extern COMMAND *make_coproc_command __P((char *, COMMAND *));
extern COMMAND *connect_async_list __P((COMMAND *, COMMAND *, int));
+1 -1
View File
@@ -46,7 +46,7 @@ extern COMMAND *make_while_command __P((COMMAND *, COMMAND *));
extern COMMAND *make_until_command __P((COMMAND *, COMMAND *));
extern COMMAND *make_bare_simple_command __P((void));
extern COMMAND *make_simple_command __P((ELEMENT, COMMAND *));
extern void make_here_document __P((REDIRECT *));
extern void make_here_document __P((REDIRECT *, int));
extern REDIRECT *make_redirection __P((int, enum r_instruction, REDIRECTEE));
extern COMMAND *make_function_def __P((WORD_DESC *, COMMAND *, int, int));
extern COMMAND *clean_simple_command __P((COMMAND *));
+63 -1
View File
@@ -327,7 +327,7 @@ static REDIRECTEE redir;
in the case that they are preceded by a list_terminator. Members
of the second group are for [[...]] commands. Members of the
third group are recognized only under special circumstances. */
%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION
%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION COPROC
%token COND_START COND_END COND_ERROR
%token IN BANG TIME TIMEOPT
@@ -350,6 +350,7 @@ static REDIRECTEE redir;
%type <command> arith_command
%type <command> cond_command
%type <command> arith_for_command
%type <command> coproc
%type <command> function_def function_body if_command elif_clause subshell
%type <redirect> redirection redirection_list
%type <element> simple_command_element
@@ -625,6 +626,8 @@ command: simple_command
}
| function_def
{ $$ = $1; }
| coproc
{ $$ = $1; }
;
shell_command: for_command
@@ -814,6 +817,57 @@ subshell: '(' compound_list ')'
}
;
coproc: COPROC shell_command
{
$$ = make_coproc_command ("COPROC", $2);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC shell_command redirection_list
{
COMMAND *tc;
tc = $2;
if (tc->redirects)
{
register REDIRECT *t;
for (t = tc->redirects; t->next; t = t->next)
;
t->next = $3;
}
else
tc->redirects = $3;
$$ = make_coproc_command ("COPROC", $2);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC WORD shell_command
{
$$ = make_coproc_command ($2->word, $3);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC WORD shell_command redirection_list
{
COMMAND *tc;
tc = $3;
if (tc->redirects)
{
register REDIRECT *t;
for (t = tc->redirects; t->next; t = t->next)
;
t->next = $4;
}
else
tc->redirects = $4;
$$ = make_coproc_command ($2->word, $3);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC simple_command
{
$$ = make_coproc_command ("COPROC", clean_simple_command ($2));
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
;
if_command: IF compound_list THEN compound_list FI
{ $$ = make_if_command ($2, $4, (COMMAND *)NULL); }
| IF compound_list THEN compound_list ELSE compound_list FI
@@ -1854,6 +1908,9 @@ STRING_INT_ALIST word_token_alist[] = {
#if defined (COND_COMMAND)
{ "[[", COND_START },
{ "]]", COND_END },
#endif
#if defined (COPROCESS_SUPPORT)
{ "coproc", COPROC },
#endif
{ (char *)NULL, 0}
};
@@ -4364,11 +4421,16 @@ reserved_word_acceptable (toksym)
case THEN:
case TIME:
case TIMEOPT:
case COPROC:
case UNTIL:
case WHILE:
case 0:
return 1;
default:
#if defined (COPROCESS_SUPPORT)
if (last_read_token == WORD && token_before_that == COPROC)
return 1;
#endif
return 0;
}
}
+70 -3
View File
@@ -327,7 +327,7 @@ static REDIRECTEE redir;
in the case that they are preceded by a list_terminator. Members
of the second group are for [[...]] commands. Members of the
third group are recognized only under special circumstances. */
%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION
%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION COPROC
%token COND_START COND_END COND_ERROR
%token IN BANG TIME TIMEOPT
@@ -350,6 +350,7 @@ static REDIRECTEE redir;
%type <command> arith_command
%type <command> cond_command
%type <command> arith_for_command
%type <command> coproc
%type <command> function_def function_body if_command elif_clause subshell
%type <redirect> redirection redirection_list
%type <element> simple_command_element
@@ -625,6 +626,8 @@ command: simple_command
}
| function_def
{ $$ = $1; }
| coproc
{ $$ = $1; }
;
shell_command: for_command
@@ -814,6 +817,57 @@ subshell: '(' compound_list ')'
}
;
coproc: COPROC shell_command
{
$$ = make_coproc_command ("COPROC", $2);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC shell_command redirection_list
{
COMMAND *tc;
tc = $2;
if (tc->redirects)
{
register REDIRECT *t;
for (t = tc->redirects; t->next; t = t->next)
;
t->next = $3;
}
else
tc->redirects = $3;
$$ = make_coproc_command ("COPROC", $2);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC WORD shell_command
{
$$ = make_coproc_command ($2->word, $3);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC WORD shell_command redirection_list
{
COMMAND *tc;
tc = $3;
if (tc->redirects)
{
register REDIRECT *t;
for (t = tc->redirects; t->next; t = t->next)
;
t->next = $4;
}
else
tc->redirects = $4;
$$ = make_coproc_command ($2->word, $3);
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
| COPROC simple_command
{
$$ = make_coproc_command ("COPROC", clean_simple_command ($2));
$$->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL;
}
;
if_command: IF compound_list THEN compound_list FI
{ $$ = make_if_command ($2, $4, (COMMAND *)NULL); }
| IF compound_list THEN compound_list ELSE compound_list FI
@@ -1854,6 +1908,9 @@ STRING_INT_ALIST word_token_alist[] = {
#if defined (COND_COMMAND)
{ "[[", COND_START },
{ "]]", COND_END },
#endif
#if defined (COPROCESS_SUPPORT)
{ "coproc", COPROC },
#endif
{ (char *)NULL, 0}
};
@@ -2285,6 +2342,7 @@ yylex ()
if ((parser_state & PST_EOFTOKEN) && current_token == shell_eof_token)
{
itrace("shell_eof_token == ')'; setting current_token == yacc_EOF");
current_token = yacc_EOF;
if (bash_input.type == st_string)
rewind_input_string ();
@@ -4142,8 +4200,12 @@ read_token_word (character)
}
#if defined (ARRAY_VARS)
/* Identify possible array subscript assignment; match [...] */
else if MBTEST(character == '[' && token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) /* ] */
/* Identify possible array subscript assignment; match [...]. If
parser_state&PST_COMPASSIGN, we need to parse [sub]=words treating
`sub' as if it were enclosed in double quotes. */
else if MBTEST(character == '[' && /* ] */
((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) ||
(token_index == 0 && (parser_state&PST_COMPASSIGN))))
{
ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
if (ttok == &matched_pair_error)
@@ -4360,11 +4422,16 @@ reserved_word_acceptable (toksym)
case THEN:
case TIME:
case TIMEOPT:
case COPROC:
case UNTIL:
case WHILE:
case 0:
return 1;
default:
#if defined (COPROCESS_SUPPORT)
if (last_read_token == WORD && token_before_that == COPROC)
return 1;
#endif
return 0;
}
}
+6
View File
@@ -284,6 +284,12 @@ make_command_string_internal (command)
cprintf (" )");
break;
case cm_coproc:
cprintf ("coproc %s ", command->value.Coproc->name);
skip_this_indent++;
make_command_string_internal (command->value.Coproc->command);
break;
default:
command_error ("print_command", CMDERR_BADTYPE, command->type, 0);
break;
+6 -1
View File
@@ -609,7 +609,12 @@ print_case_clauses (clauses)
indentation += indentation_amount;
make_command_string_internal (clauses->action);
indentation -= indentation_amount;
newline (";;");
if (clauses->flags & CASEPAT_FALLTHROUGH)
newline (";&");
else if (clauses->flags & CASEPAT_TESTNEXT)
newline (";;&");
else
newline (";;");
clauses = clauses->next;
}
indentation -= indentation_amount;
+10 -1
View File
@@ -936,7 +936,12 @@ do_redirection_internal (redirect, flags)
/* dup-and-close redirection */
if (ri == r_move_input || ri == r_move_output)
close (redir_fd);
{
close (redir_fd);
#if defined (COPROCESS_SUPPORT)
coproc_fdchk (&sh_coproc, redir_fd); /* XXX - loses coproc fds */
#endif
}
}
break;
@@ -946,6 +951,10 @@ do_redirection_internal (redirect, flags)
if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
add_undo_redirect (redirector, ri);
#if defined (COPROCESS_SUPPORT)
coproc_fdchk (&sh_coproc, redirector);
#endif
#if defined (BUFFERED_INPUT)
check_bash_input (redirector);
close_buffered_fd (redirector);
+15 -3
View File
@@ -1,6 +1,6 @@
/* redir.c -- Functions to perform input and output redirection. */
/* Copyright (C) 1997-2007 Free Software Foundation, Inc.
/* Copyright (C) 1997-2008 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -217,6 +217,7 @@ expandable_redirection_filename (redirect)
case r_input_direction:
case r_inputa_direction:
case r_err_and_out:
case r_append_err_and_out:
case r_input_output:
case r_output_force:
case r_duplicating_input_word:
@@ -724,6 +725,7 @@ do_redirection_internal (redirect, flags)
case r_input_direction:
case r_inputa_direction:
case r_err_and_out: /* command &>filename */
case r_append_err_and_out: /* command &>> filename */
case r_input_output:
case r_output_force:
if (posixly_correct && interactive_shell == 0)
@@ -821,7 +823,7 @@ do_redirection_internal (redirect, flags)
/* If we are hacking both stdout and stderr, do the stderr
redirection here. */
if (ri == r_err_and_out)
if (ri == r_err_and_out || ri == r_append_err_and_out)
{
if (flags & RX_ACTIVE)
{
@@ -934,7 +936,12 @@ do_redirection_internal (redirect, flags)
/* dup-and-close redirection */
if (ri == r_move_input || ri == r_move_output)
close (redir_fd);
{
close (redir_fd);
#if defined (COPROCESS_SUPPORT)
coproc_fdchk (&sh_coproc, redir_fd);
#endif
}
}
break;
@@ -944,6 +951,10 @@ do_redirection_internal (redirect, flags)
if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
add_undo_redirect (redirector, ri);
#if defined (COPROCESS_SUPPORT)
coproc_fdchk (&sh_coproc, redirector);
#endif
#if defined (BUFFERED_INPUT)
check_bash_input (redirector);
close_buffered_fd (redirector);
@@ -1081,6 +1092,7 @@ stdin_redirection (ri, redirector)
case r_appending_to:
case r_duplicating_output:
case r_err_and_out:
case r_append_err_and_out:
case r_output_force:
case r_duplicating_output_word:
return (0);
+5 -1
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
/* Copyright (C) 1987-2008 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -898,6 +898,10 @@ exit_shell (s)
maybe_save_shell_history ();
#endif /* HISTORY */
#if defined (COPROCESS_SUPPORT)
coproc_dispose (&sh_coproc);
#endif
#if defined (JOB_CONTROL)
/* If the user has run `shopt -s huponexit', hangup all jobs when we exit
an interactive login shell. ksh does this unconditionally. */
+1 -1
View File
@@ -1747,7 +1747,7 @@ shell_reinitialize ()
reinit_special_variables ();
#if defined (READLINE)
bashline_reset ();
bashline_reinitialize ();
#endif
shell_reinitialized = 1;
+218 -20
View File
@@ -199,10 +199,8 @@ static WORD_LIST *expand_string_leave_quoted __P((char *, int));
static WORD_LIST *expand_string_for_rhs __P((char *, int, int *, int *));
static WORD_LIST *list_quote_escapes __P((WORD_LIST *));
static char *dequote_escapes __P((char *));
static char *make_quoted_char __P((int));
static WORD_LIST *quote_list __P((WORD_LIST *));
static char *remove_quoted_nulls __P((char *));
static int unquoted_substring __P((char *, char *));
static int unquoted_member __P((int, char *));
@@ -269,7 +267,7 @@ static int valid_length_expression __P((char *));
static intmax_t parameter_brace_expand_length __P((char *));
static char *skiparith __P((char *, int));
static int verify_substring_values __P((char *, char *, int, intmax_t *, intmax_t *));
static int verify_substring_values __P((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *));
static int get_var_and_type __P((char *, char *, int, SHELL_VAR **, char **));
static char *mb_substring __P((char *, int, int));
static char *parameter_brace_substring __P((char *, char *, char *, int));
@@ -278,6 +276,9 @@ static char *pos_params_pat_subst __P((char *, char *, char *, int));
static char *parameter_brace_patsub __P((char *, char *, char *, int));
static char *pos_params_casemod __P((char *, char *, int, int));
static char *parameter_brace_casemod __P((char *, char *, int, char *, int));
static WORD_DESC *parameter_brace_expand __P((char *, int *, int, int *, int *));
static WORD_DESC *param_expand __P((char *, int *, int, int *, int *, int *, int *, int));
@@ -2341,16 +2342,19 @@ do_compound_assignment (name, value, flags)
int flags;
{
SHELL_VAR *v;
int mklocal;
int mklocal, mkassoc;
WORD_LIST *list;
mklocal = flags & ASS_MKLOCAL;
mkassoc = flags & ASS_MKASSOC;
if (mklocal && variable_context)
{
v = find_variable (name);
list = expand_compound_array_assignment (v, value, flags);
if (v == 0 || array_p (v) == 0 || v->context != variable_context)
if (mkassoc)
v = make_local_assoc_variable (name);
else if (v == 0 || (array_p (v) == 0 && assoc_p (v) == 0) || v->context != variable_context)
v = make_local_array_variable (name);
assign_compound_array_list (v, list, flags);
}
@@ -2454,6 +2458,8 @@ do_assignment_internal (word, expand)
{
if (word->flags & W_ASSIGNARG)
aflags |= ASS_MKLOCAL;
if (word->flags & W_ASSIGNASSOC)
aflags |= ASS_MKASSOC;
entry = do_compound_assignment (name, value, aflags);
}
else
@@ -2473,10 +2479,11 @@ do_assignment_internal (word, expand)
}
else
retval = 1;
ASSIGN_RETURN (retval);
if (entry && retval != 0)
if (entry && retval != 0 && noassign_p (entry) == 0)
VUNSETATTR (entry, att_invisible);
ASSIGN_RETURN (retval);
#else
if (entry)
VUNSETATTR (entry, att_invisible);
@@ -3120,7 +3127,7 @@ list_quote_escapes (list)
characters.
Also used by parts of the pattern substitution code. */
static char *
char *
dequote_escapes (string)
char *string;
{
@@ -3322,7 +3329,7 @@ remove_quoted_escapes (string)
of how expand_word_internal works. remove_quoted_nulls () turns
STRING into an empty string iff it only consists of a quoted null,
and removes all unquoted CTLNUL characters. */
static char *
char *
remove_quoted_nulls (string)
char *string;
{
@@ -4966,7 +4973,7 @@ array_length_reference (s)
if (assoc_p (var))
{
t[len - 1] = '\0';
akey = expand_assignment_string_to_string (t, 0); /* [ */
akey = expand_assignment_string_to_string (t, 0); /* [ */
t[len - 1] = ']';
if (akey == 0 || *akey == 0)
{
@@ -5504,7 +5511,8 @@ skiparith (substr, delim)
Return value is 1 if both values were OK, 0 if there was a problem
with an invalid expression, or -1 if the values were out of range. */
static int
verify_substring_values (value, substr, vtype, e1p, e2p)
verify_substring_values (v, value, substr, vtype, e1p, e2p)
SHELL_VAR *v;
char *value, *substr;
int vtype;
intmax_t *e1p, *e2p;
@@ -5514,6 +5522,7 @@ verify_substring_values (value, substr, vtype, e1p, e2p)
int expok;
#if defined (ARRAY_VARS)
ARRAY *a;
HASH_TABLE *h;
#endif
/* duplicate behavior of strchr(3) */
@@ -5543,10 +5552,19 @@ verify_substring_values (value, substr, vtype, e1p, e2p)
break;
#if defined (ARRAY_VARS)
case VT_ARRAYVAR:
a = (ARRAY *)value;
/* For arrays, the first value deals with array indices. Negative
offsets count from one past the array's maximum index. */
len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */
offsets count from one past the array's maximum index. Associative
arrays treat the number of elements as the maximum index. */
if (assoc_p (v))
{
h = assoc_cell (v);
len = assoc_num_elements (h) + (*e1p < 0);
}
else
{
a = (ARRAY *)value;
len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */
}
break;
#endif
}
@@ -5750,7 +5768,7 @@ parameter_brace_substring (varname, value, substr, quoted)
starsub = vtype & VT_STARSUB;
vtype &= ~VT_STARSUB;
r = verify_substring_values (val, substr, vtype, &e1, &e2);
r = verify_substring_values (v, val, substr, vtype, &e1, &e2);
this_command_name = oname;
if (r <= 0)
return ((r == 0) ? &expand_param_error : (char *)NULL);
@@ -5787,7 +5805,9 @@ parameter_brace_substring (varname, value, substr, quoted)
#if defined (ARRAY_VARS)
case VT_ARRAYVAR:
if (assoc_p (v))
tt = (char *)NULL;
/* we convert to list and take first e2 elements starting at e1th
element -- officially undefined for now */
temp = assoc_subrange (assoc_cell (v), e1, e2, starsub, quoted);
else
/* We want E2 to be the number of elements desired (arrays can be sparse,
so verify_substring_values just returns the numbers specified and we
@@ -6083,6 +6103,149 @@ parameter_brace_patsub (varname, value, patsub, quoted)
return temp;
}
/****************************************************************/
/* */
/* Functions to perform case modification on variable values */
/* */
/****************************************************************/
/* Do case modification on the positional parameters. */
static char *
pos_params_modcase (string, pat, modop, mflags)
char *string, *pat;
int modop;
int mflags;
{
WORD_LIST *save, *params;
WORD_DESC *w;
char *ret;
int pchar, qflags;
save = params = list_rest_of_args ();
if (save == 0)
return ((char *)NULL);
for ( ; params; params = params->next)
{
ret = sh_modcase (params->word->word, pat, modop);
w = alloc_word_desc ();
w->word = ret ? ret : savestring ("");
dispose_word (params->word);
params->word = w;
}
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
ret = string_list_pos_params (pchar, save, qflags);
dispose_words (save);
return (ret);
}
/* Perform case modification on VALUE, which is the expansion of
VARNAME. MODSPEC is an expression supplying the type of modification
to perform. QUOTED is a flags word containing the type of quoting
currently in effect. */
static char *
parameter_brace_casemod (varname, value, modspec, patspec, quoted)
char *varname, *value;
int modspec;
char *patspec;
int quoted;
{
int vtype, starsub, modop, mflags, x;
char *val, *temp, *pat, *p, *lpat, *tt;
SHELL_VAR *v;
if (value == 0)
return ((char *)NULL);
this_command_name = varname;
vtype = get_var_and_type (varname, value, quoted, &v, &val);
if (vtype == -1)
return ((char *)NULL);
starsub = vtype & VT_STARSUB;
vtype &= ~VT_STARSUB;
modop = 0;
mflags = 0;
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
mflags |= MATCH_QUOTED;
if (starsub)
mflags |= MATCH_STARSUB;
p = patspec;
if (modspec == '^')
{
x = p && p[0] == modspec;
modop = x ? CASE_UPPER : CASE_CAPITALIZE;
p += x;
}
else if (modspec == ',')
{
x = p && p[0] == modspec;
modop = x ? CASE_LOWER : CASE_UNCAP;
p += x;
}
else if (modspec == '~')
{
x = p && p[0] == modspec;
modop = x ? CASE_TOGGLEALL : CASE_TOGGLE;
p += x;
}
lpat = p ? savestring (p) : 0;
/* Perform the same expansions on the pattern as performed by the
pattern removal expansions. FOR LATER */
pat = lpat ? getpattern (lpat, quoted, 1) : 0;
/* OK, now we do the case modification. */
switch (vtype)
{
case VT_VARIABLE:
case VT_ARRAYMEMBER:
temp = sh_modcase (val, pat, modop);
if (vtype == VT_VARIABLE)
FREE (val);
if (temp)
{
tt = (mflags & MATCH_QUOTED) ? quote_string (temp) : quote_escapes (temp);
free (temp);
temp = tt;
}
break;
case VT_POSPARMS:
temp = pos_params_modcase (val, pat, modop, mflags);
if (temp && (mflags & MATCH_QUOTED) == 0)
{
tt = quote_escapes (temp);
free (temp);
temp = tt;
}
break;
#if defined (ARRAY_VARS)
case VT_ARRAYVAR:
temp = assoc_p (v) ? assoc_modcase (assoc_cell (v), pat, modop, mflags)
: array_modcase (array_cell (v), pat, modop, mflags);
/* Don't call quote_escapes; array_modcase calls array_quote_escapes
as appropriate before adding the space separators; ditto for
assoc_modcase. */
break;
#endif
}
FREE (pat);
free (lpat);
return temp;
}
/* Check for unbalanced parens in S, which is the contents of $(( ... )). If
any occur, this must be a nested command substitution, so return 0.
Otherwise, return 1. A valid arithmetic expression must always have a
@@ -6140,22 +6303,22 @@ chk_arithsub (s, len)
/* */
/****************************************************************/
/* ${[#][!]name[[:]#[#]%[%]-=?+[word][:e1[:e2]]]} */
/* ${[#][!]name[[:][^[^]][,[,]]#[#]%[%]-=?+[word][:e1[:e2]]]} */
static WORD_DESC *
parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_dollar_at)
char *string;
int *indexp, quoted, *quoted_dollar_atp, *contains_dollar_at;
{
int check_nullness, var_is_set, var_is_null, var_is_special;
int want_substring, want_indir, want_patsub;
int want_substring, want_indir, want_patsub, want_casemod;
char *name, *value, *temp, *temp1;
WORD_DESC *tdesc, *ret;
int t_index, sindex, c, tflag;
int t_index, sindex, c, tflag, modspec;
intmax_t number;
temp = temp1 = value = (char *)NULL;
var_is_set = var_is_null = var_is_special = check_nullness = 0;
want_substring = want_indir = want_patsub = 0;
want_substring = want_indir = want_patsub = want_casemod = 0;
sindex = *indexp;
t_index = ++sindex;
@@ -6163,7 +6326,17 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
if (string[t_index] == '#' && legal_variable_starter (string[t_index+1])) /* {{ */
name = string_extract (string, &t_index, "}", SX_VARNAME);
else
#if defined (CASEMOD_EXPANSIONS)
/* To enable case-toggling expansions using the `~' operator character
change the 1 to 0. */
# if defined (CASEMOD_CAPCASE)
name = string_extract (string, &t_index, "#%^,~:-=?+/}", SX_VARNAME);
# else
name = string_extract (string, &t_index, "#%^,:-=?+/}", SX_VARNAME);
# endif /* CASEMOD_CAPCASE */
#else
name = string_extract (string, &t_index, "#%:-=?+/}", SX_VARNAME);
#endif /* CASEMOD_EXPANSIONS */
ret = 0;
tflag = 0;
@@ -6217,6 +6390,13 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
want_substring = 1;
else if (c == '/' && string[sindex] != RBRACE)
want_patsub = 1;
#if defined (CASEMOD_EXPANSIONS)
else if (c == '^' || c == ',' || c == '~')
{
modspec = c;
want_casemod = 1;
}
#endif
/* Catch the valid and invalid brace expressions that made it through the
tests above. */
@@ -6437,6 +6617,24 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
ret->word = temp1;
return ret;
}
#if defined (CASEMOD_EXPANSIONS)
else if (want_casemod)
{
temp1 = parameter_brace_casemod (name, temp, modspec, value, quoted);
FREE (name);
FREE (value);
FREE (temp);
if (temp1 == &expand_param_error)
return (&expand_wdesc_error);
else if (temp1 == &expand_param_fatal)
return (&expand_wdesc_fatal);
ret = alloc_word_desc ();
ret->word = temp1;
return ret;
}
#endif
/* Do the right thing based on which character ended the variable name. */
switch (c)
+6
View File
@@ -175,6 +175,9 @@ extern char *expand_arith_string __P((char *, int));
/* De-quote quoted characters in STRING. */
extern char *dequote_string __P((char *));
/* De-quote CTLESC-escaped CTLESC or CTLNUL characters in STRING. */
extern char *dequote_escapes __P((char *));
/* De-quote quoted characters in each word in LIST. */
extern WORD_LIST *dequote_list __P((WORD_LIST *));
@@ -202,6 +205,9 @@ extern char *quote_escapes __P((char *));
/* And remove such quoted special characters. */
extern char *remove_quoted_escapes __P((char *));
/* Remove CTLNUL characters from STRING unless they are quoted with CTLESC. */
extern char *remove_quoted_nulls __P((char *));
/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the
backslash quoting rules for within double quotes. */
extern char *string_quote_removal __P((char *, int));
+25
View File
@@ -274,3 +274,28 @@ rdholz
rdho
argv[1] = <fooq//barq/>
argv[1] = <fooq>
argv[2] = <>
argv[3] = <barq>
argv[4] = <>
argv[1] = <foo!//bar!/>
argv[1] = <foo!>
argv[2] = <>
argv[3] = <bar!>
argv[4] = <>
argv[1] = <ooq//arq/>
argv[1] = <ooq>
argv[2] = <>
argv[3] = <arq>
argv[4] = <>
argv[1] = <Fooq//Barq/>
argv[1] = <Fooq>
argv[2] = <>
argv[3] = <Barq>
argv[4] = <>
argv[1] = <FOOQ//BARQ/>
argv[1] = <FOOQ>
argv[2] = <>
argv[3] = <BARQ>
argv[4] = <>
+2
View File
@@ -380,3 +380,5 @@ ${THIS_SH} ./array5.sub
# tests for post-bash-3.2 problems, most fixed in bash-3.2 patches
${THIS_SH} ./array6.sub
${THIS_SH} ./array7.sub
${THIS_SH} ./array8.sub
+23
View File
@@ -0,0 +1,23 @@
IFS=/
declare -a i
i[0]=fooq
i[1]=
i[2]=barq
i[3]=
recho "${i[*]:0}"
recho "${i[@]:0}"
recho "${i[*]/q/!}"
recho "${i[@]/q/!}"
recho "${i[*]#?}"
recho "${i[@]#?}"
# Need to complete this with case-modifying expansion examples
recho "${i[*]^?}"
recho "${i[@]^?}"
recho "${i[*]^^?}"
recho "${i[@]^^?}"
+30
View File
@@ -99,3 +99,33 @@ argv[1] = </bin/bash --login -o posix>
argv[2] = </usr/sbin/foo>
argv[3] = <cd /blat ; echo $PWD>
argv[4] = </usr/local/bin/qux -l>
outside: outside
declare -A BASH_ALIASES='()'
declare -A BASH_CMDS='()'
declare -A afoo='([six]="six" [foo bar]="foo quux" )'
argv[1] = <inside:>
argv[2] = <six>
argv[3] = <foo quux>
outside 2: outside
argv[1] = <fooq//barq/>
argv[1] = <fooq>
argv[1] = <foo!//bar!/>
argv[1] = <foo!>
argv[2] = <>
argv[3] = <bar!>
argv[4] = <>
argv[1] = <ooq//arq/>
argv[1] = <ooq>
argv[2] = <>
argv[3] = <arq>
argv[4] = <>
argv[1] = <Fooq//Barq/>
argv[1] = <Fooq>
argv[2] = <>
argv[3] = <Barq>
argv[4] = <>
argv[1] = <FOOQ//BARQ/>
argv[1] = <FOOQ>
argv[2] = <>
argv[3] = <BARQ>
argv[4] = <>
+4
View File
@@ -167,3 +167,7 @@ zecho "${xpath[@]//[\/]/\\}"
${THIS_SH} ./assoc1.sub
${THIS_SH} ./assoc2.sub
${THIS_SH} ./assoc3.sub
${THIS_SH} ./assoc4.sub
+15
View File
@@ -0,0 +1,15 @@
foo()
{
declare -A afoo=([six]="six" [foo bar]="foo quux")
declare -A
recho inside: "${afoo[@]}"
}
declare -A afoo=([main]=outside)
echo outside: "${afoo[@]}"
foo
echo outside 2: "${afoo[@]}"
+22
View File
@@ -0,0 +1,22 @@
IFS=/
declare -A i
i[0]=fooq
i[1]=
i[2]=barq
i[3]=
recho "${i[*]:0}"
recho "${i[@]:0}"
recho "${i[*]/q/!}"
recho "${i[@]/q/!}"
recho "${i[*]#?}"
recho "${i[@]#?}"
# Need to complete this with case-modifying expansion examples
recho "${i[*]^?}"
recho "${i[@]^?}"
recho "${i[*]^^?}"
recho "${i[@]^^?}"
+35
View File
@@ -0,0 +1,35 @@
Acknowledgement
ACKNOWLEDGEMENT
Oenophile
OEnOphIlE
aCKNOWLEDGEMENT
acknowledgement
oENOPHILE
oENOPHILE
oeNoPHiLe
Acknowledgement Oenophile
AcknOwlEdgEmEnt OEnOphIlE
aCKNOWLEDGEMENT oENOPHILE
aCKNoWLeDGeMeNT oeNoPHiLe
aCKNOWLEDGEMENT oENOPHILE
acknowledgement oenophile
Acknowledgement Oenophile
ACKNOWLEDGEMENT OENOPHILE
Acknowledgement Oenophile
AcknOwlEdgEmEnt OEnOphIlE
oENOPHILE aCKNOWLEDGEMENT
oenophile acknowledgement
oENOPHILE aCKNOWLEDGEMENT
oeNoPHiLe aCKNoWLeDGeMeNT
Acknowledgement Oenophile
ACKNOWLEDGEMENT OENOPHILE
acknowledgement oenophile
ackNowLEdgEmENT oENophiLE
acknowledgement oenophile
ackNowLEdgEmENT oENophiLE
ackNowLEdgEmENT oENophiLE
acknowledgement oenophile
ackNowLEdgEmENT oENophiLE
acknowledgement oenophile
Acknowledgement Oenophile
ACKNOWLEDGEMENT OENOPHILE
+72
View File
@@ -0,0 +1,72 @@
S1=acknowledgement
S2=oenophile
echo ${S1^}
echo ${S1^^}
echo ${S2^[aeiou]}
echo ${S2^^[aeiou]}
U1=${S1^^}
U2=${S2^^}
echo ${U1,}
echo ${U1,,}
echo ${U2,}
echo ${U2,[AEIOU]}
echo ${U2,,[AEIOU]}
A1=( $S1 $S2 )
echo ${A1[@]^[aeiou]}
echo ${A1[@]^^[aeiou]}
A2=( $U1 $U2 )
echo ${A2[@],[AEIOU]}
echo ${A2[@],,[AEIOU]}
echo ${A2[@],?}
echo ${A2[@],,?}
declare -A AA1 AA2
AA1[ack]=$S1
AA1[oen]=$S2
echo ${AA1[@]^}
echo ${AA1[@]^^}
echo ${AA1[@]^[aeiou]}
echo ${AA1[@]^^[aeiou]}
AA2[ACK]=$U1
AA2[OEN]=$U2
echo ${AA2[@],}
echo ${AA2[@],,}
echo ${AA2[@],[AEIOU]}
echo ${AA2[@],,[AEIOU]}
set -- $S1 $S2
echo ${@^}
echo ${@^^}
echo ${S1^[rstlne]} ${S2^[rstlne]}
echo ${S1^^[rstlne]} ${S2^^[rstlne]}
echo ${@^[rstlne]}
echo ${@^^[rstlne]}
echo ${S1,[rstlne]} ${S2,[rstlne]}
echo ${S1,,[rstlne]} ${S2,,[rstlne]}
echo ${@,[rstlne]}
echo ${@,,[rstlne]}
echo ${@^?}
echo ${@^^?}
+7
View File
@@ -0,0 +1,7 @@
./comsub-eof0.sub: line 1: unexpected EOF while looking for matching `)'
./comsub-eof0.sub: line 5: syntax error: unexpected end of file
hi
./comsub-eof2.sub: line 2: warning: here-document at line 1 delimited by end-of-file (wanted `EOF')
hi
./comsub-eof3.sub: line 1: unexpected EOF while looking for matching `)'
./comsub-eof3.sub: line 5: syntax error: unexpected end of file
+7
View File
@@ -0,0 +1,7 @@
${THIS_SH} ./comsub-eof0.sub
${THIS_SH} ./comsub-eof1.sub
${THIS_SH} ./comsub-eof2.sub
${THIS_SH} ./comsub-eof3.sub
+4
View File
@@ -0,0 +1,4 @@
foo=$(cat <<EOF
hi
EOF )
echo $foo
+10
View File
@@ -0,0 +1,10 @@
foo=$(cat <<EOF
hi
EOF )
echo $foo
foo=`cat <<EOF
hi
EOF`
echo $foo
+4
View File
@@ -0,0 +1,4 @@
foo=`cat <<EOF
hi
EOF`
echo $foo
+10
View File
@@ -0,0 +1,10 @@
foo=$(cat <<EOF
hi
EOF )
echo $foo
foo=`cat <<EOF
hi
EOF`
echo $foo
+2
View File
@@ -0,0 +1,2 @@
cat <<EOF
hi
+4
View File
@@ -0,0 +1,4 @@
foo=$(cat <<EOF
hi
)
echo $foo
+14
View File
@@ -0,0 +1,14 @@
18530
63 60
a b c
18532
63 60
flop
./coproc.tests: line 22: 18532 Terminated coproc REFLECT { cat -; }
18534
63 60
FOO
63 60
root
daemon
-1 -1
+45
View File
@@ -0,0 +1,45 @@
coproc { echo a b c; sleep 2; }
echo $COPROC_PID
echo ${COPROC[@]}
read LINE <&${COPROC[0]}
echo $LINE
wait $COPROC_PID
coproc REFLECT { cat - ; }
echo $REFLECT_PID
echo ${REFLECT[@]}
echo flop >&${REFLECT[1]}
read LINE <&${REFLECT[0]}
echo $LINE
kill $REFLECT_PID
wait $REFLECT_PID
coproc tr -u 'a-z' 'A-Z'
echo $COPROC_PID
echo ${COPROC[@]}
echo foo >&${COPROC[1]}
read <&${COPROC[0]}
echo $REPLY
echo ${COPROC[@]}
cat /etc/passwd | grep root | awk -F: '{print $1;}'
exec 4<&${COPROC[0]}-
exec >&${COPROC[1]}-
echo ${COPROC[@]}
read foo <&4
echo $foo >&2
exit 0

Some files were not shown because too many files have changed in this diff Show More