mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-28 07:59:50 +02:00
commit bash-20131025 snapshot
This commit is contained in:
@@ -5309,3 +5309,37 @@ aclocal.m4
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- document new -@ option to cd builtin
|
||||
|
||||
10/28
|
||||
-----
|
||||
lib/glob/{{gmisc,glob}.c,glob.h}
|
||||
- extglob_pattern renamed to extglob_pattern_p, declared in glob.h
|
||||
|
||||
subst.c
|
||||
- expand_word_internal: typo fix: case to fix " $@\ " bug in bash-4.2
|
||||
had a typo (& isexp instead of &&)
|
||||
|
||||
10/29
|
||||
-----
|
||||
input.c
|
||||
- getc_with_restart: make sure local_index and local_bufused are
|
||||
reset to 0 before returning EOF, in case we are running an interactive
|
||||
shell without line editing and ignoreeof is set. Report and fix
|
||||
from Yong Zhang <yong.zhang@windriver.com>
|
||||
|
||||
lib/readline/search.c
|
||||
- _rl_nsearch_init: take out extra third argument to rl_message; it
|
||||
only matches prototype (and maybe format) in cases where
|
||||
PREFER_STDARG and USE_VARARGS are both undefined, which is rare
|
||||
|
||||
10/31
|
||||
-----
|
||||
subst.c
|
||||
- process_substitute: when opening the named pipe in the child, open
|
||||
without O_NONBLOCK to avoid race conditions. Happens often on AIX.
|
||||
Bug report and fix from Michael Haubenwallner
|
||||
<michael.haubenwallner@salomon.at>
|
||||
|
||||
builtins/ulimit.def
|
||||
- RLIMIT_NTHR: if RLIMIT_PTHREAD is not defined, but RLIMIT_NTHR is,
|
||||
use RLIMIT_NTHR (NetBSD)
|
||||
|
||||
@@ -5306,3 +5306,36 @@ aclocal.m4
|
||||
- BASH_CHECK_MULTIBYTE: check for wcwidth being broken with unicode
|
||||
combining characters needs a value to use when cross-compiling.
|
||||
Bug report from Bert Sutherland <bertsutherland@gmail.com>
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- document new -@ option to cd builtin
|
||||
|
||||
10/28
|
||||
-----
|
||||
lib/glob/{{gmisc,glob}.c,glob.h}
|
||||
- extglob_pattern renamed to extglob_pattern_p, declared in glob.h
|
||||
|
||||
subst.c
|
||||
- expand_word_internal: typo fix: case to fix " $@\ " bug in bash-4.2
|
||||
had a typo (& isexp instead of &&)
|
||||
|
||||
10/29
|
||||
-----
|
||||
input.c
|
||||
- getc_with_restart: make sure local_index and local_bufused are
|
||||
reset to 0 before returning EOF, in case we are running an interactive
|
||||
shell without line editing and ignoreeof is set. Report and fix
|
||||
from Yong Zhang <yong.zhang@windriver.com>
|
||||
|
||||
lib/readline/search.c
|
||||
- _rl_nsearch_init: take out extra third argument to rl_message; it
|
||||
only matches prototype (and maybe format) in cases where
|
||||
PREFER_STDARG and USE_VARARGS are both undefined, which is rare
|
||||
|
||||
10/31
|
||||
-----
|
||||
subst.c
|
||||
- process_substitute: when opening the named pipe in the child, open
|
||||
without O_NONBLOCK to avoid race conditions. Happens often on AIX.
|
||||
Bug report and fix from Michael Haubenwallner
|
||||
<michael.haubenwallner@salomon.at>
|
||||
|
||||
@@ -11237,10 +11237,7 @@ if ${bash_cv_wcwidth_broken+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot run test program while cross compiling
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
bash_cv_wcwidth_broken=no
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
+19
-19
@@ -15,57 +15,57 @@
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'AC_INIT' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AM_NLS' => 1,
|
||||
'AC_FC_PP_DEFINE' => 1,
|
||||
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AM_PROG_CXX_C_O' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_AM_COND_ENDIF' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AM_PROG_MOC' => 1,
|
||||
'AC_CONFIG_FILES' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'include' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'AC_LIBSOURCE' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AC_FC_FREEFORM' => 1,
|
||||
'AC_FC_PP_SRCEXT' => 1,
|
||||
'AH_OUTPUT' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'AC_FC_PP_SRCEXT' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'sinclude' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AC_CONFIG_HEADERS' => 1,
|
||||
'AC_DEFINE_TRACE_LITERAL' => 1,
|
||||
'AM_POT_TOOLS' => 1,
|
||||
|
||||
@@ -1882,13 +1882,6 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2764: AC_TRY_RUN is
|
||||
../../lib/autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from...
|
||||
aclocal.m4:1689: BASH_CHECK_MULTIBYTE is expanded from...
|
||||
configure.ac:849: the top level])
|
||||
m4trace:configure.ac:849: -1- _m4_warn([cross], [AC_RUN_IFELSE called without default to allow cross compiling], [../../lib/autoconf/general.m4:2748: AC_RUN_IFELSE is expanded from...
|
||||
../../lib/autoconf/general.m4:2764: AC_TRY_RUN is expanded from...
|
||||
../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
|
||||
../../lib/autoconf/general.m4:2031: AC_CACHE_VAL is expanded from...
|
||||
../../lib/autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from...
|
||||
aclocal.m4:1689: BASH_CHECK_MULTIBYTE is expanded from...
|
||||
configure.ac:849: the top level])
|
||||
m4trace:configure.ac:849: -1- AC_DEFINE_TRACE_LITERAL([WCWIDTH_BROKEN])
|
||||
m4trace:configure.ac:849: -1- m4_pattern_allow([^WCWIDTH_BROKEN$])
|
||||
m4trace:configure.ac:849: -1- AH_OUTPUT([WCWIDTH_BROKEN], [/* wcwidth is usually not broken */
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "findcmd.h"
|
||||
#include "pathexp.h"
|
||||
#include "shmbutil.h"
|
||||
#include "trap.h"
|
||||
|
||||
#include "builtins/common.h"
|
||||
|
||||
@@ -4193,6 +4194,7 @@ bash_event_hook ()
|
||||
|
||||
bashline_reset_event_hook ();
|
||||
check_signals_and_traps (); /* XXX */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* READLINE */
|
||||
|
||||
+18
-2
@@ -53,6 +53,7 @@
|
||||
#include "findcmd.h"
|
||||
#include "pathexp.h"
|
||||
#include "shmbutil.h"
|
||||
#include "trap.h"
|
||||
|
||||
#include "builtins/common.h"
|
||||
|
||||
@@ -120,6 +121,7 @@ static int bash_backward_kill_shellword __P((int, int));
|
||||
|
||||
/* Helper functions for Readline. */
|
||||
static char *restore_tilde __P((char *, char *));
|
||||
static char *maybe_restore_tilde __P((char *, char *));
|
||||
|
||||
static char *bash_filename_rewrite_hook __P((char *, int));
|
||||
|
||||
@@ -1946,7 +1948,7 @@ globword:
|
||||
{
|
||||
if (*hint_text == '~' && directory_part)
|
||||
{
|
||||
temp = restore_tilde (val, directory_part);
|
||||
temp = maybe_restore_tilde (val, directory_part);
|
||||
free (val);
|
||||
val = temp;
|
||||
}
|
||||
@@ -2042,7 +2044,7 @@ globword:
|
||||
/* If we performed tilde expansion, restore the original
|
||||
filename. */
|
||||
if (*hint_text == '~')
|
||||
temp = restore_tilde (val, directory_part);
|
||||
temp = maybe_restore_tilde (val, directory_part);
|
||||
else
|
||||
temp = savestring (val);
|
||||
freetemp = 1;
|
||||
@@ -2899,6 +2901,20 @@ restore_tilde (val, directory_part)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static char *
|
||||
maybe_restore_tilde (val, directory_part)
|
||||
char *val, *directory_part;
|
||||
{
|
||||
rl_icppfunc_t *save;
|
||||
char *ret;
|
||||
|
||||
save = (dircomplete_expand == 0) ? save_directory_hook () : (rl_icppfunc_t *)0;
|
||||
ret = restore_tilde (val, directory_part);
|
||||
if (save)
|
||||
restore_directory_hook (save);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Simulate the expansions that will be performed by
|
||||
rl_filename_completion_function. This must be called with the address of
|
||||
a pointer to malloc'd memory. */
|
||||
|
||||
@@ -476,7 +476,7 @@ expand_seqterm (text, tlen)
|
||||
if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))
|
||||
{
|
||||
rhs_t = ST_INT;
|
||||
errno == 0;
|
||||
errno = 0;
|
||||
tr = strtoimax (rhs, &ep, 10);
|
||||
if (errno == ERANGE || (ep && *ep != 0 && *ep != '.'))
|
||||
rhs_t = ST_BAD; /* invalid */
|
||||
|
||||
@@ -0,0 +1,805 @@
|
||||
/* braces.c -- code for doing word expansion in curly braces. */
|
||||
|
||||
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Stuff in curly braces gets expanded before all other shell expansions. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined (BRACE_EXPANSION)
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "bashansi.h"
|
||||
|
||||
#if defined (SHELL)
|
||||
# include "shell.h"
|
||||
#endif /* SHELL */
|
||||
|
||||
#include "typemax.h" /* INTMAX_MIN, INTMAX_MAX */
|
||||
#include "general.h"
|
||||
#include "shmbutil.h"
|
||||
#include "chartypes.h"
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n')
|
||||
|
||||
#define BRACE_SEQ_SPECIFIER ".."
|
||||
|
||||
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
|
||||
extern int last_command_exit_value;
|
||||
|
||||
/* Basic idea:
|
||||
|
||||
Segregate the text into 3 sections: preamble (stuff before an open brace),
|
||||
postamble (stuff after the matching close brace) and amble (stuff after
|
||||
preamble, and before postamble). Expand amble, and then tack on the
|
||||
expansions to preamble. Expand postamble, and tack on the expansions to
|
||||
the result so far.
|
||||
*/
|
||||
|
||||
/* The character which is used to separate arguments. */
|
||||
static const int brace_arg_separator = ',';
|
||||
|
||||
#if defined (__P)
|
||||
static int brace_gobbler __P((char *, size_t, int *, int));
|
||||
static char **expand_amble __P((char *, size_t, int));
|
||||
static char **expand_seqterm __P((char *, size_t));
|
||||
static char **mkseq __P((intmax_t, intmax_t, intmax_t, int, int));
|
||||
static char **array_concat __P((char **, char **));
|
||||
#else
|
||||
static int brace_gobbler ();
|
||||
static char **expand_amble ();
|
||||
static char **expand_seqterm ();
|
||||
static char **mkseq();
|
||||
static char **array_concat ();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void
|
||||
dump_result (a)
|
||||
char **a;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; a[i]; i++)
|
||||
printf ("dump_result: a[%d] = -%s-\n", i, a[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return an array of strings; the brace expansion of TEXT. */
|
||||
char **
|
||||
brace_expand (text)
|
||||
char *text;
|
||||
{
|
||||
register int start;
|
||||
size_t tlen;
|
||||
char *preamble, *postamble, *amble;
|
||||
size_t alen;
|
||||
char **tack, **result;
|
||||
int i, j, c, c1;
|
||||
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
/* Find the text of the preamble. */
|
||||
tlen = strlen (text);
|
||||
i = 0;
|
||||
#if defined (CSH_BRACE_COMPAT)
|
||||
c = brace_gobbler (text, tlen, &i, '{'); /* } */
|
||||
#else
|
||||
/* Make sure that when we exit this loop, c == 0 or text[i] begins a
|
||||
valid brace expansion sequence. */
|
||||
do
|
||||
{
|
||||
c = brace_gobbler (text, tlen, &i, '{'); /* } */
|
||||
c1 = c;
|
||||
/* Verify that c begins a valid brace expansion word. If it doesn't, we
|
||||
go on. Loop stops when there are no more open braces in the word. */
|
||||
if (c)
|
||||
{
|
||||
start = j = i + 1; /* { */
|
||||
c = brace_gobbler (text, tlen, &j, '}');
|
||||
if (c == 0) /* it's not */
|
||||
{
|
||||
i++;
|
||||
c = c1;
|
||||
continue;
|
||||
}
|
||||
else /* it is */
|
||||
{
|
||||
c = c1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (c);
|
||||
#endif /* !CSH_BRACE_COMPAT */
|
||||
|
||||
preamble = (char *)xmalloc (i + 1);
|
||||
if (i > 0)
|
||||
strncpy (preamble, text, i);
|
||||
preamble[i] = '\0';
|
||||
|
||||
result = (char **)xmalloc (2 * sizeof (char *));
|
||||
result[0] = preamble;
|
||||
result[1] = (char *)NULL;
|
||||
|
||||
/* Special case. If we never found an exciting character, then
|
||||
the preamble is all of the text, so just return that. */
|
||||
if (c != '{')
|
||||
return (result);
|
||||
|
||||
/* Find the amble. This is the stuff inside this set of braces. */
|
||||
start = ++i;
|
||||
c = brace_gobbler (text, tlen, &i, '}');
|
||||
|
||||
/* What if there isn't a matching close brace? */
|
||||
if (c == 0)
|
||||
{
|
||||
#if defined (NOTDEF)
|
||||
/* Well, if we found an unquoted BRACE_ARG_SEPARATOR between START
|
||||
and I, then this should be an error. Otherwise, it isn't. */
|
||||
j = start;
|
||||
while (j < i)
|
||||
{
|
||||
if (text[j] == '\\')
|
||||
{
|
||||
j++;
|
||||
ADVANCE_CHAR (text, tlen, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (text[j] == brace_arg_separator)
|
||||
{ /* { */
|
||||
strvec_dispose (result);
|
||||
last_command_exit_value = 1;
|
||||
report_error ("no closing `%c' in %s", '}', text);
|
||||
throw_to_top_level ();
|
||||
}
|
||||
ADVANCE_CHAR (text, tlen, j);
|
||||
}
|
||||
#endif
|
||||
free (preamble); /* Same as result[0]; see initialization. */
|
||||
result[0] = savestring (text);
|
||||
return (result);
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
amble = substring (text, start, i);
|
||||
alen = i - start;
|
||||
#else
|
||||
amble = (char *)xmalloc (1 + (i - start));
|
||||
strncpy (amble, &text[start], (i - start));
|
||||
alen = i - start;
|
||||
amble[alen] = '\0';
|
||||
#endif
|
||||
|
||||
#if defined (SHELL)
|
||||
INITIALIZE_MBSTATE;
|
||||
|
||||
/* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
|
||||
just return without doing any expansion. */
|
||||
j = 0;
|
||||
while (amble[j])
|
||||
{
|
||||
if (amble[j] == '\\')
|
||||
{
|
||||
j++;
|
||||
ADVANCE_CHAR (amble, alen, j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (amble[j] == brace_arg_separator)
|
||||
break;
|
||||
|
||||
ADVANCE_CHAR (amble, alen, j);
|
||||
}
|
||||
|
||||
if (amble[j] == 0)
|
||||
{
|
||||
tack = expand_seqterm (amble, alen);
|
||||
if (tack)
|
||||
goto add_tack;
|
||||
else if (text[i + 1])
|
||||
{
|
||||
/* If the sequence expansion fails (e.g., because the integers
|
||||
overflow), but there is more in the string, try and process
|
||||
the rest of the string, which may contain additional brace
|
||||
expansions. Treat the unexpanded sequence term as a simple
|
||||
string (including the braces). */
|
||||
tack = strvec_create (2);
|
||||
tack[0] = savestring (text+start-1);
|
||||
tack[0][i-start+2] = '\0';
|
||||
tack[1] = (char *)0;
|
||||
goto add_tack;
|
||||
}
|
||||
else
|
||||
{
|
||||
free (amble);
|
||||
free (preamble);
|
||||
result[0] = savestring (text);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
#endif /* SHELL */
|
||||
|
||||
tack = expand_amble (amble, alen, 0);
|
||||
add_tack:
|
||||
result = array_concat (result, tack);
|
||||
free (amble);
|
||||
if (tack != result)
|
||||
strvec_dispose (tack);
|
||||
|
||||
postamble = text + i + 1;
|
||||
|
||||
if (postamble && *postamble)
|
||||
{
|
||||
tack = brace_expand (postamble);
|
||||
result = array_concat (result, tack);
|
||||
if (tack != result)
|
||||
strvec_dispose (tack);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Expand the text found inside of braces. We simply try to split the
|
||||
text at BRACE_ARG_SEPARATORs into separate strings. We then brace
|
||||
expand each slot which needs it, until there are no more slots which
|
||||
need it. */
|
||||
static char **
|
||||
expand_amble (text, tlen, flags)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int flags;
|
||||
{
|
||||
char **result, **partial;
|
||||
char *tem;
|
||||
int start, i, c;
|
||||
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
result = (char **)NULL;
|
||||
|
||||
start = i = 0;
|
||||
c = 1;
|
||||
while (c)
|
||||
{
|
||||
c = brace_gobbler (text, tlen, &i, brace_arg_separator);
|
||||
#if defined (SHELL)
|
||||
tem = substring (text, start, i);
|
||||
#else
|
||||
tem = (char *)xmalloc (1 + (i - start));
|
||||
strncpy (tem, &text[start], (i - start));
|
||||
tem[i- start] = '\0';
|
||||
#endif
|
||||
|
||||
partial = brace_expand (tem);
|
||||
|
||||
if (!result)
|
||||
result = partial;
|
||||
else
|
||||
{
|
||||
register int lr, lp, j;
|
||||
|
||||
lr = strvec_len (result);
|
||||
lp = strvec_len (partial);
|
||||
|
||||
result = strvec_resize (result, lp + lr + 1);
|
||||
|
||||
for (j = 0; j < lp; j++)
|
||||
result[lr + j] = partial[j];
|
||||
|
||||
result[lr + j] = (char *)NULL;
|
||||
free (partial);
|
||||
}
|
||||
free (tem);
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
start = i;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
#define ST_BAD 0
|
||||
#define ST_INT 1
|
||||
#define ST_CHAR 2
|
||||
#define ST_ZINT 3
|
||||
|
||||
#ifndef sh_imaxabs
|
||||
# define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x))
|
||||
#endif
|
||||
|
||||
/* Handle signed arithmetic overflow and underflow. Have to do it this way
|
||||
to avoid compilers optimizing out simpler overflow checks. */
|
||||
|
||||
/* Make sure that a+b does not exceed MAXV or is smaller than MINV (if b < 0).
|
||||
Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
|
||||
#define ADDOVERFLOW(a,b,minv,maxv) \
|
||||
((((a) > 0) && ((b) > ((maxv) - (a)))) || \
|
||||
(((a) < 0) && ((b) < ((minv) - (a)))))
|
||||
|
||||
/* Make sure that a-b is not smaller than MINV or exceeds MAXV (if b < 0).
|
||||
Assumes that b > 0 if a > 0 and b < 0 if a < 0 */
|
||||
#define SUBOVERFLOW(a,b,minv,maxv) \
|
||||
((((b) > 0) && ((a) < ((minv) + (b)))) || \
|
||||
(((b) < 0) && ((a) > ((maxv) + (b)))))
|
||||
|
||||
static char **
|
||||
mkseq (start, end, incr, type, width)
|
||||
intmax_t start, end, incr;
|
||||
int type, width;
|
||||
{
|
||||
intmax_t n, prevn;
|
||||
int i, nelem;
|
||||
char **result, *t;
|
||||
|
||||
if (incr == 0)
|
||||
incr = 1;
|
||||
|
||||
if (start > end && incr > 0)
|
||||
incr = -incr;
|
||||
else if (start < end && incr < 0)
|
||||
{
|
||||
if (incr == INTMAX_MIN) /* Don't use -INTMAX_MIN */
|
||||
return ((char **)NULL);
|
||||
incr = -incr;
|
||||
}
|
||||
|
||||
/* Check that end-start will not overflow INTMAX_MIN, INTMAX_MAX. The +3
|
||||
and -2, not strictly necessary, are there because of the way the number
|
||||
of elements and value passed to strvec_create() are calculated below. */
|
||||
if (SUBOVERFLOW (end, start, INTMAX_MIN+3, INTMAX_MAX-2))
|
||||
return ((char **)NULL);
|
||||
|
||||
prevn = sh_imaxabs (end - start);
|
||||
/* Need to check this way in case INT_MAX == INTMAX_MAX */
|
||||
if (INT_MAX == INTMAX_MAX && (ADDOVERFLOW (prevn, 2, INT_MIN, INT_MAX)))
|
||||
return ((char **)NULL);
|
||||
/* Make sure the assignment to nelem below doesn't end up <= 0 due to
|
||||
intmax_t overflow */
|
||||
else if (ADDOVERFLOW ((prevn/sh_imaxabs(incr)), 1, INTMAX_MIN, INTMAX_MAX))
|
||||
return ((char **)NULL);
|
||||
|
||||
/* XXX - TOFIX: potentially allocating a lot of extra memory if
|
||||
imaxabs(incr) != 1 */
|
||||
/* Instead of a simple nelem = prevn + 1, something like:
|
||||
nelem = (prevn / imaxabs(incr)) + 1;
|
||||
would work */
|
||||
nelem = (prevn / sh_imaxabs(incr)) + 1;
|
||||
if (nelem > INT_MAX - 2) /* Don't overflow int */
|
||||
return ((char **)NULL);
|
||||
result = strvec_create (nelem + 1);
|
||||
|
||||
/* Make sure we go through the loop at least once, so {3..3} prints `3' */
|
||||
i = 0;
|
||||
n = start;
|
||||
do
|
||||
{
|
||||
#if defined (SHELL)
|
||||
QUIT; /* XXX - memory leak here */
|
||||
#endif
|
||||
if (type == ST_INT)
|
||||
result[i++] = itos (n);
|
||||
else if (type == ST_ZINT)
|
||||
{
|
||||
int len, arg;
|
||||
arg = n;
|
||||
len = asprintf (&t, "%0*d", width, arg);
|
||||
result[i++] = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = (char *)xmalloc (2);
|
||||
t[0] = n;
|
||||
t[1] = '\0';
|
||||
result[i++] = t;
|
||||
}
|
||||
|
||||
/* Handle overflow and underflow of n+incr */
|
||||
if (ADDOVERFLOW (n, incr, INTMAX_MIN, INTMAX_MAX))
|
||||
break;
|
||||
|
||||
n += incr;
|
||||
|
||||
if ((incr < 0 && n < end) || (incr > 0 && n > end))
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
|
||||
result[i] = (char *)0;
|
||||
return (result);
|
||||
}
|
||||
|
||||
static char **
|
||||
expand_seqterm (text, tlen)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
{
|
||||
char *t, *lhs, *rhs;
|
||||
int i, lhs_t, rhs_t, lhs_l, rhs_l, width;
|
||||
intmax_t lhs_v, rhs_v, incr;
|
||||
intmax_t tl, tr;
|
||||
char **result, *ep, *oep;
|
||||
|
||||
t = strstr (text, BRACE_SEQ_SPECIFIER);
|
||||
if (t == 0)
|
||||
return ((char **)NULL);
|
||||
|
||||
lhs_l = t - text; /* index of start of BRACE_SEQ_SPECIFIER */
|
||||
lhs = substring (text, 0, lhs_l);
|
||||
rhs = substring (text, lhs_l + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen);
|
||||
|
||||
if (lhs[0] == 0 || rhs[0] == 0)
|
||||
{
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
return ((char **)NULL);
|
||||
}
|
||||
|
||||
/* Now figure out whether LHS and RHS are integers or letters. Both
|
||||
sides have to match. */
|
||||
lhs_t = (legal_number (lhs, &tl)) ? ST_INT :
|
||||
((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);
|
||||
|
||||
/* Decide on rhs and whether or not it looks like the user specified
|
||||
an increment */
|
||||
ep = 0;
|
||||
if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))
|
||||
{
|
||||
rhs_t = ST_INT;
|
||||
errno == 0;
|
||||
tr = strtoimax (rhs, &ep, 10);
|
||||
if (errno == ERANGE || (ep && *ep != 0 && *ep != '.'))
|
||||
rhs_t = ST_BAD; /* invalid */
|
||||
}
|
||||
else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.'))
|
||||
{
|
||||
rhs_t = ST_CHAR;
|
||||
ep = rhs + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rhs_t = ST_BAD;
|
||||
ep = 0;
|
||||
}
|
||||
|
||||
incr = 1;
|
||||
if (rhs_t != ST_BAD)
|
||||
{
|
||||
oep = ep;
|
||||
errno = 0;
|
||||
if (ep && *ep == '.' && ep[1] == '.' && ep[2])
|
||||
incr = strtoimax (ep + 2, &ep, 10);
|
||||
if (*ep != 0 || errno == ERANGE)
|
||||
rhs_t = ST_BAD; /* invalid incr or overflow */
|
||||
tlen -= ep - oep;
|
||||
}
|
||||
|
||||
if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)
|
||||
{
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
return ((char **)NULL);
|
||||
}
|
||||
|
||||
/* OK, we have something. It's either a sequence of integers, ascending
|
||||
or descending, or a sequence or letters, ditto. Generate the sequence,
|
||||
put it into a string vector, and return it. */
|
||||
|
||||
if (lhs_t == ST_CHAR)
|
||||
{
|
||||
lhs_v = (unsigned char)lhs[0];
|
||||
rhs_v = (unsigned char)rhs[0];
|
||||
width = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lhs_v = tl; /* integer truncation */
|
||||
rhs_v = tr;
|
||||
|
||||
/* Decide whether or not the terms need zero-padding */
|
||||
rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1;
|
||||
width = 0;
|
||||
if (lhs_l > 1 && lhs[0] == '0')
|
||||
width = lhs_l, lhs_t = ST_ZINT;
|
||||
if (lhs_l > 2 && lhs[0] == '-' && lhs[1] == '0')
|
||||
width = lhs_l, lhs_t = ST_ZINT;
|
||||
if (rhs_l > 1 && rhs[0] == '0' && width < rhs_l)
|
||||
width = rhs_l, lhs_t = ST_ZINT;
|
||||
if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l)
|
||||
width = rhs_l, lhs_t = ST_ZINT;
|
||||
|
||||
if (width < lhs_l && lhs_t == ST_ZINT)
|
||||
width = lhs_l;
|
||||
if (width < rhs_l && lhs_t == ST_ZINT)
|
||||
width = rhs_l;
|
||||
}
|
||||
|
||||
result = mkseq (lhs_v, rhs_v, incr, lhs_t, width);
|
||||
|
||||
free (lhs);
|
||||
free (rhs);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Start at INDEX, and skip characters in TEXT. Set INDEX to the
|
||||
index of the character matching SATISFY. This understands about
|
||||
quoting. Return the character that caused us to stop searching;
|
||||
this is either the same as SATISFY, or 0. */
|
||||
/* If SATISFY is `}', we are looking for a brace expression, so we
|
||||
should enforce the rules that govern valid brace expansions:
|
||||
1) to count as an arg separator, a comma or `..' has to be outside
|
||||
an inner set of braces.
|
||||
*/
|
||||
static int
|
||||
brace_gobbler (text, tlen, indx, satisfy)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int *indx;
|
||||
int satisfy;
|
||||
{
|
||||
register int i, c, quoted, level, commas, pass_next;
|
||||
#if defined (SHELL)
|
||||
int si;
|
||||
char *t;
|
||||
#endif
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
level = quoted = pass_next = 0;
|
||||
#if defined (CSH_BRACE_COMPAT)
|
||||
commas = 1;
|
||||
#else
|
||||
commas = (satisfy == '}') ? 0 : 1;
|
||||
#endif
|
||||
|
||||
i = *indx;
|
||||
while (c = text[i])
|
||||
{
|
||||
if (pass_next)
|
||||
{
|
||||
pass_next = 0;
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* A backslash escapes the next character. This allows backslash to
|
||||
escape the quote character in a double-quoted string. */
|
||||
if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))
|
||||
{
|
||||
pass_next = 1;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
/* If compiling for the shell, treat ${...} like \{...} */
|
||||
if (c == '$' && text[i+1] == '{' && quoted != '\'') /* } */
|
||||
{
|
||||
pass_next = 1;
|
||||
i++;
|
||||
if (quoted == 0)
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (quoted)
|
||||
{
|
||||
if (c == quoted)
|
||||
quoted = 0;
|
||||
#if defined (SHELL)
|
||||
/* The shell allows quoted command substitutions */
|
||||
if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/
|
||||
goto comsub;
|
||||
#endif
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '"' || c == '\'' || c == '`')
|
||||
{
|
||||
quoted = c;
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined (SHELL)
|
||||
/* Pass new-style command and process substitutions through unchanged. */
|
||||
if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */
|
||||
{
|
||||
comsub:
|
||||
si = i + 2;
|
||||
t = extract_command_subst (text, &si, 0);
|
||||
i = si;
|
||||
free (t);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c == satisfy && level == 0 && quoted == 0 && commas > 0)
|
||||
{
|
||||
/* We ignore an open brace surrounded by whitespace, and also
|
||||
an open brace followed immediately by a close brace preceded
|
||||
by whitespace. */
|
||||
if (c == '{' &&
|
||||
((!i || brace_whitespace (text[i - 1])) &&
|
||||
(brace_whitespace (text[i + 1]) || text[i + 1] == '}')))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '{')
|
||||
level++;
|
||||
else if (c == '}' && level)
|
||||
level--;
|
||||
#if !defined (CSH_BRACE_COMPAT)
|
||||
else if (satisfy == '}' && c == brace_arg_separator && level == 0)
|
||||
commas++;
|
||||
else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) &&
|
||||
text[i+2] != satisfy && level == 0)
|
||||
commas++;
|
||||
#endif
|
||||
|
||||
ADVANCE_CHAR (text, tlen, i);
|
||||
}
|
||||
|
||||
*indx = i;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* Return 1 if ARR has any non-empty-string members. Used to short-circuit
|
||||
in array_concat() below. */
|
||||
static int
|
||||
degenerate_array (arr)
|
||||
char **arr;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; arr[i]; i++)
|
||||
if (arr[i][0] != '\0')
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return a new array of strings which is the result of appending each
|
||||
string in ARR2 to each string in ARR1. The resultant array is
|
||||
len (arr1) * len (arr2) long. For convenience, ARR1 (and its contents)
|
||||
are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2
|
||||
is returned. */
|
||||
static char **
|
||||
array_concat (arr1, arr2)
|
||||
char **arr1, **arr2;
|
||||
{
|
||||
register int i, j, len, len1, len2;
|
||||
register char **result;
|
||||
|
||||
if (arr1 == 0)
|
||||
return (arr2); /* XXX - see if we can get away without copying? */
|
||||
|
||||
if (arr2 == 0)
|
||||
return (arr1); /* XXX - caller expects us to free arr1 */
|
||||
|
||||
/* We can only short-circuit if the array consists of a single null element;
|
||||
otherwise we need to replicate the contents of the other array and
|
||||
prefix (or append, below) an empty element to each one. */
|
||||
if (arr1[0] && arr1[0][0] == 0 && arr1[1] == 0)
|
||||
{
|
||||
strvec_dispose (arr1);
|
||||
return (arr2); /* XXX - use flags to see if we can avoid copying here */
|
||||
}
|
||||
|
||||
if (arr2[0] && arr2[0][0] == 0 && arr2[1] == 0)
|
||||
return (arr1); /* XXX - rather than copying and freeing it */
|
||||
|
||||
len1 = strvec_len (arr1);
|
||||
len2 = strvec_len (arr2);
|
||||
|
||||
result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
|
||||
|
||||
len = 0;
|
||||
for (i = 0; i < len1; i++)
|
||||
{
|
||||
int strlen_1 = strlen (arr1[i]);
|
||||
|
||||
for (j = 0; j < len2; j++)
|
||||
{
|
||||
result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j]));
|
||||
strcpy (result[len], arr1[i]);
|
||||
strcpy (result[len] + strlen_1, arr2[j]);
|
||||
len++;
|
||||
}
|
||||
free (arr1[i]);
|
||||
}
|
||||
free (arr1);
|
||||
|
||||
result[len] = (char *)NULL;
|
||||
return (result);
|
||||
}
|
||||
|
||||
#if defined (TEST)
|
||||
#include <stdio.h>
|
||||
|
||||
fatal_error (format, arg1, arg2)
|
||||
char *format, *arg1, *arg2;
|
||||
{
|
||||
report_error (format, arg1, arg2);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
report_error (format, arg1, arg2)
|
||||
char *format, *arg1, *arg2;
|
||||
{
|
||||
fprintf (stderr, format, arg1, arg2);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
char example[256];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char **result;
|
||||
int i;
|
||||
|
||||
fprintf (stderr, "brace_expand> ");
|
||||
|
||||
if ((!fgets (example, 256, stdin)) ||
|
||||
(strncmp (example, "quit", 4) == 0))
|
||||
break;
|
||||
|
||||
if (strlen (example))
|
||||
example[strlen (example) - 1] = '\0';
|
||||
|
||||
result = brace_expand (example);
|
||||
|
||||
for (i = 0; result[i]; i++)
|
||||
printf ("%s\n", result[i]);
|
||||
|
||||
free_array (result);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* compile-command: "gcc -g -Bstatic -DTEST -o brace_expand braces.c general.o"
|
||||
* end:
|
||||
*/
|
||||
|
||||
#endif /* TEST */
|
||||
#endif /* BRACE_EXPANSION */
|
||||
@@ -170,6 +170,10 @@ extern int errno;
|
||||
# define RLIMIT_MAXUPROC 260
|
||||
#endif
|
||||
|
||||
#if !defined (RLIMIT_PTHREAD) && defined (RLIMIT_NTHR)
|
||||
# define RLIMIT_PTHREAD RLIMIT_NTHR
|
||||
#endif
|
||||
|
||||
#if !defined (RLIM_INFINITY)
|
||||
# define RLIM_INFINITY 0x7fffffff
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,779 @@
|
||||
This file is ulimit.def, from which is created ulimit.c.
|
||||
It implements the builtin "ulimit" in Bash.
|
||||
|
||||
Copyright (C) 1987-2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES ulimit.c
|
||||
|
||||
$BUILTIN ulimit
|
||||
$FUNCTION ulimit_builtin
|
||||
$DEPENDS_ON !_MINIX
|
||||
$SHORT_DOC ulimit [-SHabcdefilmnpqrstuvxT] [limit]
|
||||
Modify shell resource limits.
|
||||
|
||||
Provides control over the resources available to the shell and processes
|
||||
it creates, on systems that allow such control.
|
||||
|
||||
Options:
|
||||
-S use the `soft' resource limit
|
||||
-H use the `hard' resource limit
|
||||
-a all current limits are reported
|
||||
-b the socket buffer size
|
||||
-c the maximum size of core files created
|
||||
-d the maximum size of a process's data segment
|
||||
-e the maximum scheduling priority (`nice')
|
||||
-f the maximum size of files written by the shell and its children
|
||||
-i the maximum number of pending signals
|
||||
-l the maximum size a process may lock into memory
|
||||
-m the maximum resident set size
|
||||
-n the maximum number of open file descriptors
|
||||
-p the pipe buffer size
|
||||
-q the maximum number of bytes in POSIX message queues
|
||||
-r the maximum real-time scheduling priority
|
||||
-s the maximum stack size
|
||||
-t the maximum amount of cpu time in seconds
|
||||
-u the maximum number of user processes
|
||||
-v the size of virtual memory
|
||||
-x the maximum number of file locks
|
||||
-T the maximum number of threads
|
||||
|
||||
Not all options are available on all platforms.
|
||||
|
||||
If LIMIT is given, it is the new value of the specified resource; the
|
||||
special LIMIT values `soft', `hard', and `unlimited' stand for the
|
||||
current soft limit, the current hard limit, and no limit, respectively.
|
||||
Otherwise, the current value of the specified resource is printed. If
|
||||
no option is given, then -f is assumed.
|
||||
|
||||
Values are in 1024-byte increments, except for -t, which is in seconds,
|
||||
-p, which is in increments of 512 bytes, and -u, which is an unscaled
|
||||
number of processes.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
$END
|
||||
|
||||
#if !defined (_MINIX)
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "../bashtypes.h"
|
||||
#if defined (HAVE_SYS_PARAM_H)
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "pipesize.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* For some reason, HPUX chose to make these definitions visible only if
|
||||
_KERNEL is defined, so we define _KERNEL before including <sys/resource.h>
|
||||
and #undef it afterward. */
|
||||
#if defined (HAVE_RESOURCE)
|
||||
# include <sys/time.h>
|
||||
# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL)
|
||||
# define _KERNEL
|
||||
# endif
|
||||
# include <sys/resource.h>
|
||||
# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL)
|
||||
# undef _KERNEL
|
||||
# endif
|
||||
#elif defined (HAVE_SYS_TIMES_H)
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_LIMITS_H)
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Check for the most basic symbols. If they aren't present, this
|
||||
system's <sys/resource.h> isn't very useful to us. */
|
||||
#if !defined (RLIMIT_FSIZE) || !defined (HAVE_GETRLIMIT)
|
||||
# undef HAVE_RESOURCE
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_RESOURCE) && defined (HAVE_ULIMIT_H)
|
||||
# include <ulimit.h>
|
||||
#endif
|
||||
|
||||
#if !defined (RLIMTYPE)
|
||||
# define RLIMTYPE long
|
||||
# define string_to_rlimtype(s) strtol(s, (char **)NULL, 10)
|
||||
# define print_rlimtype(num, nl) printf ("%ld%s", num, nl ? "\n" : "")
|
||||
#endif
|
||||
|
||||
/* Some systems use RLIMIT_NOFILE, others use RLIMIT_OFILE */
|
||||
#if defined (HAVE_RESOURCE) && defined (RLIMIT_OFILE) && !defined (RLIMIT_NOFILE)
|
||||
# define RLIMIT_NOFILE RLIMIT_OFILE
|
||||
#endif /* HAVE_RESOURCE && RLIMIT_OFILE && !RLIMIT_NOFILE */
|
||||
|
||||
/* Some systems have these, some do not. */
|
||||
#ifdef RLIMIT_FSIZE
|
||||
# define RLIMIT_FILESIZE RLIMIT_FSIZE
|
||||
#else
|
||||
# define RLIMIT_FILESIZE 256
|
||||
#endif
|
||||
|
||||
#define RLIMIT_PIPESIZE 257
|
||||
|
||||
#ifdef RLIMIT_NOFILE
|
||||
# define RLIMIT_OPENFILES RLIMIT_NOFILE
|
||||
#else
|
||||
# define RLIMIT_OPENFILES 258
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_VMEM
|
||||
# define RLIMIT_VIRTMEM RLIMIT_VMEM
|
||||
# define RLIMIT_VMBLKSZ 1024
|
||||
#else
|
||||
# ifdef RLIMIT_AS
|
||||
# define RLIMIT_VIRTMEM RLIMIT_AS
|
||||
# define RLIMIT_VMBLKSZ 1024
|
||||
# else
|
||||
# define RLIMIT_VIRTMEM 259
|
||||
# define RLIMIT_VMBLKSZ 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef RLIMIT_NPROC
|
||||
# define RLIMIT_MAXUPROC RLIMIT_NPROC
|
||||
#else
|
||||
# define RLIMIT_MAXUPROC 260
|
||||
#endif
|
||||
|
||||
#if !defined (RLIM_INFINITY)
|
||||
# define RLIM_INFINITY 0x7fffffff
|
||||
#endif
|
||||
|
||||
#if !defined (RLIM_SAVED_CUR)
|
||||
# define RLIM_SAVED_CUR RLIM_INFINITY
|
||||
#endif
|
||||
|
||||
#if !defined (RLIM_SAVED_MAX)
|
||||
# define RLIM_SAVED_MAX RLIM_INFINITY
|
||||
#endif
|
||||
|
||||
#define LIMIT_HARD 0x01
|
||||
#define LIMIT_SOFT 0x02
|
||||
|
||||
/* "Blocks" are defined as 512 bytes when in Posix mode and 1024 bytes
|
||||
otherwise. */
|
||||
#define POSIXBLK -2
|
||||
|
||||
#define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x))
|
||||
|
||||
extern int posixly_correct;
|
||||
|
||||
static int _findlim __P((int));
|
||||
|
||||
static int ulimit_internal __P((int, char *, int, int));
|
||||
|
||||
static int get_limit __P((int, RLIMTYPE *, RLIMTYPE *));
|
||||
static int set_limit __P((int, RLIMTYPE, int));
|
||||
|
||||
static void printone __P((int, RLIMTYPE, int));
|
||||
static void print_all_limits __P((int));
|
||||
|
||||
static int set_all_limits __P((int, RLIMTYPE));
|
||||
|
||||
static int filesize __P((RLIMTYPE *));
|
||||
static int pipesize __P((RLIMTYPE *));
|
||||
static int getmaxuprc __P((RLIMTYPE *));
|
||||
static int getmaxvm __P((RLIMTYPE *, RLIMTYPE *));
|
||||
|
||||
typedef struct {
|
||||
int option; /* The ulimit option for this limit. */
|
||||
int parameter; /* Parameter to pass to get_limit (). */
|
||||
int block_factor; /* Blocking factor for specific limit. */
|
||||
const char * const description; /* Descriptive string to output. */
|
||||
const char * const units; /* scale */
|
||||
} RESOURCE_LIMITS;
|
||||
|
||||
static RESOURCE_LIMITS limits[] = {
|
||||
#ifdef RLIMIT_PTHREAD
|
||||
{ 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_SBSIZE
|
||||
{ 'b', RLIMIT_SBSIZE, 1, "socket buffer size", "bytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_CORE
|
||||
{ 'c', RLIMIT_CORE, POSIXBLK, "core file size", "blocks" },
|
||||
#endif
|
||||
#ifdef RLIMIT_DATA
|
||||
{ 'd', RLIMIT_DATA, 1024, "data seg size", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_NICE
|
||||
{ 'e', RLIMIT_NICE, 1, "scheduling priority", (char *)NULL },
|
||||
#endif
|
||||
{ 'f', RLIMIT_FILESIZE, POSIXBLK, "file size", "blocks" },
|
||||
#ifdef RLIMIT_SIGPENDING
|
||||
{ 'i', RLIMIT_SIGPENDING, 1, "pending signals", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
{ 'l', RLIMIT_MEMLOCK, 1024, "max locked memory", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_RSS
|
||||
{ 'm', RLIMIT_RSS, 1024, "max memory size", "kbytes" },
|
||||
#endif /* RLIMIT_RSS */
|
||||
{ 'n', RLIMIT_OPENFILES, 1, "open files", (char *)NULL},
|
||||
{ 'p', RLIMIT_PIPESIZE, 512, "pipe size", "512 bytes" },
|
||||
#ifdef RLIMIT_MSGQUEUE
|
||||
{ 'q', RLIMIT_MSGQUEUE, 1, "POSIX message queues", "bytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_RTPRIO
|
||||
{ 'r', RLIMIT_RTPRIO, 1, "real-time priority", (char *)NULL },
|
||||
#endif
|
||||
#ifdef RLIMIT_STACK
|
||||
{ 's', RLIMIT_STACK, 1024, "stack size", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_CPU
|
||||
{ 't', RLIMIT_CPU, 1, "cpu time", "seconds" },
|
||||
#endif /* RLIMIT_CPU */
|
||||
{ 'u', RLIMIT_MAXUPROC, 1, "max user processes", (char *)NULL },
|
||||
#if defined (HAVE_RESOURCE)
|
||||
{ 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_SWAP
|
||||
{ 'w', RLIMIT_SWAP, 1024, "swap size", "kbytes" },
|
||||
#endif
|
||||
#ifdef RLIMIT_LOCKS
|
||||
{ 'x', RLIMIT_LOCKS, 1, "file locks", (char *)NULL },
|
||||
#endif
|
||||
{ -1, -1, -1, (char *)NULL, (char *)NULL }
|
||||
};
|
||||
#define NCMDS (sizeof(limits) / sizeof(limits[0]))
|
||||
|
||||
typedef struct _cmd {
|
||||
int cmd;
|
||||
char *arg;
|
||||
} ULCMD;
|
||||
|
||||
static ULCMD *cmdlist;
|
||||
static int ncmd;
|
||||
static int cmdlistsz;
|
||||
|
||||
#if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT)
|
||||
long
|
||||
ulimit (cmd, newlim)
|
||||
int cmd;
|
||||
long newlim;
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */
|
||||
|
||||
static int
|
||||
_findlim (opt)
|
||||
int opt;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; limits[i].option > 0; i++)
|
||||
if (limits[i].option == opt)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char optstring[4 + 2 * NCMDS];
|
||||
|
||||
/* Report or set limits associated with certain per-process resources.
|
||||
See the help documentation in builtins.c for a full description. */
|
||||
int
|
||||
ulimit_builtin (list)
|
||||
register WORD_LIST *list;
|
||||
{
|
||||
register char *s;
|
||||
int c, limind, mode, opt, all_limits;
|
||||
|
||||
mode = 0;
|
||||
|
||||
all_limits = 0;
|
||||
|
||||
/* Idea stolen from pdksh -- build option string the first time called. */
|
||||
if (optstring[0] == 0)
|
||||
{
|
||||
s = optstring;
|
||||
*s++ = 'a'; *s++ = 'S'; *s++ = 'H';
|
||||
for (c = 0; limits[c].option > 0; c++)
|
||||
{
|
||||
*s++ = limits[c].option;
|
||||
*s++ = ';';
|
||||
}
|
||||
*s = '\0';
|
||||
}
|
||||
|
||||
/* Initialize the command list. */
|
||||
if (cmdlistsz == 0)
|
||||
cmdlist = (ULCMD *)xmalloc ((cmdlistsz = 16) * sizeof (ULCMD));
|
||||
ncmd = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, optstring)) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'a':
|
||||
all_limits++;
|
||||
break;
|
||||
|
||||
/* -S and -H are modifiers, not real options. */
|
||||
case 'S':
|
||||
mode |= LIMIT_SOFT;
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
mode |= LIMIT_HARD;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
|
||||
default:
|
||||
if (ncmd >= cmdlistsz)
|
||||
cmdlist = (ULCMD *)xrealloc (cmdlist, (cmdlistsz *= 2) * sizeof (ULCMD));
|
||||
cmdlist[ncmd].cmd = opt;
|
||||
cmdlist[ncmd++].arg = list_optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (all_limits)
|
||||
{
|
||||
#ifdef NOTYET
|
||||
if (list) /* setting */
|
||||
{
|
||||
if (STREQ (list->word->word, "unlimited") == 0)
|
||||
{
|
||||
builtin_error (_("%s: invalid limit argument"), list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
return (set_all_limits (mode == 0 ? LIMIT_SOFT|LIMIT_HARD : mode, RLIM_INFINITY));
|
||||
}
|
||||
#endif
|
||||
print_all_limits (mode == 0 ? LIMIT_SOFT : mode);
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
/* default is `ulimit -f' */
|
||||
if (ncmd == 0)
|
||||
{
|
||||
cmdlist[ncmd].cmd = 'f';
|
||||
/* `ulimit something' is same as `ulimit -f something' */
|
||||
cmdlist[ncmd++].arg = list ? list->word->word : (char *)NULL;
|
||||
if (list)
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* verify each command in the list. */
|
||||
for (c = 0; c < ncmd; c++)
|
||||
{
|
||||
limind = _findlim (cmdlist[c].cmd);
|
||||
if (limind == -1)
|
||||
{
|
||||
builtin_error (_("`%c': bad command"), cmdlist[c].cmd);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
for (c = 0; c < ncmd; c++)
|
||||
if (ulimit_internal (cmdlist[c].cmd, cmdlist[c].arg, mode, ncmd > 1) == EXECUTION_FAILURE)
|
||||
return (EXECUTION_FAILURE);
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
static int
|
||||
ulimit_internal (cmd, cmdarg, mode, multiple)
|
||||
int cmd;
|
||||
char *cmdarg;
|
||||
int mode, multiple;
|
||||
{
|
||||
int opt, limind, setting;
|
||||
int block_factor;
|
||||
RLIMTYPE soft_limit, hard_limit, real_limit, limit;
|
||||
|
||||
setting = cmdarg != 0;
|
||||
limind = _findlim (cmd);
|
||||
if (mode == 0)
|
||||
mode = setting ? (LIMIT_HARD|LIMIT_SOFT) : LIMIT_SOFT;
|
||||
opt = get_limit (limind, &soft_limit, &hard_limit);
|
||||
if (opt < 0)
|
||||
{
|
||||
builtin_error (_("%s: cannot get limit: %s"), limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (setting == 0) /* print the value of the specified limit */
|
||||
{
|
||||
printone (limind, (mode & LIMIT_SOFT) ? soft_limit : hard_limit, multiple);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* Setting the limit. */
|
||||
if (STREQ (cmdarg, "hard"))
|
||||
real_limit = hard_limit;
|
||||
else if (STREQ (cmdarg, "soft"))
|
||||
real_limit = soft_limit;
|
||||
else if (STREQ (cmdarg, "unlimited"))
|
||||
real_limit = RLIM_INFINITY;
|
||||
else if (all_digits (cmdarg))
|
||||
{
|
||||
limit = string_to_rlimtype (cmdarg);
|
||||
block_factor = BLOCKSIZE(limits[limind].block_factor);
|
||||
real_limit = limit * block_factor;
|
||||
|
||||
if ((real_limit / block_factor) != limit)
|
||||
{
|
||||
sh_erange (cmdarg, _("limit"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_invalidnum (cmdarg);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
if (set_limit (limind, real_limit, mode) < 0)
|
||||
{
|
||||
builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description,
|
||||
strerror (errno));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
static int
|
||||
get_limit (ind, softlim, hardlim)
|
||||
int ind;
|
||||
RLIMTYPE *softlim, *hardlim;
|
||||
{
|
||||
RLIMTYPE value;
|
||||
#if defined (HAVE_RESOURCE)
|
||||
struct rlimit limit;
|
||||
#endif
|
||||
|
||||
if (limits[ind].parameter >= 256)
|
||||
{
|
||||
switch (limits[ind].parameter)
|
||||
{
|
||||
case RLIMIT_FILESIZE:
|
||||
if (filesize (&value) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case RLIMIT_PIPESIZE:
|
||||
if (pipesize (&value) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case RLIMIT_OPENFILES:
|
||||
value = (RLIMTYPE)getdtablesize ();
|
||||
break;
|
||||
case RLIMIT_VIRTMEM:
|
||||
return (getmaxvm (softlim, hardlim));
|
||||
case RLIMIT_MAXUPROC:
|
||||
if (getmaxuprc (&value) < 0)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*softlim = *hardlim = value;
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_RESOURCE)
|
||||
if (getrlimit (limits[ind].parameter, &limit) < 0)
|
||||
return -1;
|
||||
*softlim = limit.rlim_cur;
|
||||
*hardlim = limit.rlim_max;
|
||||
# if defined (HPUX9)
|
||||
if (limits[ind].parameter == RLIMIT_FILESIZE)
|
||||
{
|
||||
*softlim *= 512;
|
||||
*hardlim *= 512; /* Ugh. */
|
||||
}
|
||||
else
|
||||
# endif /* HPUX9 */
|
||||
return 0;
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
set_limit (ind, newlim, mode)
|
||||
int ind;
|
||||
RLIMTYPE newlim;
|
||||
int mode;
|
||||
{
|
||||
#if defined (HAVE_RESOURCE)
|
||||
struct rlimit limit;
|
||||
RLIMTYPE val;
|
||||
#endif
|
||||
|
||||
if (limits[ind].parameter >= 256)
|
||||
switch (limits[ind].parameter)
|
||||
{
|
||||
case RLIMIT_FILESIZE:
|
||||
#if !defined (HAVE_RESOURCE)
|
||||
return (ulimit (2, newlim / 512L));
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
case RLIMIT_OPENFILES:
|
||||
#if defined (HAVE_SETDTABLESIZE)
|
||||
# if defined (__CYGWIN__)
|
||||
/* Grrr... Cygwin declares setdtablesize as void. */
|
||||
setdtablesize (newlim);
|
||||
return 0;
|
||||
# else
|
||||
return (setdtablesize (newlim));
|
||||
# endif
|
||||
#endif
|
||||
case RLIMIT_PIPESIZE:
|
||||
case RLIMIT_VIRTMEM:
|
||||
case RLIMIT_MAXUPROC:
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_RESOURCE)
|
||||
if (getrlimit (limits[ind].parameter, &limit) < 0)
|
||||
return -1;
|
||||
# if defined (HPUX9)
|
||||
if (limits[ind].parameter == RLIMIT_FILESIZE)
|
||||
newlim /= 512; /* Ugh. */
|
||||
# endif /* HPUX9 */
|
||||
val = (current_user.euid != 0 && newlim == RLIM_INFINITY &&
|
||||
(mode & LIMIT_HARD) == 0 && /* XXX -- test */
|
||||
(limit.rlim_cur <= limit.rlim_max))
|
||||
? limit.rlim_max : newlim;
|
||||
if (mode & LIMIT_SOFT)
|
||||
limit.rlim_cur = val;
|
||||
if (mode & LIMIT_HARD)
|
||||
limit.rlim_max = val;
|
||||
|
||||
return (setrlimit (limits[ind].parameter, &limit));
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
getmaxvm (softlim, hardlim)
|
||||
RLIMTYPE *softlim, *hardlim;
|
||||
{
|
||||
#if defined (HAVE_RESOURCE)
|
||||
struct rlimit datalim, stacklim;
|
||||
|
||||
if (getrlimit (RLIMIT_DATA, &datalim) < 0)
|
||||
return -1;
|
||||
|
||||
if (getrlimit (RLIMIT_STACK, &stacklim) < 0)
|
||||
return -1;
|
||||
|
||||
/* Protect against overflow. */
|
||||
*softlim = (datalim.rlim_cur / 1024L) + (stacklim.rlim_cur / 1024L);
|
||||
*hardlim = (datalim.rlim_max / 1024L) + (stacklim.rlim_max / 1024L);
|
||||
return 0;
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif /* HAVE_RESOURCE */
|
||||
}
|
||||
|
||||
static int
|
||||
filesize(valuep)
|
||||
RLIMTYPE *valuep;
|
||||
{
|
||||
#if !defined (HAVE_RESOURCE)
|
||||
long result;
|
||||
if ((result = ulimit (1, 0L)) < 0)
|
||||
return -1;
|
||||
else
|
||||
*valuep = (RLIMTYPE) result * 512;
|
||||
return 0;
|
||||
#else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
pipesize (valuep)
|
||||
RLIMTYPE *valuep;
|
||||
{
|
||||
#if defined (PIPE_BUF)
|
||||
/* This is defined on Posix systems. */
|
||||
*valuep = (RLIMTYPE) PIPE_BUF;
|
||||
return 0;
|
||||
#else
|
||||
# if defined (_POSIX_PIPE_BUF)
|
||||
*valuep = (RLIMTYPE) _POSIX_PIPE_BUF;
|
||||
return 0;
|
||||
# else
|
||||
# if defined (PIPESIZE)
|
||||
/* This is defined by running a program from the Makefile. */
|
||||
*valuep = (RLIMTYPE) PIPESIZE;
|
||||
return 0;
|
||||
# else
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
# endif /* PIPESIZE */
|
||||
# endif /* _POSIX_PIPE_BUF */
|
||||
#endif /* PIPE_BUF */
|
||||
}
|
||||
|
||||
static int
|
||||
getmaxuprc (valuep)
|
||||
RLIMTYPE *valuep;
|
||||
{
|
||||
long maxchild;
|
||||
|
||||
maxchild = getmaxchild ();
|
||||
if (maxchild < 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*valuep = (RLIMTYPE) maxchild;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_all_limits (mode)
|
||||
int mode;
|
||||
{
|
||||
register int i;
|
||||
RLIMTYPE softlim, hardlim;
|
||||
|
||||
if (mode == 0)
|
||||
mode |= LIMIT_SOFT;
|
||||
|
||||
for (i = 0; limits[i].option > 0; i++)
|
||||
{
|
||||
if (get_limit (i, &softlim, &hardlim) == 0)
|
||||
printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
|
||||
else if (errno != EINVAL)
|
||||
builtin_error ("%s: cannot get limit: %s", limits[i].description,
|
||||
strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printone (limind, curlim, pdesc)
|
||||
int limind;
|
||||
RLIMTYPE curlim;
|
||||
int pdesc;
|
||||
{
|
||||
char unitstr[64];
|
||||
int factor;
|
||||
|
||||
factor = BLOCKSIZE(limits[limind].block_factor);
|
||||
if (pdesc)
|
||||
{
|
||||
if (limits[limind].units)
|
||||
sprintf (unitstr, "(%s, -%c) ", limits[limind].units, limits[limind].option);
|
||||
else
|
||||
sprintf (unitstr, "(-%c) ", limits[limind].option);
|
||||
|
||||
printf ("%-20s %16s", limits[limind].description, unitstr);
|
||||
}
|
||||
if (curlim == RLIM_INFINITY)
|
||||
puts ("unlimited");
|
||||
else if (curlim == RLIM_SAVED_MAX)
|
||||
puts ("hard");
|
||||
else if (curlim == RLIM_SAVED_CUR)
|
||||
puts ("soft");
|
||||
else
|
||||
print_rlimtype ((curlim / factor), 1);
|
||||
}
|
||||
|
||||
/* Set all limits to NEWLIM. NEWLIM currently must be RLIM_INFINITY, which
|
||||
causes all limits to be set as high as possible depending on mode (like
|
||||
csh `unlimit'). Returns -1 if NEWLIM is invalid, 0 if all limits
|
||||
were set successfully, and 1 if at least one limit could not be set.
|
||||
|
||||
To raise all soft limits to their corresponding hard limits, use
|
||||
ulimit -S -a unlimited
|
||||
To attempt to raise all hard limits to infinity (superuser-only), use
|
||||
ulimit -H -a unlimited
|
||||
To attempt to raise all soft and hard limits to infinity, use
|
||||
ulimit -a unlimited
|
||||
*/
|
||||
|
||||
static int
|
||||
set_all_limits (mode, newlim)
|
||||
int mode;
|
||||
RLIMTYPE newlim;
|
||||
{
|
||||
register int i;
|
||||
int retval = 0;
|
||||
|
||||
if (newlim != RLIM_INFINITY)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mode == 0)
|
||||
mode = LIMIT_SOFT|LIMIT_HARD;
|
||||
|
||||
for (retval = i = 0; limits[i].option > 0; i++)
|
||||
if (set_limit (i, newlim, mode) < 0)
|
||||
{
|
||||
builtin_error (_("%s: cannot modify limit: %s"), limits[i].description,
|
||||
strerror (errno));
|
||||
retval = 1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* !_MINIX */
|
||||
@@ -61,10 +61,6 @@ $END
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#ifdef __LCC__
|
||||
#define mode_t int
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* UMASK Builtin and Helpers */
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
This file is umask.def, from which is created umask.c.
|
||||
It implements the builtin "umask" in Bash.
|
||||
|
||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES umask.c
|
||||
|
||||
$BUILTIN umask
|
||||
$FUNCTION umask_builtin
|
||||
$SHORT_DOC umask [-p] [-S] [mode]
|
||||
Display or set file mode mask.
|
||||
|
||||
Sets the user file-creation mask to MODE. If MODE is omitted, prints
|
||||
the current value of the mask.
|
||||
|
||||
If MODE begins with a digit, it is interpreted as an octal number;
|
||||
otherwise it is a symbolic mode string like that accepted by chmod(1).
|
||||
|
||||
Options:
|
||||
-p if MODE is omitted, output in a form that may be reused as input
|
||||
-S makes the output symbolic; otherwise an octal number is output
|
||||
|
||||
Exit Status:
|
||||
Returns success unless MODE is invalid or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "../bashtypes.h"
|
||||
#include "filecntl.h"
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <chartypes.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "posixstat.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#ifdef __LCC__
|
||||
#define mode_t int
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* UMASK Builtin and Helpers */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static void print_symbolic_umask __P((mode_t));
|
||||
static int symbolic_umask __P((WORD_LIST *));
|
||||
|
||||
/* Set or display the mask used by the system when creating files. Flag
|
||||
of -S means display the umask in a symbolic mode. */
|
||||
int
|
||||
umask_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int print_symbolically, opt, umask_value, pflag;
|
||||
mode_t umask_arg;
|
||||
|
||||
print_symbolically = pflag = 0;
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "Sp")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'S':
|
||||
print_symbolically++;
|
||||
break;
|
||||
case 'p':
|
||||
pflag++;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
list = loptend;
|
||||
|
||||
if (list)
|
||||
{
|
||||
if (DIGIT (*list->word->word))
|
||||
{
|
||||
umask_value = read_octal (list->word->word);
|
||||
|
||||
/* Note that other shells just let you set the umask to zero
|
||||
by specifying a number out of range. This is a problem
|
||||
with those shells. We don't change the umask if the input
|
||||
is lousy. */
|
||||
if (umask_value == -1)
|
||||
{
|
||||
sh_erange (list->word->word, _("octal number"));
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
umask_value = symbolic_umask (list);
|
||||
if (umask_value == -1)
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
umask_arg = (mode_t)umask_value;
|
||||
umask (umask_arg);
|
||||
if (print_symbolically)
|
||||
print_symbolic_umask (umask_arg);
|
||||
}
|
||||
else /* Display the UMASK for this user. */
|
||||
{
|
||||
umask_arg = umask (022);
|
||||
umask (umask_arg);
|
||||
|
||||
if (pflag)
|
||||
printf ("umask%s ", (print_symbolically ? " -S" : ""));
|
||||
if (print_symbolically)
|
||||
print_symbolic_umask (umask_arg);
|
||||
else
|
||||
printf ("%04lo\n", (unsigned long)umask_arg);
|
||||
}
|
||||
|
||||
return (sh_chkwrite (EXECUTION_SUCCESS));
|
||||
}
|
||||
|
||||
/* Print the umask in a symbolic form. In the output, a letter is
|
||||
printed if the corresponding bit is clear in the umask. */
|
||||
static void
|
||||
print_symbolic_umask (um)
|
||||
mode_t um;
|
||||
{
|
||||
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if ((um & S_IRUSR) == 0)
|
||||
ubits[i++] = 'r';
|
||||
if ((um & S_IWUSR) == 0)
|
||||
ubits[i++] = 'w';
|
||||
if ((um & S_IXUSR) == 0)
|
||||
ubits[i++] = 'x';
|
||||
ubits[i] = '\0';
|
||||
|
||||
i = 0;
|
||||
if ((um & S_IRGRP) == 0)
|
||||
gbits[i++] = 'r';
|
||||
if ((um & S_IWGRP) == 0)
|
||||
gbits[i++] = 'w';
|
||||
if ((um & S_IXGRP) == 0)
|
||||
gbits[i++] = 'x';
|
||||
gbits[i] = '\0';
|
||||
|
||||
i = 0;
|
||||
if ((um & S_IROTH) == 0)
|
||||
obits[i++] = 'r';
|
||||
if ((um & S_IWOTH) == 0)
|
||||
obits[i++] = 'w';
|
||||
if ((um & S_IXOTH) == 0)
|
||||
obits[i++] = 'x';
|
||||
obits[i] = '\0';
|
||||
|
||||
printf ("u=%s,g=%s,o=%s\n", ubits, gbits, obits);
|
||||
}
|
||||
|
||||
int
|
||||
parse_symbolic_mode (mode, initial_bits)
|
||||
char *mode;
|
||||
int initial_bits;
|
||||
{
|
||||
int who, op, perm, bits, c;
|
||||
char *s;
|
||||
|
||||
for (s = mode, bits = initial_bits;;)
|
||||
{
|
||||
who = op = perm = 0;
|
||||
|
||||
/* Parse the `who' portion of the symbolic mode clause. */
|
||||
while (member (*s, "agou"))
|
||||
{
|
||||
switch (c = *s++)
|
||||
{
|
||||
case 'u':
|
||||
who |= S_IRWXU;
|
||||
continue;
|
||||
case 'g':
|
||||
who |= S_IRWXG;
|
||||
continue;
|
||||
case 'o':
|
||||
who |= S_IRWXO;
|
||||
continue;
|
||||
case 'a':
|
||||
who |= S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The operation is now sitting in *s. */
|
||||
op = *s++;
|
||||
switch (op)
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
case '=':
|
||||
break;
|
||||
default:
|
||||
builtin_error (_("`%c': invalid symbolic mode operator"), op);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Parse out the `perm' section of the symbolic mode clause. */
|
||||
while (member (*s, "rwx"))
|
||||
{
|
||||
c = *s++;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'r':
|
||||
perm |= S_IRUGO;
|
||||
break;
|
||||
case 'w':
|
||||
perm |= S_IWUGO;
|
||||
break;
|
||||
case 'x':
|
||||
perm |= S_IXUGO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now perform the operation or return an error for a
|
||||
bad permission string. */
|
||||
if (!*s || *s == ',')
|
||||
{
|
||||
if (who)
|
||||
perm &= who;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case '+':
|
||||
bits |= perm;
|
||||
break;
|
||||
case '-':
|
||||
bits &= ~perm;
|
||||
break;
|
||||
case '=':
|
||||
if (who == 0)
|
||||
who = S_IRWXU | S_IRWXG | S_IRWXO;
|
||||
bits &= ~who;
|
||||
bits |= perm;
|
||||
break;
|
||||
|
||||
/* No other values are possible. */
|
||||
}
|
||||
|
||||
if (*s == '\0')
|
||||
break;
|
||||
else
|
||||
s++; /* skip past ',' */
|
||||
}
|
||||
else
|
||||
{
|
||||
builtin_error (_("`%c': invalid symbolic mode character"), *s);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return (bits);
|
||||
}
|
||||
|
||||
/* Set the umask from a symbolic mode string similar to that accepted
|
||||
by chmod. If the -S argument is given, then print the umask in a
|
||||
symbolic form. */
|
||||
static int
|
||||
symbolic_umask (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int um, bits;
|
||||
|
||||
/* Get the initial umask. Don't change it yet. */
|
||||
um = umask (022);
|
||||
umask (um);
|
||||
|
||||
/* All work is done with the complement of the umask -- it's
|
||||
more intuitive and easier to deal with. It is complemented
|
||||
again before being returned. */
|
||||
bits = parse_symbolic_mode (list->word->word, ~um & 0777);
|
||||
if (bits == -1)
|
||||
return (-1);
|
||||
|
||||
um = ~bits & 0777;
|
||||
return (um);
|
||||
}
|
||||
@@ -11237,10 +11237,7 @@ if ${bash_cv_wcwidth_broken+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "cannot run test program while cross compiling
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
bash_cv_wcwidth_broken=no
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
@@ -170,6 +170,8 @@ bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
# can also use:
|
||||
# $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
# This Makefile is for the Bash/documentation directory -*- text -*-.
|
||||
#
|
||||
# Copyright (C) 2003-2013 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
VERSION = @PACKAGE_VERSION@
|
||||
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
|
||||
#
|
||||
SHELL = @MAKE_SHELL@
|
||||
RM = rm -f
|
||||
|
||||
topdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
datarootdir = @datarootdir@
|
||||
|
||||
infodir = @infodir@
|
||||
|
||||
docdir = @docdir@
|
||||
|
||||
# set this to a directory name to have the HTML files installed
|
||||
htmldir = @htmldir@
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
||||
mandir = @mandir@
|
||||
manpfx = man
|
||||
|
||||
man1ext = .1
|
||||
man1dir = $(mandir)/$(manpfx)1
|
||||
man3ext = .3
|
||||
man3dir = $(mandir)/$(manpfx)3
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
BUILD_DIR = @BUILD_DIR@
|
||||
|
||||
SUPPORT_SRCDIR = $(topdir)/support
|
||||
|
||||
# bad style
|
||||
RL_LIBDIR = $(topdir)/lib/readline
|
||||
|
||||
# unused
|
||||
TEXINDEX = texindex
|
||||
TEX = tex
|
||||
|
||||
MAKEINFO = makeinfo
|
||||
TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi
|
||||
TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html
|
||||
MAN2HTML = ${BUILD_DIR}/support/man2html
|
||||
HTMLPOST = ${srcdir}/htmlpost.sh
|
||||
INFOPOST = ${srcdir}/infopost.sh
|
||||
QUIETPS = #set this to -q to shut up dvips
|
||||
PAPERSIZE = letter # change to a4 for A4-size paper
|
||||
PSDPI = 600 # could be 300 if you like
|
||||
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
|
||||
|
||||
TEXINPUTDIR = $(RL_LIBDIR)/doc
|
||||
SET_TEXINPUTS = TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS
|
||||
|
||||
# These tools might not be available; they're not required
|
||||
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
|
||||
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
|
||||
|
||||
MKDIRS = ${SUPPORT_SRCDIR}/mkdirs
|
||||
|
||||
# This should be a program that converts troff to an ascii-readable format
|
||||
NROFF = groff -Tascii
|
||||
|
||||
# This should be a program that converts troff to postscript
|
||||
GROFF = groff
|
||||
|
||||
HSUSER = $(RL_LIBDIR)/doc/hsuser.texi
|
||||
RLUSER = $(RL_LIBDIR)/doc/rluser.texi
|
||||
|
||||
BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi
|
||||
|
||||
.SUFFIXES: .0 .1 .3 .ms .ps .txt .dvi .html .pdf
|
||||
|
||||
.1.ps:
|
||||
$(RM) $@
|
||||
-${GROFF} -man $< > $@
|
||||
|
||||
.1.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
|
||||
.1.html:
|
||||
$(RM) $@
|
||||
-${MAN2HTML} $< | ${HTMLPOST} > $@
|
||||
|
||||
.ms.ps:
|
||||
$(RM) $@
|
||||
-${GROFF} -ms $< > $@
|
||||
|
||||
.ms.txt:
|
||||
$(RM) $@
|
||||
-${NROFF} -ms $< > $@
|
||||
|
||||
.3.ps:
|
||||
$(RM) $@
|
||||
-${GROFF} -man $< > $@
|
||||
|
||||
.3.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
|
||||
.3.html:
|
||||
$(RM) $@
|
||||
-${MAN2HTML} $< > $@
|
||||
|
||||
.ps.pdf:
|
||||
$(RM) $@
|
||||
-${PSPDF} $<
|
||||
|
||||
.dvi.pdf:
|
||||
$(RM) $@
|
||||
-${DVIPDF} $<
|
||||
|
||||
.dvi.ps:
|
||||
${RM} $@
|
||||
-${DVIPS} $<
|
||||
|
||||
all: ps info dvi text html
|
||||
nodvi: ps info text html
|
||||
everything: all pdf
|
||||
|
||||
PSFILES = bash.ps bashbug.ps article.ps builtins.ps rbash.ps
|
||||
DVIFILES = bashref.dvi bashref.ps
|
||||
INFOFILES = bashref.info
|
||||
MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0
|
||||
HTMLFILES = bashref.html bash.html
|
||||
PDFFILES = bash.pdf bashref.pdf article.pdf rose94.pdf
|
||||
|
||||
ps: ${PSFILES}
|
||||
dvi: ${DVIFILES}
|
||||
info: ${INFOFILES}
|
||||
text: ${MAN0FILES}
|
||||
html: ${HTMLFILES}
|
||||
pdf: ${PDFFILES}
|
||||
|
||||
bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
${SET_TEXINPUTS} $(TEXI2DVI) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; }
|
||||
|
||||
bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER)
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
|
||||
|
||||
bash.info: bashref.info
|
||||
${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \
|
||||
|
||||
bash.txt: bash.1
|
||||
bash.ps: bash.1
|
||||
bash.html: bash.1 $(MAN2HTML)
|
||||
bashbug.ps: bashbug.1
|
||||
builtins.ps: builtins.1 bash.1
|
||||
rbash.ps: rbash.1 bash.1
|
||||
bash.0: bash.1
|
||||
bashbug.0: bashbug.1
|
||||
builtins.0: builtins.1 bash.1
|
||||
rbash.0: rbash.1 bash.1
|
||||
article.ps: article.ms
|
||||
|
||||
bashref.ps: bashref.dvi
|
||||
|
||||
article.pdf: article.ps
|
||||
bashref.pdf: bashref.dvi
|
||||
bash.pdf: bash.ps
|
||||
rose94.pdf: rose94.ps
|
||||
|
||||
OTHER_DOCS = $(srcdir)/FAQ $(srcdir)/INTRO
|
||||
OTHER_INSTALLED_DOCS = FAQ INTRO
|
||||
|
||||
$(MAN2HTML): ${topdir}/support/man2html.c
|
||||
-( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html)
|
||||
|
||||
clean:
|
||||
$(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \
|
||||
*.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o
|
||||
${RM} core *.core
|
||||
|
||||
mostlyclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
distclean: clean maybe-clean
|
||||
$(RM) Makefile
|
||||
|
||||
maintainer-clean: clean
|
||||
${RM} ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}
|
||||
${RM} ${CREATED_FAQ}
|
||||
$(RM) Makefile
|
||||
|
||||
maybe-clean:
|
||||
-if test "X$(topdir)" != "X$(BUILD_DIR)"; then \
|
||||
$(RM) ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}; \
|
||||
fi
|
||||
|
||||
installdirs:
|
||||
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(man1dir)
|
||||
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(infodir)
|
||||
-$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(docdir)
|
||||
-if test -n "$(htmldir)" ; then \
|
||||
$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(htmldir) ; \
|
||||
fi
|
||||
|
||||
install: info installdirs bash.info
|
||||
-$(INSTALL_DATA) $(srcdir)/bash.1 $(DESTDIR)$(man1dir)/bash${man1ext}
|
||||
-$(INSTALL_DATA) $(srcdir)/bashbug.1 $(DESTDIR)$(man1dir)/bashbug${man1ext}
|
||||
-$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir)
|
||||
# uncomment the next lines to install the builtins man page
|
||||
# sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1
|
||||
# -$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
|
||||
# -$(RM) $${TMPDIR:-/var/tmp}/builtins.1
|
||||
-if test -f bash.info; then d=.; else d=$(srcdir); fi; \
|
||||
$(INSTALL_DATA) $$d/bash.info $(DESTDIR)$(infodir)/bash.info
|
||||
# run install-info if it is present to update the info directory
|
||||
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
|
||||
install-info --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/bash.info; \
|
||||
else true; fi
|
||||
# if htmldir is set, install the html files into that directory
|
||||
-if test -n "${htmldir}" ; then \
|
||||
$(INSTALL_DATA) $(srcdir)/bash.html $(DESTDIR)$(htmldir) ; \
|
||||
$(INSTALL_DATA) $(srcdir)/bashref.html $(DESTDIR)$(htmldir) ; \
|
||||
fi
|
||||
|
||||
install_builtins: installdirs
|
||||
sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1
|
||||
-$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
|
||||
-$(RM) $${TMPDIR:-/var/tmp}/builtins.1
|
||||
|
||||
install_everything: install install_builtins
|
||||
|
||||
uninstall:
|
||||
-$(RM) $(DESTDIR)$(man1dir)/bash${man1ext} $(DESTDIR)$(man1dir)/bashbug${man1ext}
|
||||
-$(RM) $(DESTDIR)$(man1dir)/bash_builtins${man1ext}
|
||||
$(RM) $(DESTDIR)$(infodir)/bash.info
|
||||
-( cd $(DESTDIR)$(docdir) && $(RM) $(OTHER_INSTALLED_DOCS) )
|
||||
-if test -n "$(htmldir)" ; then \
|
||||
$(RM) $(DESTDIR)$(htmldir)/bash.html ; \
|
||||
$(RM) $(DESTDIR)$(htmldir)/bashref.html ; \
|
||||
fi
|
||||
|
||||
# for use by chet
|
||||
CREATED_FAQ = faq.news faq.news2 faq.mail faq.version
|
||||
|
||||
faq: ${CREATED_FAQ}
|
||||
|
||||
faq.version: FAQ.version FAQ
|
||||
sh mkfaqvers FAQ.version > $@
|
||||
|
||||
faq.headers.mail: FAQ.headers.mail FAQ
|
||||
sh mkfaqvers FAQ.headers.mail > $@
|
||||
|
||||
faq.headers.news: FAQ.headers.news FAQ
|
||||
sh mkfaqvers FAQ.headers.news > $@
|
||||
|
||||
faq.headers.news2: FAQ.headers.news2 FAQ
|
||||
sh mkfaqvers FAQ.headers.news2 > $@
|
||||
|
||||
faq.news: FAQ faq.headers.news faq.version
|
||||
$(RM) $@
|
||||
cat faq.headers.news faq.version FAQ > $@
|
||||
|
||||
faq.news2: FAQ faq.headers.news2 faq.version
|
||||
$(RM) $@
|
||||
cat faq.headers.news2 faq.version FAQ > $@
|
||||
|
||||
faq.mail: FAQ faq.headers.mail faq.version
|
||||
$(RM) $@
|
||||
cat faq.headers.mail faq.version FAQ > $@
|
||||
|
||||
inst: bashref.texi
|
||||
$(SHELL) ./mkinstall
|
||||
cmp -s INSTALL ../INSTALL || mv INSTALL ../INSTALL
|
||||
$(RM) INSTALL
|
||||
|
||||
posix: bashref.texi
|
||||
$(SHELL) ./mkposix
|
||||
cmp -s POSIX ../POSIX || mv POSIX ../POSIX
|
||||
$(RM) POSIX
|
||||
|
||||
rbash: bashref.texi
|
||||
$(SH) ./mkrbash
|
||||
cmp -s RBASH ../RBASH || mv RBASH ../RBASH
|
||||
$(RM) RBASH
|
||||
|
||||
xdist: pdf inst posix rbash
|
||||
+194
-170
@@ -1,17 +1,22 @@
|
||||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.16.1
|
||||
%%CreationDate: Mon Nov 19 13:06:55 2001
|
||||
%%Creator: groff version 1.19.2
|
||||
%%CreationDate: Tue Oct 22 11:07:52 2013
|
||||
%%DocumentNeededResources: font Times-Bold
|
||||
%%+ font Times-Italic
|
||||
%%+ font Times-Roman
|
||||
%%+ font Courier
|
||||
%%DocumentSuppliedResources: procset grops 1.16 1
|
||||
%%DocumentSuppliedResources: procset grops 1.19 2
|
||||
%%Pages: 11
|
||||
%%PageOrder: Ascend
|
||||
%%DocumentMedia: Default 612 792 0 () ()
|
||||
%%Orientation: Portrait
|
||||
%%EndComments
|
||||
%%BeginDefaults
|
||||
%%PageMedia: Default
|
||||
%%EndDefaults
|
||||
%%BeginProlog
|
||||
%%BeginResource: procset grops 1.16 1
|
||||
%%BeginResource: procset grops 1.19 2
|
||||
%!PS-Adobe-3.0 Resource-ProcSet
|
||||
/setpacking where{
|
||||
pop
|
||||
currentpacking
|
||||
@@ -79,7 +84,7 @@ LS{
|
||||
/EP{
|
||||
level0 restore
|
||||
showpage
|
||||
}bind def
|
||||
}def
|
||||
/DA{
|
||||
newpath arcn stroke
|
||||
}bind def
|
||||
@@ -109,11 +114,26 @@ TM setmatrix
|
||||
/ST/stroke load def
|
||||
/MT/moveto load def
|
||||
/CL/closepath load def
|
||||
/FL{
|
||||
currentgray exch setgray fill setgray
|
||||
/Fr{
|
||||
setrgbcolor fill
|
||||
}bind def
|
||||
/BL/fill load def
|
||||
/setcmykcolor where{
|
||||
pop
|
||||
/Fk{
|
||||
setcmykcolor fill
|
||||
}bind def
|
||||
}if
|
||||
/Fg{
|
||||
setgray fill
|
||||
}bind def
|
||||
/FL/fill load def
|
||||
/LW/setlinewidth load def
|
||||
/Cr/setrgbcolor load def
|
||||
/setcmykcolor where{
|
||||
pop
|
||||
/Ck/setcmykcolor load def
|
||||
}if
|
||||
/Cg/setgray load def
|
||||
/RE{
|
||||
findfont
|
||||
dup maxlength 1 index/FontName known not{1 add}if dict begin
|
||||
@@ -155,9 +175,9 @@ newpath
|
||||
/CNT countdictstack def
|
||||
userdict begin
|
||||
/showpage{}def
|
||||
/setpagedevice{}def
|
||||
}bind def
|
||||
/PEND{
|
||||
clear
|
||||
countdictstack CNT sub{end}repeat
|
||||
level1 restore
|
||||
}bind def
|
||||
@@ -167,13 +187,18 @@ pop
|
||||
setpacking
|
||||
}if
|
||||
%%EndResource
|
||||
%%EndProlog
|
||||
%%BeginSetup
|
||||
%%BeginFeature: *PageSize Default
|
||||
<< /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice
|
||||
%%EndFeature
|
||||
%%IncludeResource: font Times-Bold
|
||||
%%IncludeResource: font Times-Italic
|
||||
%%IncludeResource: font Times-Roman
|
||||
%%IncludeResource: font Courier
|
||||
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
|
||||
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
|
||||
/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
|
||||
/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef
|
||||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
|
||||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
|
||||
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
|
||||
@@ -201,256 +226,254 @@ def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
|
||||
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
|
||||
/Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE
|
||||
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
|
||||
%%EndProlog
|
||||
%%EndSetup
|
||||
%%Page: 1 1
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 12/Times-Bold@0 SF(Bash \255 The GNU shell*)227.904 123 Q/F1 10
|
||||
/Times-Italic@0 SF(Chet Rame)263.85 147 Q(y)-.3 E(Case W)221.72 159 Q
|
||||
(estern Reserve Univer)-.92 E(sity)-.1 E -.15(ch)250.425 171 S
|
||||
(et@po.cwru.edu).15 E/F2 10/Times-Bold@0 SF 2.5(1. Intr)72 207 R
|
||||
(oduction)-.18 E(Bash)97 222.6 Q/F3 10/Times-Roman@0 SF .904
|
||||
/Times-Italic@0 SF(Chet Rame)263.85 159 Q(y)-.3 E(Case W)221.72 171 Q
|
||||
(estern Reserve Univer)-.92 E(sity)-.1 E -.15(ch)250.425 183 S
|
||||
(et@po.cwru.edu).15 E/F2 10/Times-Bold@0 SF 2.5(1. Intr)72 219 R
|
||||
(oduction)-.18 E(Bash)97 234.6 Q/F3 10/Times-Roman@0 SF .904
|
||||
(is the shell, or command language interpreter)3.404 F 3.404(,t)-.4 G
|
||||
.904(hat will appear in the GNU operating system.)-3.404 F 1.075
|
||||
(The name is an acron)72 234.6 R 1.075(ym for the \231Bourne-Ag)-.15 F
|
||||
(The name is an acron)72 246.6 R 1.075(ym for the \231Bourne-Ag)-.15 F
|
||||
1.075(ain SHell\232, a pun on Ste)-.05 F 1.375 -.15(ve B)-.25 H 1.075
|
||||
(ourne, the author of the direct).15 F .206(ancestor of the current)72
|
||||
246.6 R/F4 8/Times-Roman@0 SF(UNIX)2.706 E F3 2.706<ae73>C(hell)-2.706 E
|
||||
258.6 R/F4 8/Times-Roman@0 SF(UNIX)2.706 E F3 2.706<ae73>C(hell)-2.706 E
|
||||
F1(/bin/sh)2.706 E F3 2.706(,w)C .205(hich appeared in the Se)-2.706 F
|
||||
-.15(ve)-.25 G .205(nth Edition Bell Labs Research v).15 F(er)-.15 E(-)
|
||||
-.2 E(sion of)72 258.6 Q/F5 9/Times-Roman@0 SF(UNIX)2.5 E F3(.)A .387
|
||||
(Bash is an)97 274.2 R F2(sh)2.887 E F3 .387
|
||||
-.2 E(sion of)72 270.6 Q/F5 9/Times-Roman@0 SF(UNIX)2.5 E F3(.)A .387
|
||||
(Bash is an)97 286.2 R F2(sh)2.887 E F3 .387
|
||||
(\255compatible shell that incorporates useful features from the K)B
|
||||
.388(orn shell \()-.35 F F2(ksh)A F3 2.888(\)a)C .388(nd the C)-2.888 F
|
||||
.023(shell \()72 286.2 R F2(csh)A F3 .023
|
||||
.023(shell \()72 298.2 R F2(csh)A F3 .023
|
||||
(\), described later in this article.)B .022
|
||||
(It is ultimately intended to be a conformant implementation of the)
|
||||
5.022 F 3.568(IEEE POSIX Shell and Utilities speci\214cation \(IEEE W)72
|
||||
298.2 R 3.568(orking Group 1003.2\).)-.8 F 3.569(It of)8.569 F 3.569
|
||||
(fers functional)-.25 F(impro)72 310.2 Q -.15(ve)-.15 G(ments o).15 E
|
||||
310.2 R 3.568(orking Group 1003.2\).)-.8 F 3.569(It of)8.569 F 3.569
|
||||
(fers functional)-.25 F(impro)72 322.2 Q -.15(ve)-.15 G(ments o).15 E
|
||||
-.15(ve)-.15 G 2.5(rs).15 G 2.5(hf)-2.5 G(or both interacti)-2.5 E .3
|
||||
-.15(ve a)-.25 H(nd programming use.).15 E .697
|
||||
(While the GNU operating system will most lik)97 325.8 R .697
|
||||
(While the GNU operating system will most lik)97 337.8 R .697
|
||||
(ely include a v)-.1 F .697(ersion of the Berk)-.15 F(ele)-.1 E 3.197
|
||||
(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 337.8 R
|
||||
(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 349.8 R
|
||||
.015(ault shell.)-.1 F(Lik)5.015 E 2.515(eo)-.1 G .015(ther GNU softw)
|
||||
-2.515 F .016(are, Bash is quite portable.)-.1 F .016
|
||||
(It currently runs on nearly e)5.016 F -.15(ve)-.25 G(ry).15 E -.15(ve)
|
||||
72 349.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F
|
||||
72 361.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F
|
||||
3.023(wo)-.25 G .523
|
||||
(ther operating systems \255 an independently-supported port e)-3.023 F
|
||||
.523(xists for OS/2, and)-.15 F .706
|
||||
(there are rumors of ports to DOS and W)72 361.8 R(indo)-.4 E .706
|
||||
(there are rumors of ports to DOS and W)72 373.8 R(indo)-.4 E .706
|
||||
(ws NT)-.25 F 5.706(.P)-.74 G .706(orts to)-5.706 F F5(UNIX)3.206 E F3
|
||||
(-lik)A 3.206(es)-.1 G .706(ystems such as QNX and Minix)-3.206 F
|
||||
(are part of the distrib)72 373.8 Q(ution.)-.2 E .405
|
||||
(The original author of Bash w)97 389.4 R .405(as Brian F)-.1 F .405
|
||||
(are part of the distrib)72 385.8 Q(ution.)-.2 E .405
|
||||
(The original author of Bash w)97 401.4 R .405(as Brian F)-.1 F .405
|
||||
(ox, an emplo)-.15 F .405(yee of the Free Softw)-.1 F .405(are F)-.1 F
|
||||
2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 401.4 Q -.15
|
||||
2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 413.4 Q -.15
|
||||
(ve)-.25 G(loper and maintainer is Chet Rame).15 E 1.3 -.65(y, a v)-.15
|
||||
H(olunteer who w).45 E(orks at Case W)-.1 E(estern Reserv)-.8 E 2.5(eU)
|
||||
-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(.)-.65 E F2 2.5(2. What')72
|
||||
425.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 441 Q F3 .343
|
||||
437.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 453 Q F3 .343
|
||||
(is a name originally coined by Richard Stallman for a f)2.843 F .343
|
||||
(amily of open system standards based)-.1 F(on)72 453 Q F5(UNIX)3.24 E
|
||||
(amily of open system standards based)-.1 F(on)72 465 Q F5(UNIX)3.24 E
|
||||
F3 5.74(.T)C .74(here are a number of aspects of)-5.74 F F5(UNIX)3.24 E
|
||||
F3 .74(under consideration for standardization, from the basic)3.24 F
|
||||
.192(system services at the system call and C library le)72 465 R -.15
|
||||
.192(system services at the system call and C library le)72 477 R -.15
|
||||
(ve)-.25 G 2.692(lt).15 G 2.692(oa)-2.692 G .192
|
||||
(pplications and tools to system administration and)-2.692 F 2.5
|
||||
(management. Each)72 477 R(area of standardization is assigned to a w)
|
||||
(management. Each)72 489 R(area of standardization is assigned to a w)
|
||||
2.5 E(orking group in the 1003 series.)-.1 E 2.814
|
||||
(The POSIX Shell and Utilities standard has been de)97 492.6 R -.15(ve)
|
||||
(The POSIX Shell and Utilities standard has been de)97 504.6 R -.15(ve)
|
||||
-.25 G 2.814(loped by IEEE W).15 F 2.813(orking Group 1003.2)-.8 F .254
|
||||
(\(POSIX.2\).\210 It concentrates on the command interpreter interf)72
|
||||
504.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G
|
||||
(cuted).15 E 1.112(from the command line or by other programs.)72 516.6
|
||||
516.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G
|
||||
(cuted).15 E 1.112(from the command line or by other programs.)72 528.6
|
||||
R 1.112(An initial v)6.112 F 1.113
|
||||
(ersion of the standard has been appro)-.15 F -.15(ve)-.15 G 3.613(da)
|
||||
.15 G(nd)-3.613 E .365(published by the IEEE, and w)72 528.6 R .365
|
||||
.15 G(nd)-3.613 E .365(published by the IEEE, and w)72 540.6 R .365
|
||||
(ork is currently underw)-.1 F .365(ay to update it.)-.1 F .365
|
||||
(There are four primary areas of w)5.365 F(ork)-.1 E
|
||||
(in the 1003.2 standard:)72 540.6 Q 21.5<8341>72 556.2 S .835
|
||||
(in the 1003.2 standard:)72 552.6 Q 21.5<8341>72 568.2 S .835
|
||||
(spects of the shell')-21.5 F 3.335(ss)-.55 G .835
|
||||
(yntax and command language.)-3.335 F 3.335(An)5.835 G .835
|
||||
(umber of special b)-3.335 F .835(uiltins such as)-.2 F F2(cd)3.335 E F3
|
||||
(and)3.335 E F2(exec)97 568.2 Q F3 .545(are being speci\214ed as part o\
|
||||
(and)3.335 E F2(exec)97 580.2 Q F3 .545(are being speci\214ed as part o\
|
||||
f the shell, since their functionality usually cannot be implemented)
|
||||
3.046 F(by a separate e)97 580.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5
|
||||
<8341>72 595.8 S .926
|
||||
3.046 F(by a separate e)97 592.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5
|
||||
<8341>72 607.8 S .926
|
||||
(set of utilities to be called by shell scripts and applications.)
|
||||
-18.074 F .927(Examples are programs lik)5.927 F(e)-.1 E F1 .927
|
||||
(sed, tr)3.427 F(,)-1.11 E F3(and)97 607.8 Q F1(awk.)2.797 E F3 .297
|
||||
(sed, tr)3.427 F(,)-1.11 E F3(and)97 619.8 Q F1(awk.)2.797 E F3 .297
|
||||
(Utilities commonly implemented as shell b)5.297 F .296
|
||||
(uiltins are described in this section, such as)-.2 F F2(test)2.796 E F3
|
||||
(and)97 619.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922
|
||||
(and)97 631.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922
|
||||
(xpansion of this section')-3.572 F 3.423(ss)-.55 G .923
|
||||
(cope, termed the User Portability Extension, or UPE, has)-3.423 F
|
||||
(standardized interacti)97 631.8 Q .3 -.15(ve p)-.25 H(rograms such as)
|
||||
.15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 647.4 S
|
||||
(standardized interacti)97 643.8 Q .3 -.15(ve p)-.25 H(rograms such as)
|
||||
.15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 659.4 S
|
||||
.288(group of functional interf)-18.712 F .287(aces to services pro)-.1
|
||||
F .287(vided by the shell, such as the traditional)-.15 F/F6 10
|
||||
/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 659.4 S .789
|
||||
/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 671.4 S .789
|
||||
(ibrary function.)-3.289 F .789(There are functions to perform shell w)
|
||||
5.789 F .789(ord e)-.1 F .79(xpansions, perform \214lename e)-.15 F
|
||||
(xpan-)-.15 E .324(sion \()97 671.4 R F1(globbing)A F3 .324
|
||||
(\), obtain v)B .323(alues of POSIX.2 system con\214guration v)-.25 F
|
||||
.323(ariables, retrie)-.25 F .623 -.15(ve v)-.25 H .323(alues of en)-.1
|
||||
F(viron-)-.4 E(ment v)97 683.4 Q(ariables \()-.25 E F6(getenv\(\))A F3
|
||||
(\), and other services;).833 E .32 LW 144 691.4 72 691.4 DL F4
|
||||
(*An earlier v)72 703.2 Q
|
||||
(xpan-)-.15 E 3.624(sion \()97 683.4 R F1(globbing)A F3 3.624
|
||||
(\), obtain v)B 3.624(alues of POSIX.2 system con\214guration v)-.25 F
|
||||
3.623(ariables, retrie)-.25 F 3.923 -.15(ve v)-.25 H 3.623(alues of)-.1
|
||||
F .32 LW 144 691.4 72 691.4 DL F4(*An earlier v)72 703.2 Q
|
||||
(ersion of this article appeared in The Linux Journal.)-.12 E(\210IEEE,)
|
||||
72 715 Q/F7 8/Times-Italic@0 SF 1.231(IEEE Standar)3.231 F 3.231(df)
|
||||
-.296 G 1.231(or Information T)-3.231 F(ec)-.736 E(hnolo)-.12 E 1.231
|
||||
(gy -- P)-.08 F 1.231(ortable Oper)-.64 F 1.232
|
||||
(ating System Interface \(POSIX\) P)-.12 F 1.232(art 2:)-.64 F
|
||||
(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E EP
|
||||
(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E 0 Cg EP
|
||||
%%Page: 2 2
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q 21.5<8341>72 84 S
|
||||
(suite of \231de)-19 E -.15(ve)-.25 G(lopment\232 utilities such as).15
|
||||
E/F1 10/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)
|
||||
-.15 E F1(cc)2.5 E F0(\), and)A F1(yacc.)2.5 E F0 .483
|
||||
(Bash is concerned with the aspects of the shell')97 99.6 R 2.983(sb)
|
||||
/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q(en)97 84 Q(vironment v)-.4 E
|
||||
(ariables \()-.25 E/F1 10/Courier@0 SF(getenv\(\))A F0
|
||||
(\), and other services;).833 E 21.5<8341>72 99.6 S(suite of \231de)-19
|
||||
E -.15(ve)-.25 G(lopment\232 utilities such as).15 E/F2 10
|
||||
/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)-.15 E
|
||||
F2(cc)2.5 E F0(\), and)A F2(yacc.)2.5 E F0 .483
|
||||
(Bash is concerned with the aspects of the shell')97 115.2 R 2.983(sb)
|
||||
-.55 G(eha)-2.983 E .484(vior de\214ned by POSIX.2.)-.2 F .484
|
||||
(The shell command)5.484 F 1.439
|
||||
(language has of course been standardized, including the basic \215o)72
|
||||
111.6 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15
|
||||
127.2 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15
|
||||
G 1.438(cution con-).15 F 1.284
|
||||
(structs, I/O redirection and pipelining, ar)72 123.6 R 1.284
|
||||
(structs, I/O redirection and pipelining, ar)72 139.2 R 1.284
|
||||
(gument handling, v)-.18 F 1.284(ariable e)-.25 F 1.284
|
||||
(xpansion, and quoting.)-.15 F(The)6.285 E F1(special)3.785 E F0 -.2(bu)
|
||||
72 135.6 S .676
|
||||
(xpansion, and quoting.)-.15 F(The)6.285 E F2(special)3.785 E F0 -.2(bu)
|
||||
72 151.2 S .676
|
||||
(iltins, which must be implemented as part of the shell to pro).2 F .676
|
||||
(vide the desired functionality)-.15 F 3.176(,a)-.65 G .676
|
||||
(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 147.6 R .7
|
||||
(xamples of these are)-.15 F/F2 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201
|
||||
H(l).15 E F0(and)3.201 E F2(export)3.201 E F0 5.701(.O)C .701
|
||||
(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 163.2 R .7
|
||||
(xamples of these are)-.15 F/F3 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201
|
||||
H(l).15 E F0(and)3.201 E F3(export)3.201 E F0 5.701(.O)C .701
|
||||
(ther utilities appear in the sections of)-5.701 F .256(POSIX.2 not de)
|
||||
72 159.6 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\
|
||||
72 175.2 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\
|
||||
in some cases must be\) implemented as b).2 F(uiltin)-.2 E .213
|
||||
(commands, such as)72 171.6 R F2 -.18(re)2.713 G(ad).18 E F0(and)2.713 E
|
||||
F2(test)2.713 E F0 5.213(.P)C .213
|
||||
(commands, such as)72 187.2 R F3 -.18(re)2.713 G(ad).18 E F0(and)2.713 E
|
||||
F3(test)2.713 E F0 5.213(.P)C .213
|
||||
(OSIX.2 also speci\214es aspects of the shell')-5.213 F 2.713(si)-.55 G
|
||||
(nteracti)-2.713 E .513 -.15(ve b)-.25 H(eha).15 E .214(vior as part)-.2
|
||||
F .598(of the UPE, including job control and command line editing.)72
|
||||
183.6 R .598(Interestingly enough, only)5.598 F F1(vi)3.098 E F0 .598
|
||||
(-style line edit-)B(ing commands ha)72 195.6 Q .3 -.15(ve b)-.2 H
|
||||
(een standardized;).15 E F1(emacs)2.5 E F0
|
||||
199.2 R .598(Interestingly enough, only)5.598 F F2(vi)3.098 E F0 .598
|
||||
(-style line edit-)B(ing commands ha)72 211.2 Q .3 -.15(ve b)-.2 H
|
||||
(een standardized;).15 E F2(emacs)2.5 E F0
|
||||
(editing commands were left out due to objections.)2.5 E 1.128
|
||||
(While POSIX.2 includes much of what the shell has traditionally pro)97
|
||||
211.2 R 1.129(vided, some important things)-.15 F(ha)72 223.2 Q .344
|
||||
226.8 R 1.129(vided, some important things)-.15 F(ha)72 238.8 Q .344
|
||||
-.15(ve b)-.2 H .044(een omitted as being \231be).15 F .044
|
||||
(yond its scope.)-.15 F 5.043<9a54>-.7 G .043
|
||||
(here is, for instance, no mention of a dif)-5.043 F .043
|
||||
(ference between a)-.25 F F1(lo)72 235.2 Q(gin)-.1 E F0 1.445
|
||||
(ference between a)-.25 F F2(lo)72 250.8 Q(gin)-.1 E F0 1.445
|
||||
(shell and an)3.945 F 3.945(yo)-.15 G 1.445(ther interacti)-3.945 F
|
||||
1.745 -.15(ve s)-.25 H 1.446
|
||||
(hell \(since POSIX.2 does not specify a login program\).).15 F 1.446
|
||||
(No \214x)6.446 F(ed)-.15 E(startup \214les are de\214ned, either \255 \
|
||||
the standard does not mention)72 247.2 Q F1(.pr)2.5 E(o\214le)-.45 E F0
|
||||
(.)A F2 2.5(3. Basic)72 271.2 R(Bash featur)2.5 E(es)-.18 E F0 1.448
|
||||
(Since the Bourne shell pro)97 286.8 R 1.448
|
||||
the standard does not mention)72 262.8 Q F2(.pr)2.5 E(o\214le)-.45 E F0
|
||||
(.)A F3 2.5(3. Basic)72 286.8 R(Bash featur)2.5 E(es)-.18 E F0 1.448
|
||||
(Since the Bourne shell pro)97 302.4 R 1.448
|
||||
(vides Bash with most of its philosophical underpinnings, Bash inherits)
|
||||
-.15 F .64(most of its features and functionality from sh.)72 298.8 R
|
||||
-.15 F .64(most of its features and functionality from sh.)72 314.4 R
|
||||
.641(Bash implements all of the traditional sh \215o)5.641 F 3.141(wc)
|
||||
-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 310.8 R F1(for)A F0(,)
|
||||
A F1(if)3.3 E F0(,)A F1(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F
|
||||
-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 326.4 R F2(for)A F0(,)
|
||||
A F2(if)3.3 E F0(,)A F2(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F
|
||||
.799(of the Bourne shell b)3.3 F .799
|
||||
(uiltins, including those not speci\214ed in the POSIX.2)-.2 F .536
|
||||
(standard, appear in Bash.)72 322.8 R(Shell)5.536 E F1(functions)3.036 E
|
||||
(standard, appear in Bash.)72 338.4 R(Shell)5.536 E F2(functions)3.036 E
|
||||
F0 3.036(,i)C .536(ntroduced in the SVR2 v)-3.036 F .537
|
||||
(ersion of the Bourne shell, are similar)-.15 F .779
|
||||
(to shell scripts, b)72 334.8 R .779
|
||||
(to shell scripts, b)72 350.4 R .779
|
||||
(ut are de\214ned using a special syntax and are e)-.2 F -.15(xe)-.15 G
|
||||
.779(cuted in the same process as the calling).15 F 2.841(shell. Bash)72
|
||||
346.8 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H
|
||||
362.4 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H
|
||||
2.841(naf).15 G .341(ashion upw)-2.941 F .342
|
||||
(ard-compatible with sh functions.)-.1 F .342(There are)5.342 F 1.447
|
||||
(certain shell v)72 358.8 R 1.446
|
||||
(certain shell v)72 374.4 R 1.446
|
||||
(ariables that Bash interprets in the same w)-.25 F 1.446
|
||||
(ay as sh, such as)-.1 F F2(PS1)3.946 E F0(,)A F2(IFS)3.946 E F0 3.946
|
||||
(,a)C(nd)-3.946 E F2 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446
|
||||
E 1.423(implements essentially the same grammar)72 370.8 R 3.924(,p)-.4
|
||||
(ay as sh, such as)-.1 F F3(PS1)3.946 E F0(,)A F3(IFS)3.946 E F0 3.946
|
||||
(,a)C(nd)-3.946 E F3 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446
|
||||
E 1.423(implements essentially the same grammar)72 386.4 R 3.924(,p)-.4
|
||||
G 1.424(arameter and v)-3.924 F 1.424(ariable e)-.25 F 1.424
|
||||
(xpansion semantics, redirection, and)-.15 F 1.06
|
||||
(quoting as the Bourne shell.)72 382.8 R 1.06(Where dif)6.06 F 1.06
|
||||
(quoting as the Bourne shell.)72 398.4 R 1.06(Where dif)6.06 F 1.06
|
||||
(ferences appear between the POSIX.2 standard and traditional sh)-.25 F
|
||||
(beha)72 394.8 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25
|
||||
E 1.608(The K)97 410.4 R 1.608(orn Shell \()-.35 F F2(ksh)A F0 4.108
|
||||
(\)i)C 4.108(sad)-4.108 G 1.608
|
||||
(escendent of the Bourne shell written at A)-4.108 F 1.609
|
||||
(T&T Bell Laboratories by)-1.11 F(Da)72 422.4 Q 1.059(vid K)-.2 F 3.559
|
||||
(orn\207. It)-.35 F(pro)3.559 E 1.059
|
||||
(beha)72 410.4 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25
|
||||
E 1.608(The K)97 426 R 1.608(orn Shell \()-.35 F F3(ksh)A F0 4.108(\)i)C
|
||||
4.108(sad)-4.108 G 1.608(escendant of the Bourne shell written at A)
|
||||
-4.108 F 1.609(T&T Bell Laboratories by)-1.11 F(Da)72 438 Q 1.059(vid K)
|
||||
-.2 F 3.559(orn\207. It)-.35 F(pro)3.559 E 1.059
|
||||
(vides a number of useful features that POSIX and Bash ha)-.15 F 1.359
|
||||
-.15(ve a)-.2 H 3.558(dopted. Man).15 F 3.558(yo)-.15 G 3.558(ft)-3.558
|
||||
G(he)-3.558 E(interacti)72 434.4 Q 1.312 -.15(ve f)-.25 H 1.012
|
||||
G(he)-3.558 E(interacti)72 450 Q 1.312 -.15(ve f)-.25 H 1.012
|
||||
(acilities in POSIX.2 ha).05 F 1.312 -.15(ve t)-.2 H 1.012
|
||||
(heir roots in the ksh: for e).15 F 1.013
|
||||
(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 446.4 S .513
|
||||
(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 462 S .513
|
||||
(cilities are nearly identical. Bash includes features from the K).1 F
|
||||
.513(orn Shell for both interacti)-.35 F .813 -.15(ve u)-.25 H .513
|
||||
(se and shell).15 F 3.905(programming. F)72 458.4 R 1.405
|
||||
(se and shell).15 F 3.905(programming. F)72 474 R 1.405
|
||||
(or programming, Bash pro)-.15 F 1.405(vides v)-.15 F 1.405
|
||||
(ariables such as)-.25 F F2(RANDOM)3.905 E F0(and)3.905 E F2(REPL)3.905
|
||||
E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F2(typeset)3.905 E F0 -.2(bu)72
|
||||
470.4 S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398
|
||||
(ariables such as)-.25 F F3(RANDOM)3.905 E F0(and)3.905 E F3(REPL)3.905
|
||||
E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F3(typeset)3.905 E F0 -.2(bu)72 486
|
||||
S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398
|
||||
(ubstrings from v).15 F .398
|
||||
(ariables based on patterns, and shell arithmetic.)-.25 F F2(RANDOM)
|
||||
5.397 E F0 -.15(ex)72 482.4 S .489
|
||||
(ariables based on patterns, and shell arithmetic.)-.25 F F3(RANDOM)
|
||||
5.397 E F0 -.15(ex)72 498 S .489
|
||||
(pands to a random number each time it is referenced; assigning a v).15
|
||||
F .49(alue to)-.25 F F2(RANDOM)2.99 E F0 .49(seeds the random)2.99 F
|
||||
.055(number generator)72 494.4 R(.)-.55 E F2(REPL)5.055 E(Y)-.92 E F0
|
||||
.054(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25
|
||||
F F2 -.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2
|
||||
F .054(ariable names are sup-)-.25 F .742(plied as ar)72 506.4 R 3.243
|
||||
(guments. The)-.18 F F2(typeset)3.243 E F0 -.2(bu)3.243 G .743
|
||||
F .49(alue to)-.25 F F3(RANDOM)2.99 E F0 .49(seeds the random)2.99 F
|
||||
.055(number generator)72 510 R(.)-.55 E F3(REPL)5.055 E(Y)-.92 E F0 .054
|
||||
(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25 F F3
|
||||
-.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2 F
|
||||
.054(ariable names are sup-)-.25 F .742(plied as ar)72 522 R 3.243
|
||||
(guments. The)-.18 F F3(typeset)3.243 E F0 -.2(bu)3.243 G .743
|
||||
(iltin is used to de\214ne v).2 F .743(ariables and gi)-.25 F 1.043 -.15
|
||||
(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F2 -.18(re)
|
||||
3.243 G(ad-).18 E(only)72 518.4 Q F0 5.512(.B)C .512
|
||||
(ash arithmetic allo)-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511
|
||||
(luation of an e).25 F .511
|
||||
(xpression and the substitution of the result.)-.15 F .511(Shell v)5.511
|
||||
F(ari-)-.25 E .222
|
||||
(ables may be used as operands, and the result of an e)72 530.4 R .222
|
||||
(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F3 -.18(re)
|
||||
3.243 G(ad-).18 E(only)72 534 Q F0 5.512(.B)C .512(ash arithmetic allo)
|
||||
-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511(luation of an e).25 F
|
||||
.511(xpression and the substitution of the result.)-.15 F .511(Shell v)
|
||||
5.511 F(ari-)-.25 E .222
|
||||
(ables may be used as operands, and the result of an e)72 546 R .222
|
||||
(xpression may be assigned to a v)-.15 F 2.722(ariable. Nearly)-.25 F
|
||||
.222(all of)2.722 F(the operators from the C language are a)72 542.4 Q
|
||||
-.25(va)-.2 G(ilable, with the same precedence rules:).25 E/F3 10
|
||||
/Courier@0 SF 6($e)97 560.4 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 572.4
|
||||
Q F0 -.15(Fo)72 594 S 3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25
|
||||
H .74(se, Bash implements ksh-style aliases and b).15 F .74
|
||||
(uiltins such as)-.2 F F2(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74
|
||||
(w\) and)-.25 F F2(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 606 R
|
||||
2.791(was)-.25 G .291(tring to be substituted for a command name.)-2.791
|
||||
F(The)5.291 E 2.791(yc)-.15 G .291(an be used to create a mnemonic)
|
||||
-2.791 F .568(for a)72 618 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568
|
||||
(command name \()3.068 F F3 .568(alias del=rm)B F0 .568(\), to e)B .567
|
||||
.222(all of)2.722 F(the operators from the C language are a)72 558 Q
|
||||
-.25(va)-.2 G(ilable, with the same precedence rules:).25 E F1 6($e)97
|
||||
576 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 588 Q F0 -.15(Fo)72 609.6 S
|
||||
3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25 H .74
|
||||
(se, Bash implements ksh-style aliases and b).15 F .74(uiltins such as)
|
||||
-.2 F F3(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74(w\) and)-.25 F F3
|
||||
(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 621.6 R 2.791(was)-.25 G
|
||||
.291(tring to be substituted for a command name.)-2.791 F(The)5.291 E
|
||||
2.791(yc)-.15 G .291(an be used to create a mnemonic)-2.791 F .568
|
||||
(for a)72 633.6 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568
|
||||
(command name \()3.068 F F1 .568(alias del=rm)B F0 .568(\), to e)B .567
|
||||
(xpand a single w)-.15 F .567(ord to a comple)-.1 F 3.067(xc)-.15 G .567
|
||||
(ommand \()-3.067 F F3(alias)A .255
|
||||
(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 630 R F0 .255
|
||||
(\), or to ensure that a command)B(is in)72 642 Q -.2(vo)-.4 G -.1(ke).2
|
||||
G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F3
|
||||
(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 657.6 R F2(csh)
|
||||
(ommand \()-3.067 F F1(alias)A .255
|
||||
(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 645.6 R F0 .255
|
||||
(\), or to ensure that a command)B(is in)72 657.6 Q -.2(vo)-.4 G -.1(ke)
|
||||
.2 G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F1
|
||||
(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 673.2 R F3(csh)
|
||||
A F0 .293(\)\207, originally written by Bill Jo)B 2.792(yw)-.1 G .292
|
||||
(hile at Berk)-2.792 F(ele)-.1 E 1.592 -.65(y, i)-.15 H 2.792(sw).65 G
|
||||
.292(idely used and quite popular)-2.792 F 1.499(for its interacti)72
|
||||
669.6 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499
|
||||
685.2 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499
|
||||
(includes a csh-compatible history e)3.999 F 1.5
|
||||
(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 681.6
|
||||
R .018(xpansion, access to a stack of directories via the)-.15 F F2
|
||||
(pushd)2.518 E F0(,)A F2(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F2(dirs)
|
||||
(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 697.2
|
||||
R .018(xpansion, access to a stack of directories via the)-.15 F F3
|
||||
(pushd)2.518 E F0(,)A F3(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F3(dirs)
|
||||
2.518 E F0 -.2(bu)2.518 G .018(iltins, and tilde e).2 F(xpansion,)-.15 E
|
||||
1.293(to generate users' home directories.)72 693.6 R -.35(Ti)6.294 G
|
||||
1.293(to generate users' home directories.)72 709.2 R -.35(Ti)6.294 G
|
||||
1.294(lde e).35 F 1.294(xpansion has also been adopted by both the K)
|
||||
-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 708.2 72 708.2 DL/F5 8
|
||||
/Times-Roman@0 SF(\207Morris Bolsk)72 720 Q 2(ya)-.12 G(nd Da)-2 E
|
||||
-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 717.2 72 717.2 DL/F5 8
|
||||
/Times-Roman@0 SF(\207Morris Bolsk)72 727.2 Q 2(ya)-.12 G(nd Da)-2 E
|
||||
(vid K)-.16 E(orn,)-.28 E/F6 8/Times-Italic@0 SF(The K)2 E
|
||||
(ornShell Command and Pr)-.32 E -.08(og)-.36 G -.12(ra).08 G
|
||||
(mming Langua).12 E -.08(ge)-.08 G F5 2(,P).08 G(rentice Hall, 1989.)-2
|
||||
E EP
|
||||
E 0 Cg EP
|
||||
%%Page: 3 3
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -520,10 +543,10 @@ tput of the command contained within the parentheses, with)-.15 F .664
|
||||
(xpansion, the ability to de\214ne a v)-.15 F(ariable)-.25 E .283
|
||||
(and a function with the same name, local v)72 398.4 R .282
|
||||
(ariables in shell functions, the ability to enable and disable indi-)
|
||||
-.25 F .547(vidual b)72 410.4 R .547
|
||||
(uiltins or write a function to replace a b)-.2 F .547
|
||||
(uiltin, or a means to e)-.2 F .547
|
||||
(xport a shell function to a child pro-)-.15 F(cess.)72 422.4 Q .32
|
||||
-.25 F 1.532(vidual b)72 410.4 R 1.532
|
||||
(uiltins or write a function to replace a b)-.2 F 1.533
|
||||
(uiltin, or a means to e)-.2 F 1.533(xport a shell function to a child)
|
||||
-.15 F(process.)72 422.4 Q .32
|
||||
(Bash has closed a long-standing shell security hole by not using the)97
|
||||
438 R F1($IFS)2.82 E F0 -.25(va)2.82 G .32(riable to split each w).25 F
|
||||
(ord)-.1 E 1.254(read by the shell, b)72 450 R 1.254
|
||||
@@ -580,11 +603,11 @@ E F1($ENV)2.842 E F0 2.841(,i)C 2.841(fs)-2.841 G .341
|
||||
(on out here.)-.1 F(Interestingly)5.158 E 2.658(,t)-.65 G .158(he ne)
|
||||
-2.658 F .159(xt release of ksh will change to reading)-.15 F F1($ENV)
|
||||
2.659 E .32 LW 144 705.2 72 705.2 DL/F4 8/Times-Roman@0 SF .559
|
||||
(\207Bill Jo)72 717 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559
|
||||
(\207Bill Jo)72 715.2 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559
|
||||
(ntroduction to the C Shell,)-2.559 F/F5 8/Times-Italic@0 SF .558
|
||||
(UNIX User')2.558 F 2.558(sS)-.32 G .558(upplementary Documents)-2.558 F
|
||||
F4 2.558(,U)C(ni)-2.558 E -.12(ve)-.2 G .558(rsity of California at).12
|
||||
F(Berk)72 727 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E EP
|
||||
F(Berk)72 725.2 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E 0 Cg EP
|
||||
%%Page: 4 4
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -696,7 +719,7 @@ R -.15(ey)-.1 G 1.196(map to which subsequent k).15 F 1.496 -.15(ey b)
|
||||
-3.031 G -.15(ve)-3.281 G 3.031(nw).15 G .531
|
||||
(hat happens when readline w)-3.031 F .531(ants to ring the terminal')
|
||||
-.1 F 3.03(sb)-.55 G 3.03(ell. All)-3.03 F .53(of these v)3.03 F
|
||||
(ariables)-.25 E EP
|
||||
(ariables)-.25 E 0 Cg EP
|
||||
%%Page: 5 5
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -724,9 +747,9 @@ S(repare to type a quoted word -- insert open and close double)-6 E 6
|
||||
249.6 Q($endif)97 261.6 Q F0 .322(There is a readline command to re-rea\
|
||||
d the \214le, so users can edit the \214le, change some bindings, and b\
|
||||
e)72 283.2 R(gin)-.15 E(to use them almost immediately)72 295.2 Q(.)-.65
|
||||
E .851(Bash implements the)97 310.8 R F1(bind)3.351 E F0 -.2(bu)3.351 G
|
||||
.851(iltin for more dyamic control of readline than the startup \214le \
|
||||
permits.).2 F F1(Bind)72 322.8 Q F0 .25(is used in se)2.75 F -.15(ve)
|
||||
E .518(Bash implements the)97 310.8 R F1(bind)3.018 E F0 -.2(bu)3.018 G
|
||||
.518(iltin for more dynamic control of readline than the startup \214le\
|
||||
permits.).2 F F1(Bind)72 322.8 Q F0 .25(is used in se)2.75 F -.15(ve)
|
||||
-.25 G .25(ral w).15 F 2.75(ays. In)-.1 F/F3 10/Times-Italic@0 SF(list)
|
||||
2.75 E F0 .25(mode, it can display the current k)2.75 F .55 -.15(ey b)
|
||||
-.1 H .25(indings, list all the readline edit-).15 F .149(ing directi)72
|
||||
@@ -781,11 +804,11 @@ lly quite good at determining what type of completion to attempt.)72
|
||||
(and the readline library)72 570 R 5.077(.B)-.65 G .077(ash pro)-5.077 F
|
||||
.077(vides v)-.15 F .077(ariables \()-.25 F F1($HISTFILE)A F0(,)A F1
|
||||
($HISTSIZE)2.577 E F0 2.577(,a)C(nd)-2.577 E F1($HISTCONTR)2.577 E(OL)
|
||||
-.3 E F0 2.577(\)a)C(nd)-2.577 E(the)72 582 Q F1(history)2.89 E F0(and)
|
||||
2.89 E F1(fc)2.89 E F0 -.2(bu)2.89 G .39
|
||||
(iltins to manipulate the history list.).2 F .391(The v)5.391 F .391
|
||||
(alue of)-.25 F F1($HISTFILE)2.891 E F0 .391(specifes the \214le where)
|
||||
2.891 F .49(Bash writes the command history on e)72 594 R .489
|
||||
-.3 E F0 2.577(\)a)C(nd)-2.577 E(the)72 582 Q F1(history)2.759 E F0(and)
|
||||
2.759 E F1(fc)2.759 E F0 -.2(bu)2.759 G .259
|
||||
(iltins to manipulate the history list.).2 F .26(The v)5.259 F .26
|
||||
(alue of)-.25 F F1($HISTFILE)2.76 E F0 .26(speci\214es the \214le where)
|
||||
2.76 F .49(Bash writes the command history on e)72 594 R .489
|
||||
(xit and reads it on startup.)-.15 F F1($HISTSIZE)5.489 E F0 .489
|
||||
(is used to limit the number)2.989 F .642(of commands sa)72 606 R -.15
|
||||
(ve)-.2 G 3.142(di).15 G 3.142(nt)-3.142 G .642(he history)-3.142 F(.)
|
||||
@@ -820,7 +843,7 @@ or a string typed by the user)72 690 R(.)-.55 E(Finally)72 702 Q 2.535
|
||||
-.15(xe)-.15 G 1.022(cution of pre).15 F 1.022(vious commands v)-.25 F
|
||||
1.022(ery similar to csh \(\231bang history\232, so)-.15 F
|
||||
(called because the e)72 726 Q
|
||||
(xclamation point introduces a history substitution\):)-.15 E EP
|
||||
(xclamation point introduces a history substitution\):)-.15 E 0 Cg EP
|
||||
%%Page: 6 6
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -903,7 +926,7 @@ e)-.15 F .104(when opened.)72 648 R .103
|
||||
(xpansion. Process)-.15 F .103(substitution can be used to com-)2.603 F
|
||||
(pare the outputs of tw)72 660 Q 2.5(od)-.1 G(if)-2.5 E(ferent v)-.25 E
|
||||
(ersions of an application as part of a re)-.15 E(gression test:)-.15 E
|
||||
F1 6($c)97 678 S(mp <\(old_prog\) <\(new_prog\))-6 E EP
|
||||
F1 6($c)97 678 S(mp <\(old_prog\) <\(new_prog\))-6 E 0 Cg EP
|
||||
%%Page: 7 7
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -998,7 +1021,7 @@ G .367
|
||||
E(/usr/local/bin)97 624 Q 6($/)97 636 S(bin/pwd)-6 E
|
||||
(/net/share/sun4/local/bin)97 648 Q 6($c)97 660 S 6(d.)-6 G(.)-6 E 6($p)
|
||||
97 672 S(wd)-6 E(/usr/local)97 684 Q 6($/)97 696 S(bin/pwd)-6 E
|
||||
(/net/share/sun4/local)97 708 Q 6($c)97 720 S 6(d.)-6 G(.)-6 E EP
|
||||
(/net/share/sun4/local)97 708 Q 6($c)97 720 S 6(d.)-6 G(.)-6 E 0 Cg EP
|
||||
%%Page: 8 8
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -1097,7 +1120,7 @@ such)-2.931 F .136
|
||||
(nting the use of these sequences in earlier v).15 F .559(ersions, b)
|
||||
-.15 F .559(ut the readline redisplay algorithm assumed)-.2 F
|
||||
(each character occupied ph)72 720 Q(ysical screen space and w)-.05 E
|
||||
(ould wrap lines prematurely)-.1 E(.)-.65 E EP
|
||||
(ould wrap lines prematurely)-.1 E(.)-.65 E 0 Cg EP
|
||||
%%Page: 9 9
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -1244,7 +1267,7 @@ F F1(HISTIGNORE)4.286 E F0 4.285(,w)C 1.785(hich w)-4.285 F 1.785
|
||||
(mentation to be printed by the)72 697.2 R F1(help)3.851 E F0 1.351
|
||||
(command \(possibly present in the shared object as well\).)3.851 F
|
||||
1.351(It w)6.351 F(ould)-.1 E(manage the details of e)72 709.2 Q
|
||||
(xtending the internal table of b)-.15 E(uiltins.)-.2 E EP
|
||||
(xtending the internal table of b)-.15 E(uiltins.)-.2 E 0 Cg EP
|
||||
%%Page: 10 10
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -1256,14 +1279,14 @@ BP
|
||||
(command, which prints)3.292 F 1.412(the v)72 96 R 1.412
|
||||
(alues of system con\214guration v)-.25 F 1.411
|
||||
(ariables de\214ned by POSIX.2, and a)-.25 F F1(diso)3.911 E(wn)-.1 E F0
|
||||
-.2(bu)3.911 G 1.411(iltin, which causes a).2 F 1.347
|
||||
(shell running with job control acti)72 108 R 1.647 -.15(ve t)-.25 H
|
||||
3.847<6f99>.15 G(for)-3.847 E 1.347
|
||||
(get about\232 one or more background jobs in its internal jobs)-.18 F
|
||||
3.465(table. Using)72 120 R F1(getconf)3.465 E F0 3.465(,f)C .965(or e)
|
||||
-3.465 F .965(xample, a user could retrie)-.15 F 1.264 -.15(ve a v)-.25
|
||||
H .964(alue for)-.1 F F1($P)3.464 E -.95(AT)-.74 G(H).95 E F0 .964
|
||||
(guaranteed to \214nd all of the)3.464 F .884
|
||||
-.2(bu)3.911 G 1.411(iltin, which causes a).2 F .547
|
||||
(shell running with job control acti)72 108 R .847 -.15(ve t)-.25 H
|
||||
3.047<6f99>.15 G(for)-3.047 E .547
|
||||
(get about\232 one or more background jobs in its internal jobs ta-)-.18
|
||||
F 3.866(ble. Using)72 120 R F1(getconf)3.866 E F0 3.866(,f)C 1.366(or e)
|
||||
-3.866 F 1.366(xample, a user could retrie)-.15 F 1.666 -.15(ve a v)-.25
|
||||
H 1.365(alue for)-.1 F F1($P)3.865 E -.95(AT)-.74 G(H).95 E F0 1.365
|
||||
(guaranteed to \214nd all of the)3.865 F .884
|
||||
(POSIX standard utilities, or \214nd out ho)72 132 R 3.385(wl)-.25 G
|
||||
.885
|
||||
(ong \214lenames may be in the \214le system containing a speci\214ed)
|
||||
@@ -1368,7 +1391,7 @@ E F0(for more information.)2.5 E .694(Bash is also distrib)97 656.4 R
|
||||
-.15(ve)-.25 G .948(ral Linux distrib).15 F .948
|
||||
(utions \(more about the dif)-.2 F .948
|
||||
(ference in a moment\), and as contrib)-.25 F(uted)-.2 E .32 LW 144
|
||||
676.4 72 676.4 DL/F5 8/Times-Roman@0 SF .781
|
||||
678.2 72 678.2 DL/F5 8/Times-Roman@0 SF .781
|
||||
(\207S. R. Bourne, \231UNIX T)72 688.2 R .781(ime-Sharing System:)-.28 F
|
||||
.781(The UNIX Shell\232,)4.781 F/F6 8/Times-Italic@0 SF .78
|
||||
(Bell System T)2.78 F(ec)-.736 E .78(hnical J)-.12 F(ournal)-.2 E F5
|
||||
@@ -1377,7 +1400,8 @@ E F0(for more information.)2.5 E .694(Bash is also distrib)97 656.4 R
|
||||
(f, \231Rc \255 A Shell for Plan 9 and)-.2 F/F7 7/Times-Roman@0 SF(UNIX)
|
||||
2.432 E F5(systems\232,)2.432 E F6(Pr)2.432 E .432
|
||||
(oc. of the Summer 1990 EUUG Confer)-.36 F(ence)-.296 E F5 2.432(,L)C
|
||||
(on-)-2.432 E(don, July)72 720 Q 2(,1)-.52 G(990, pp. 21-33.)-2 E EP
|
||||
(on-)-2.432 E(don, July)72 720 Q 2(,1)-.52 G(990, pp. 21-33.)-2 E 0 Cg
|
||||
EP
|
||||
%%Page: 11 11
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
@@ -1410,9 +1434,9 @@ F .8(It is suf)5.8 F .8(\214ciently portable to run on nearly e)-.25 F
|
||||
(ral thousand re).15 F 1.515(gular users, and their feedback has)-.15 F
|
||||
(helped to mak)72 235.2 Q 2.5(ei)-.1 G 2.5(ta)-2.5 G 2.5(sg)-2.5 G
|
||||
(ood as it is today \255 a testament to the bene\214ts of free softw)
|
||||
-2.5 E(are.)-.1 E .32 LW 144 708.2 72 708.2 DL/F4 8/Times-Roman@0 SF
|
||||
-2.5 E(are.)-.1 E .32 LW 144 710 72 710 DL/F4 8/Times-Roman@0 SF
|
||||
(*BSD/386 is a trademark of Berk)72 720 Q(ele)-.08 E 2(yS)-.12 G(oftw)-2
|
||||
E(are Design, Inc.)-.08 E EP
|
||||
E(are Design, Inc.)-.08 E 0 Cg EP
|
||||
%%Trailer
|
||||
end
|
||||
%%EOF
|
||||
|
||||
+1886
-1881
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -2373,7 +2373,7 @@ The value of \fIp\fP determines whether or not the fraction is
|
||||
included.
|
||||
.IP
|
||||
If this variable is not set, \fBbash\fP acts as if it had the
|
||||
value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\ett%3lS\(aq\fP.
|
||||
value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\et%3lS\(aq\fP.
|
||||
If the value is null, no timing information is displayed.
|
||||
A trailing newline is added when the format string is displayed.
|
||||
.PD 0
|
||||
|
||||
+2
-2
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@po.cwru.edu
|
||||
.\"
|
||||
.\" Last Change: Mon Oct 14 11:51:13 EDT 2013
|
||||
.\" Last Change: Sun Oct 20 22:13:29 EDT 2013
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2013 October 14" "GNU Bash 4.3"
|
||||
.TH BASH 1 "2013 October 20" "GNU Bash 4.3"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
|
||||
+15
-9
@@ -3,7 +3,7 @@
|
||||
</HEAD>
|
||||
<BODY><TABLE WIDTH=100%>
|
||||
<TR>
|
||||
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2013 September 2<TH ALIGN=RIGHT width=33%>BASH(1)
|
||||
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2013 October 20<TH ALIGN=RIGHT width=33%>BASH(1)
|
||||
</TR>
|
||||
</TABLE>
|
||||
<BR><A HREF="#index">Index</A>
|
||||
@@ -3307,15 +3307,19 @@ and
|
||||
|
||||
<P>
|
||||
|
||||
The order of expansions is: brace expansion, tilde expansion,
|
||||
parameter, variable and arithmetic expansion and
|
||||
command substitution
|
||||
(done in a left-to-right fashion), word splitting, and pathname
|
||||
expansion.
|
||||
The order of expansions is:
|
||||
brace expansion;
|
||||
tilde expansion, parameter and variable expansion, arithmetic expansion,
|
||||
and command substitution (done in a left-to-right fashion);
|
||||
word splitting;
|
||||
and pathname expansion.
|
||||
<P>
|
||||
|
||||
On systems that can support it, there is an additional expansion
|
||||
available: <I>process substitution</I>.
|
||||
This is performed at the
|
||||
same time as tilde, parameter, variable, and arithmetic expansion and
|
||||
command substitution.
|
||||
<P>
|
||||
|
||||
Only brace expansion, word splitting, and pathname expansion
|
||||
@@ -9010,7 +9014,7 @@ current frame is frame 0.
|
||||
The return value is 0 unless the shell is not executing a subroutine
|
||||
call or <I>expr</I> does not correspond to a valid position in the
|
||||
call stack.
|
||||
<DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]]] [<I>dir</I>]<DD>
|
||||
<DT><B>cd</B> [<B>-L</B>|[<B>-P</B> [<B>-e</B>]] [-@]] [<I>dir</I>]<DD>
|
||||
Change the current directory to <I>dir</I>.
|
||||
if <I>dir</I> is not supplied, the value of the
|
||||
<FONT SIZE=-1><B>HOME</B>
|
||||
@@ -9074,6 +9078,8 @@ option is supplied with
|
||||
and the current working directory cannot be successfully determined
|
||||
after a successful directory change, <B>cd</B> will return an unsuccessful
|
||||
status.
|
||||
On systems that support it, the <B>-@</B> option presents the extended
|
||||
attributes associated with a file as a directory.
|
||||
An argument of
|
||||
<B>-</B>
|
||||
|
||||
@@ -13141,7 +13147,7 @@ There may be only one active coprocess at a time.
|
||||
<HR>
|
||||
<TABLE WIDTH=100%>
|
||||
<TR>
|
||||
<TH ALIGN=LEFT width=33%>GNU Bash 4.3<TH ALIGN=CENTER width=33%>2013 September 2<TH ALIGN=RIGHT width=33%>BASH(1)
|
||||
<TH ALIGN=LEFT width=33%>GNU Bash 4.3<TH ALIGN=CENTER width=33%>2013 October 20<TH ALIGN=RIGHT width=33%>BASH(1)
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR>
|
||||
@@ -13247,6 +13253,6 @@ There may be only one active coprocess at a time.
|
||||
</DL>
|
||||
<HR>
|
||||
This document was created by man2html from bash.1.<BR>
|
||||
Time: 11 September 2013 09:17:53 EDT
|
||||
Time: 22 October 2013 11:07:59 EDT
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
+1732
-1725
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -155,11 +155,11 @@
|
||||
@xrdef{Modifying Shell Behavior-snt}{Section@tie 4.3}
|
||||
@xrdef{The Set Builtin-title}{The Set Builtin}
|
||||
@xrdef{The Set Builtin-snt}{Section@tie 4.3.1}
|
||||
@xrdef{Modifying Shell Behavior-pg}{58}
|
||||
@xrdef{The Set Builtin-pg}{58}
|
||||
@xrdef{Modifying Shell Behavior-pg}{59}
|
||||
@xrdef{The Set Builtin-pg}{59}
|
||||
@xrdef{The Shopt Builtin-title}{The Shopt Builtin}
|
||||
@xrdef{The Shopt Builtin-snt}{Section@tie 4.3.2}
|
||||
@xrdef{The Shopt Builtin-pg}{62}
|
||||
@xrdef{The Shopt Builtin-pg}{63}
|
||||
@xrdef{Special Builtins-title}{Special Builtins}
|
||||
@xrdef{Special Builtins-snt}{Section@tie 4.4}
|
||||
@xrdef{Special Builtins-pg}{68}
|
||||
|
||||
+8
-8
@@ -16,13 +16,13 @@
|
||||
\entry{test}{45}{\code {test}}
|
||||
\entry{[}{45}{\code {[}}
|
||||
\entry{times}{46}{\code {times}}
|
||||
\entry{trap}{46}{\code {trap}}
|
||||
\entry{trap}{47}{\code {trap}}
|
||||
\entry{umask}{47}{\code {umask}}
|
||||
\entry{unset}{48}{\code {unset}}
|
||||
\entry{alias}{48}{\code {alias}}
|
||||
\entry{bind}{48}{\code {bind}}
|
||||
\entry{builtin}{49}{\code {builtin}}
|
||||
\entry{caller}{49}{\code {caller}}
|
||||
\entry{caller}{50}{\code {caller}}
|
||||
\entry{command}{50}{\code {command}}
|
||||
\entry{declare}{50}{\code {declare}}
|
||||
\entry{echo}{52}{\code {echo}}
|
||||
@@ -30,18 +30,18 @@
|
||||
\entry{help}{53}{\code {help}}
|
||||
\entry{let}{53}{\code {let}}
|
||||
\entry{local}{53}{\code {local}}
|
||||
\entry{logout}{53}{\code {logout}}
|
||||
\entry{mapfile}{53}{\code {mapfile}}
|
||||
\entry{logout}{54}{\code {logout}}
|
||||
\entry{mapfile}{54}{\code {mapfile}}
|
||||
\entry{printf}{54}{\code {printf}}
|
||||
\entry{read}{55}{\code {read}}
|
||||
\entry{readarray}{56}{\code {readarray}}
|
||||
\entry{source}{56}{\code {source}}
|
||||
\entry{type}{56}{\code {type}}
|
||||
\entry{source}{57}{\code {source}}
|
||||
\entry{type}{57}{\code {type}}
|
||||
\entry{typeset}{57}{\code {typeset}}
|
||||
\entry{ulimit}{57}{\code {ulimit}}
|
||||
\entry{unalias}{58}{\code {unalias}}
|
||||
\entry{set}{58}{\code {set}}
|
||||
\entry{shopt}{62}{\code {shopt}}
|
||||
\entry{set}{59}{\code {set}}
|
||||
\entry{shopt}{63}{\code {shopt}}
|
||||
\entry{dirs}{91}{\code {dirs}}
|
||||
\entry{popd}{91}{\code {popd}}
|
||||
\entry{pushd}{92}{\code {pushd}}
|
||||
|
||||
+8
-8
@@ -12,7 +12,7 @@
|
||||
\entry {\code {break}}{41}
|
||||
\entry {\code {builtin}}{49}
|
||||
\initial {C}
|
||||
\entry {\code {caller}}{49}
|
||||
\entry {\code {caller}}{50}
|
||||
\entry {\code {cd}}{42}
|
||||
\entry {\code {command}}{50}
|
||||
\entry {\code {compgen}}{127}
|
||||
@@ -46,9 +46,9 @@
|
||||
\initial {L}
|
||||
\entry {\code {let}}{53}
|
||||
\entry {\code {local}}{53}
|
||||
\entry {\code {logout}}{53}
|
||||
\entry {\code {logout}}{54}
|
||||
\initial {M}
|
||||
\entry {\code {mapfile}}{53}
|
||||
\entry {\code {mapfile}}{54}
|
||||
\initial {P}
|
||||
\entry {\code {popd}}{91}
|
||||
\entry {\code {printf}}{54}
|
||||
@@ -60,16 +60,16 @@
|
||||
\entry {\code {readonly}}{44}
|
||||
\entry {\code {return}}{45}
|
||||
\initial {S}
|
||||
\entry {\code {set}}{58}
|
||||
\entry {\code {set}}{59}
|
||||
\entry {\code {shift}}{45}
|
||||
\entry {\code {shopt}}{62}
|
||||
\entry {\code {source}}{56}
|
||||
\entry {\code {shopt}}{63}
|
||||
\entry {\code {source}}{57}
|
||||
\entry {\code {suspend}}{100}
|
||||
\initial {T}
|
||||
\entry {\code {test}}{45}
|
||||
\entry {\code {times}}{46}
|
||||
\entry {\code {trap}}{46}
|
||||
\entry {\code {type}}{56}
|
||||
\entry {\code {trap}}{47}
|
||||
\entry {\code {type}}{57}
|
||||
\entry {\code {typeset}}{57}
|
||||
\initial {U}
|
||||
\entry {\code {ulimit}}{57}
|
||||
|
||||
Binary file not shown.
+22
-14
@@ -1,6 +1,6 @@
|
||||
<HTML>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<!-- Created on September, 11 2013 by texi2html 1.64 -->
|
||||
<!-- Created on October, 22 2013 by texi2html 1.64 -->
|
||||
<!--
|
||||
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
|
||||
Karl Berry <karl@freefriends.org>
|
||||
@@ -33,11 +33,11 @@ Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
|
||||
<H1>Bash Reference Manual</H1></P><P>
|
||||
|
||||
This text is a brief description of the features that are present in
|
||||
the Bash shell (version 4.3, 2 September 2013).
|
||||
the Bash shell (version 4.3, 20 October 2013).
|
||||
The Bash home page is <A HREF="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</A>.
|
||||
</P><P>
|
||||
|
||||
This is Edition 4.3, last updated 2 September 2013,
|
||||
This is Edition 4.3, last updated 20 October 2013,
|
||||
of <CITE>The GNU Bash Reference Manual</CITE>,
|
||||
for <CODE>Bash</CODE>, Version 4.3.
|
||||
</P><P>
|
||||
@@ -2183,16 +2183,18 @@ Expansion is performed on the command line after it has been split into
|
||||
</TABLE></BLOCKQUOTE>
|
||||
<P>
|
||||
|
||||
The order of expansions is: brace expansion, tilde expansion,
|
||||
parameter, variable, and arithmetic expansion and
|
||||
command substitution
|
||||
(done in a left-to-right fashion), word splitting, and filename
|
||||
expansion.
|
||||
The order of expansions is:
|
||||
brace expansion;
|
||||
tilde expansion, parameter and variable expansion, arithmetic expansion,
|
||||
and command substitution (done in a left-to-right fashion);
|
||||
word splitting;
|
||||
and filename expansion.
|
||||
</P><P>
|
||||
|
||||
On systems that can support it, there is an additional expansion
|
||||
available: <VAR>process substitution</VAR>. This is performed at the
|
||||
same time as parameter, variable, and arithmetic expansion and
|
||||
available: <VAR>process substitution</VAR>.
|
||||
This is performed at the
|
||||
same time as tilde, parameter, variable, and arithmetic expansion and
|
||||
command substitution.
|
||||
</P><P>
|
||||
|
||||
@@ -4297,7 +4299,7 @@ The return status is zero unless <VAR>n</VAR> is not greater than or equal to 1.
|
||||
|
||||
<DT><CODE>cd</CODE>
|
||||
<DD><A NAME="IDX71"></A>
|
||||
<TABLE><tr><td> </td><td class=example><pre>cd [-L|[-P [-e]]] [<VAR>directory</VAR>]
|
||||
<TABLE><tr><td> </td><td class=example><pre>cd [-L|[-P [-e]] [-@] [<VAR>directory</VAR>]
|
||||
</pre></td></tr></table><P>
|
||||
|
||||
Change the current working directory to <VAR>directory</VAR>.
|
||||
@@ -4331,6 +4333,12 @@ If the <SAMP>`-e'</SAMP> option is supplied with <SAMP>`-P'</SAMP>
|
||||
and the current working directory cannot be successfully determined
|
||||
after a successful directory change, <CODE>cd</CODE> will return an unsuccessful
|
||||
status.
|
||||
</P><P>
|
||||
|
||||
On systems that support it, the <SAMP>`-@'</SAMP> option presents the extended
|
||||
attributes associated with a file as a directory.
|
||||
</P><P>
|
||||
|
||||
If <VAR>directory</VAR> is <SAMP>`-'</SAMP>, it is converted to <CODE>$OLDPWD</CODE>
|
||||
before the directory change is attempted.
|
||||
</P><P>
|
||||
@@ -11067,7 +11075,7 @@ binding, variable assignment, and conditional syntax.
|
||||
# You can re-read the inputrc file with C-x C-r.
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# First, include any systemwide bindings and variable
|
||||
# First, include any system-wide bindings and variable
|
||||
# assignments from /etc/Inputrc
|
||||
$include /etc/Inputrc
|
||||
|
||||
@@ -17263,7 +17271,7 @@ to permit their use in free software.
|
||||
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD>
|
||||
</TR></TABLE>
|
||||
<H1>About this document</H1>
|
||||
This document was generated by <I>Chet Ramey</I> on <I>September, 11 2013</I>
|
||||
This document was generated by <I>Chet Ramey</I> on <I>October, 22 2013</I>
|
||||
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
||||
"><I>texi2html</I></A>
|
||||
<P></P>
|
||||
@@ -17425,7 +17433,7 @@ the following structure:
|
||||
<BR>
|
||||
<FONT SIZE="-1">
|
||||
This document was generated
|
||||
by <I>Chet Ramey</I> on <I>September, 11 2013</I>
|
||||
by <I>Chet Ramey</I> on <I>October, 22 2013</I>
|
||||
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
|
||||
"><I>texi2html</I></A>
|
||||
|
||||
|
||||
+164
-159
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 4.13 from
|
||||
/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.3, 2 September 2013).
|
||||
the Bash shell (version 4.3, 20 October 2013).
|
||||
|
||||
This is Edition 4.3, last updated 2 September 2013, of `The GNU Bash
|
||||
This is Edition 4.3, last updated 20 October 2013, of `The GNU Bash
|
||||
Reference Manual', for `Bash', Version 4.3.
|
||||
|
||||
Copyright (C) 1988-2013 Free Software Foundation, Inc.
|
||||
@@ -28,10 +28,10 @@ Bash Features
|
||||
*************
|
||||
|
||||
This text is a brief description of the features that are present in
|
||||
the Bash shell (version 4.3, 2 September 2013). The Bash home page is
|
||||
the Bash shell (version 4.3, 20 October 2013). The Bash home page is
|
||||
`http://www.gnu.org/software/bash/'.
|
||||
|
||||
This is Edition 4.3, last updated 2 September 2013, of `The GNU Bash
|
||||
This is Edition 4.3, last updated 20 October 2013, of `The GNU Bash
|
||||
Reference Manual', for `Bash', Version 4.3.
|
||||
|
||||
Bash contains features that appear in other popular shells, and some
|
||||
@@ -1447,14 +1447,15 @@ Expansion is performed on the command line after it has been split into
|
||||
* Quote Removal:: How and when quote characters are removed from
|
||||
words.
|
||||
|
||||
The order of expansions is: brace expansion, tilde expansion,
|
||||
parameter, variable, and arithmetic expansion and command substitution
|
||||
(done in a left-to-right fashion), word splitting, and filename
|
||||
expansion.
|
||||
The order of expansions is: brace expansion; tilde expansion,
|
||||
parameter and variable expansion, arithmetic expansion, and command
|
||||
substitution (done in a left-to-right fashion); word splitting; and
|
||||
filename expansion.
|
||||
|
||||
On systems that can support it, there is an additional expansion
|
||||
available: PROCESS SUBSTITUTION. This is performed at the same time as
|
||||
parameter, variable, and arithmetic expansion and command substitution.
|
||||
tilde, parameter, variable, and arithmetic expansion and command
|
||||
substitution.
|
||||
|
||||
Only brace expansion, word splitting, and filename expansion can
|
||||
change the number of words of the expansion; other expansions expand a
|
||||
@@ -2796,7 +2797,7 @@ standard.
|
||||
greater than or equal to 1.
|
||||
|
||||
`cd'
|
||||
cd [-L|[-P [-e]]] [DIRECTORY]
|
||||
cd [-L|[-P [-e]] [-@] [DIRECTORY]
|
||||
|
||||
Change the current working directory to DIRECTORY. If DIRECTORY
|
||||
is not supplied, the value of the `HOME' shell variable is used.
|
||||
@@ -2820,8 +2821,12 @@ standard.
|
||||
|
||||
If the `-e' option is supplied with `-P' and the current working
|
||||
directory cannot be successfully determined after a successful
|
||||
directory change, `cd' will return an unsuccessful status. If
|
||||
DIRECTORY is `-', it is converted to `$OLDPWD' before the
|
||||
directory change, `cd' will return an unsuccessful status.
|
||||
|
||||
On systems that support it, the `-@' option presents the extended
|
||||
attributes associated with a file as a directory.
|
||||
|
||||
If DIRECTORY is `-', it is converted to `$OLDPWD' before the
|
||||
directory change is attempted.
|
||||
|
||||
If a non-empty directory name from `CDPATH' is used, or if `-' is
|
||||
@@ -7555,7 +7560,7 @@ variable assignment, and conditional syntax.
|
||||
# You can re-read the inputrc file with C-x C-r.
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# First, include any systemwide bindings and variable
|
||||
# First, include any system-wide bindings and variable
|
||||
# assignments from /etc/Inputrc
|
||||
$include /etc/Inputrc
|
||||
|
||||
@@ -10533,7 +10538,7 @@ D.1 Index of Shell Builtin Commands
|
||||
* :: Bourne Shell Builtins.
|
||||
(line 11)
|
||||
* [: Bourne Shell Builtins.
|
||||
(line 254)
|
||||
(line 258)
|
||||
* alias: Bash Builtins. (line 11)
|
||||
* bg: Job Control Builtins.
|
||||
(line 7)
|
||||
@@ -10552,7 +10557,7 @@ D.1 Index of Shell Builtin Commands
|
||||
* compopt: Programmable Completion Builtins.
|
||||
(line 228)
|
||||
* continue: Bourne Shell Builtins.
|
||||
(line 76)
|
||||
(line 80)
|
||||
* declare: Bash Builtins. (line 149)
|
||||
* dirs: Directory Stack Builtins.
|
||||
(line 7)
|
||||
@@ -10561,21 +10566,21 @@ D.1 Index of Shell Builtin Commands
|
||||
* echo: Bash Builtins. (line 241)
|
||||
* enable: Bash Builtins. (line 303)
|
||||
* eval: Bourne Shell Builtins.
|
||||
(line 85)
|
||||
(line 89)
|
||||
* exec: Bourne Shell Builtins.
|
||||
(line 93)
|
||||
(line 97)
|
||||
* exit: Bourne Shell Builtins.
|
||||
(line 110)
|
||||
(line 114)
|
||||
* export: Bourne Shell Builtins.
|
||||
(line 117)
|
||||
(line 121)
|
||||
* fc: Bash History Builtins.
|
||||
(line 10)
|
||||
* fg: Job Control Builtins.
|
||||
(line 17)
|
||||
* getopts: Bourne Shell Builtins.
|
||||
(line 133)
|
||||
(line 137)
|
||||
* hash: Bourne Shell Builtins.
|
||||
(line 176)
|
||||
(line 180)
|
||||
* help: Bash Builtins. (line 332)
|
||||
* history: Bash History Builtins.
|
||||
(line 40)
|
||||
@@ -10593,34 +10598,34 @@ D.1 Index of Shell Builtin Commands
|
||||
* pushd: Directory Stack Builtins.
|
||||
(line 61)
|
||||
* pwd: Bourne Shell Builtins.
|
||||
(line 196)
|
||||
(line 200)
|
||||
* read: Bash Builtins. (line 473)
|
||||
* readarray: Bash Builtins. (line 560)
|
||||
* readonly: Bourne Shell Builtins.
|
||||
(line 206)
|
||||
(line 210)
|
||||
* return: Bourne Shell Builtins.
|
||||
(line 225)
|
||||
(line 229)
|
||||
* set: The Set Builtin. (line 11)
|
||||
* shift: Bourne Shell Builtins.
|
||||
(line 241)
|
||||
(line 245)
|
||||
* shopt: The Shopt Builtin. (line 9)
|
||||
* source: Bash Builtins. (line 569)
|
||||
* suspend: Job Control Builtins.
|
||||
(line 101)
|
||||
* test: Bourne Shell Builtins.
|
||||
(line 254)
|
||||
(line 258)
|
||||
* times: Bourne Shell Builtins.
|
||||
(line 330)
|
||||
(line 334)
|
||||
* trap: Bourne Shell Builtins.
|
||||
(line 336)
|
||||
(line 340)
|
||||
* type: Bash Builtins. (line 574)
|
||||
* typeset: Bash Builtins. (line 606)
|
||||
* ulimit: Bash Builtins. (line 612)
|
||||
* umask: Bourne Shell Builtins.
|
||||
(line 385)
|
||||
(line 389)
|
||||
* unalias: Bash Builtins. (line 703)
|
||||
* unset: Bourne Shell Builtins.
|
||||
(line 403)
|
||||
(line 407)
|
||||
* wait: Job Control Builtins.
|
||||
(line 76)
|
||||
|
||||
@@ -11133,134 +11138,134 @@ D.5 Concept Index
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top932
|
||||
Node: Introduction2852
|
||||
Node: What is Bash?3080
|
||||
Node: What is a shell?4193
|
||||
Node: Definitions6732
|
||||
Node: Basic Shell Features9650
|
||||
Node: Shell Syntax10869
|
||||
Node: Shell Operation11899
|
||||
Node: Quoting13193
|
||||
Node: Escape Character14496
|
||||
Node: Single Quotes14981
|
||||
Node: Double Quotes15329
|
||||
Node: ANSI-C Quoting16454
|
||||
Node: Locale Translation17698
|
||||
Node: Comments18594
|
||||
Node: Shell Commands19212
|
||||
Node: Simple Commands20084
|
||||
Node: Pipelines20715
|
||||
Node: Lists23453
|
||||
Node: Compound Commands25182
|
||||
Node: Looping Constructs26188
|
||||
Node: Conditional Constructs28651
|
||||
Node: Command Grouping39581
|
||||
Node: Coprocesses41060
|
||||
Node: GNU Parallel42893
|
||||
Node: Shell Functions46879
|
||||
Node: Shell Parameters51963
|
||||
Node: Positional Parameters56092
|
||||
Node: Special Parameters56992
|
||||
Node: Shell Expansions60051
|
||||
Node: Brace Expansion61977
|
||||
Node: Tilde Expansion64758
|
||||
Node: Shell Parameter Expansion67107
|
||||
Node: Command Substitution79401
|
||||
Node: Arithmetic Expansion80734
|
||||
Node: Process Substitution81666
|
||||
Node: Word Splitting82716
|
||||
Node: Filename Expansion84364
|
||||
Node: Pattern Matching86529
|
||||
Node: Quote Removal90229
|
||||
Node: Redirections90524
|
||||
Node: Executing Commands99688
|
||||
Node: Simple Command Expansion100358
|
||||
Node: Command Search and Execution102288
|
||||
Node: Command Execution Environment104625
|
||||
Node: Environment107611
|
||||
Node: Exit Status109270
|
||||
Node: Signals110892
|
||||
Node: Shell Scripts112860
|
||||
Node: Shell Builtin Commands115378
|
||||
Node: Bourne Shell Builtins117406
|
||||
Node: Bash Builtins137182
|
||||
Node: Modifying Shell Behavior164635
|
||||
Node: The Set Builtin164980
|
||||
Node: The Shopt Builtin175306
|
||||
Node: Special Builtins189727
|
||||
Node: Shell Variables190706
|
||||
Node: Bourne Shell Variables191146
|
||||
Node: Bash Variables193177
|
||||
Node: Bash Features220052
|
||||
Node: Invoking Bash220951
|
||||
Node: Bash Startup Files226729
|
||||
Node: Interactive Shells231758
|
||||
Node: What is an Interactive Shell?232168
|
||||
Node: Is this Shell Interactive?232817
|
||||
Node: Interactive Shell Behavior233632
|
||||
Node: Bash Conditional Expressions236920
|
||||
Node: Shell Arithmetic240922
|
||||
Node: Aliases243698
|
||||
Node: Arrays246254
|
||||
Node: The Directory Stack251235
|
||||
Node: Directory Stack Builtins251954
|
||||
Node: Controlling the Prompt254910
|
||||
Node: The Restricted Shell257682
|
||||
Node: Bash POSIX Mode259519
|
||||
Node: Job Control268906
|
||||
Node: Job Control Basics269366
|
||||
Node: Job Control Builtins274085
|
||||
Node: Job Control Variables278556
|
||||
Node: Command Line Editing279714
|
||||
Node: Introduction and Notation281386
|
||||
Node: Readline Interaction283008
|
||||
Node: Readline Bare Essentials284199
|
||||
Node: Readline Movement Commands285988
|
||||
Node: Readline Killing Commands286953
|
||||
Node: Readline Arguments288873
|
||||
Node: Searching289917
|
||||
Node: Readline Init File292103
|
||||
Node: Readline Init File Syntax293250
|
||||
Node: Conditional Init Constructs310087
|
||||
Node: Sample Init File312620
|
||||
Node: Bindable Readline Commands315737
|
||||
Node: Commands For Moving316944
|
||||
Node: Commands For History318088
|
||||
Node: Commands For Text322273
|
||||
Node: Commands For Killing324946
|
||||
Node: Numeric Arguments327403
|
||||
Node: Commands For Completion328542
|
||||
Node: Keyboard Macros332734
|
||||
Node: Miscellaneous Commands333422
|
||||
Node: Readline vi Mode339228
|
||||
Node: Programmable Completion340135
|
||||
Node: Programmable Completion Builtins347411
|
||||
Node: A Programmable Completion Example357157
|
||||
Node: Using History Interactively362407
|
||||
Node: Bash History Facilities363091
|
||||
Node: Bash History Builtins366090
|
||||
Node: History Interaction370018
|
||||
Node: Event Designators372723
|
||||
Node: Word Designators373945
|
||||
Node: Modifiers375584
|
||||
Node: Installing Bash376988
|
||||
Node: Basic Installation378125
|
||||
Node: Compilers and Options380817
|
||||
Node: Compiling For Multiple Architectures381558
|
||||
Node: Installation Names383222
|
||||
Node: Specifying the System Type384040
|
||||
Node: Sharing Defaults384756
|
||||
Node: Operation Controls385429
|
||||
Node: Optional Features386387
|
||||
Node: Reporting Bugs396451
|
||||
Node: Major Differences From The Bourne Shell397649
|
||||
Node: GNU Free Documentation License414508
|
||||
Node: Indexes439704
|
||||
Node: Builtin Index440158
|
||||
Node: Reserved Word Index446985
|
||||
Node: Variable Index449433
|
||||
Node: Function Index462956
|
||||
Node: Concept Index470184
|
||||
Node: Top930
|
||||
Node: Introduction2848
|
||||
Node: What is Bash?3076
|
||||
Node: What is a shell?4189
|
||||
Node: Definitions6728
|
||||
Node: Basic Shell Features9646
|
||||
Node: Shell Syntax10865
|
||||
Node: Shell Operation11895
|
||||
Node: Quoting13189
|
||||
Node: Escape Character14492
|
||||
Node: Single Quotes14977
|
||||
Node: Double Quotes15325
|
||||
Node: ANSI-C Quoting16450
|
||||
Node: Locale Translation17694
|
||||
Node: Comments18590
|
||||
Node: Shell Commands19208
|
||||
Node: Simple Commands20080
|
||||
Node: Pipelines20711
|
||||
Node: Lists23449
|
||||
Node: Compound Commands25178
|
||||
Node: Looping Constructs26184
|
||||
Node: Conditional Constructs28647
|
||||
Node: Command Grouping39577
|
||||
Node: Coprocesses41056
|
||||
Node: GNU Parallel42889
|
||||
Node: Shell Functions46875
|
||||
Node: Shell Parameters51959
|
||||
Node: Positional Parameters56088
|
||||
Node: Special Parameters56988
|
||||
Node: Shell Expansions60047
|
||||
Node: Brace Expansion61990
|
||||
Node: Tilde Expansion64771
|
||||
Node: Shell Parameter Expansion67120
|
||||
Node: Command Substitution79414
|
||||
Node: Arithmetic Expansion80747
|
||||
Node: Process Substitution81679
|
||||
Node: Word Splitting82729
|
||||
Node: Filename Expansion84377
|
||||
Node: Pattern Matching86542
|
||||
Node: Quote Removal90242
|
||||
Node: Redirections90537
|
||||
Node: Executing Commands99701
|
||||
Node: Simple Command Expansion100371
|
||||
Node: Command Search and Execution102301
|
||||
Node: Command Execution Environment104638
|
||||
Node: Environment107624
|
||||
Node: Exit Status109283
|
||||
Node: Signals110905
|
||||
Node: Shell Scripts112873
|
||||
Node: Shell Builtin Commands115391
|
||||
Node: Bourne Shell Builtins117419
|
||||
Node: Bash Builtins137326
|
||||
Node: Modifying Shell Behavior164779
|
||||
Node: The Set Builtin165124
|
||||
Node: The Shopt Builtin175450
|
||||
Node: Special Builtins189871
|
||||
Node: Shell Variables190850
|
||||
Node: Bourne Shell Variables191290
|
||||
Node: Bash Variables193321
|
||||
Node: Bash Features220196
|
||||
Node: Invoking Bash221095
|
||||
Node: Bash Startup Files226873
|
||||
Node: Interactive Shells231902
|
||||
Node: What is an Interactive Shell?232312
|
||||
Node: Is this Shell Interactive?232961
|
||||
Node: Interactive Shell Behavior233776
|
||||
Node: Bash Conditional Expressions237064
|
||||
Node: Shell Arithmetic241066
|
||||
Node: Aliases243842
|
||||
Node: Arrays246398
|
||||
Node: The Directory Stack251379
|
||||
Node: Directory Stack Builtins252098
|
||||
Node: Controlling the Prompt255054
|
||||
Node: The Restricted Shell257826
|
||||
Node: Bash POSIX Mode259663
|
||||
Node: Job Control269050
|
||||
Node: Job Control Basics269510
|
||||
Node: Job Control Builtins274229
|
||||
Node: Job Control Variables278700
|
||||
Node: Command Line Editing279858
|
||||
Node: Introduction and Notation281530
|
||||
Node: Readline Interaction283152
|
||||
Node: Readline Bare Essentials284343
|
||||
Node: Readline Movement Commands286132
|
||||
Node: Readline Killing Commands287097
|
||||
Node: Readline Arguments289017
|
||||
Node: Searching290061
|
||||
Node: Readline Init File292247
|
||||
Node: Readline Init File Syntax293394
|
||||
Node: Conditional Init Constructs310231
|
||||
Node: Sample Init File312764
|
||||
Node: Bindable Readline Commands315882
|
||||
Node: Commands For Moving317089
|
||||
Node: Commands For History318233
|
||||
Node: Commands For Text322418
|
||||
Node: Commands For Killing325091
|
||||
Node: Numeric Arguments327548
|
||||
Node: Commands For Completion328687
|
||||
Node: Keyboard Macros332879
|
||||
Node: Miscellaneous Commands333567
|
||||
Node: Readline vi Mode339373
|
||||
Node: Programmable Completion340280
|
||||
Node: Programmable Completion Builtins347556
|
||||
Node: A Programmable Completion Example357302
|
||||
Node: Using History Interactively362552
|
||||
Node: Bash History Facilities363236
|
||||
Node: Bash History Builtins366235
|
||||
Node: History Interaction370163
|
||||
Node: Event Designators372868
|
||||
Node: Word Designators374090
|
||||
Node: Modifiers375729
|
||||
Node: Installing Bash377133
|
||||
Node: Basic Installation378270
|
||||
Node: Compilers and Options380962
|
||||
Node: Compiling For Multiple Architectures381703
|
||||
Node: Installation Names383367
|
||||
Node: Specifying the System Type384185
|
||||
Node: Sharing Defaults384901
|
||||
Node: Operation Controls385574
|
||||
Node: Optional Features386532
|
||||
Node: Reporting Bugs396596
|
||||
Node: Major Differences From The Bourne Shell397794
|
||||
Node: GNU Free Documentation License414653
|
||||
Node: Indexes439849
|
||||
Node: Builtin Index440303
|
||||
Node: Reserved Word Index447130
|
||||
Node: Variable Index449578
|
||||
Node: Function Index463101
|
||||
Node: Concept Index470329
|
||||
|
||||
End Tag Table
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
This is TeX, Version 3.1415926 (TeX Live 2011/Fink) (format=tex 2012.4.18) 11 SEP 2013 09:17
|
||||
This is TeX, Version 3.1415926 (TeX Live 2011/Fink) (format=tex 2012.4.18) 22 OCT 2013 11:07
|
||||
**/usr/homes/chet/src/bash/src/doc/bashref.texi
|
||||
(/usr/homes/chet/src/bash/src/doc/bashref.texi (./texinfo.tex
|
||||
Loading texinfo [version 2009-01-18.17]:
|
||||
@@ -232,7 +232,7 @@ arallel -k traceroute[]
|
||||
[16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30]
|
||||
[31] [32] [33] [34] [35] [36] [37] [38] Chapter 4 [39] [40] [41] [42] [43]
|
||||
[44] [45] [46] [47]
|
||||
Underfull \hbox (badness 5231) in paragraph at lines 3764--3777
|
||||
Underfull \hbox (badness 5231) in paragraph at lines 3770--3783
|
||||
@texttt emacs-meta[]@textrm , @texttt emacs-ctlx[]@textrm , @texttt vi[]@textr
|
||||
m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
|
||||
|
||||
@@ -247,7 +247,7 @@ m , @texttt vi-move[]@textrm , @texttt vi-command[]@textrm , and
|
||||
[48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62]
|
||||
[63] [64] [65] [66] [67] Chapter 5 [68] [69] [70] [71] [72] [73] [74] [75]
|
||||
[76] [77] [78] Chapter 6 [79]
|
||||
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5981--5981
|
||||
Overfull \hbox (51.96864pt too wide) in paragraph at lines 5987--5987
|
||||
[]@texttt bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@t
|
||||
exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
|
||||
@@ -260,7 +260,7 @@ exttt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
.etc.
|
||||
|
||||
|
||||
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5982--5982
|
||||
Overfull \hbox (76.23077pt too wide) in paragraph at lines 5988--5988
|
||||
[]@texttt bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@texttt
|
||||
] [-O @textttsl shopt_option@texttt ] -c @textttsl string @texttt [@textttsl ar
|
||||
-
|
||||
@@ -274,7 +274,7 @@ Overfull \hbox (76.23077pt too wide) in paragraph at lines 5982--5982
|
||||
.etc.
|
||||
|
||||
|
||||
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5983--5983
|
||||
Overfull \hbox (34.72258pt too wide) in paragraph at lines 5989--5989
|
||||
[]@texttt bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @textttsl op-tion@text
|
||||
tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
|
||||
@@ -287,7 +287,7 @@ tt ] [-O @textttsl shopt_option@texttt ] [@textttsl ar-
|
||||
.etc.
|
||||
|
||||
[80] [81]
|
||||
Underfull \hbox (badness 2245) in paragraph at lines 6155--6157
|
||||
Underfull \hbox (badness 2245) in paragraph at lines 6161--6163
|
||||
[]@textrm When a lo-gin shell ex-its, Bash reads and ex-e-cutes com-mands from
|
||||
the file
|
||||
|
||||
@@ -300,7 +300,7 @@ the file
|
||||
.etc.
|
||||
|
||||
[82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96]
|
||||
Underfull \hbox (badness 2521) in paragraph at lines 7373--7376
|
||||
Underfull \hbox (badness 2521) in paragraph at lines 7379--7382
|
||||
@textrm `@texttt --enable-strict-posix-default[]@textrm '[] to @texttt configur
|
||||
e[] @textrm when build-ing (see Sec-tion 10.8
|
||||
|
||||
@@ -381,7 +381,7 @@ athname[]
|
||||
|
||||
[132]) (/usr/homes/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
|
||||
[133] [134] [135] [136] [137]) Chapter 10 [138] [139] [140] [141]
|
||||
Underfull \hbox (badness 2772) in paragraph at lines 7981--7985
|
||||
Underfull \hbox (badness 2772) in paragraph at lines 7987--7991
|
||||
[]@textrm Enable sup-port for large files (@texttt http://www.sas.com/standard
|
||||
s/large_
|
||||
|
||||
@@ -400,10 +400,10 @@ Appendix D [160] (./bashref.bts) [161] (./bashref.rws) (./bashref.vrs [162]
|
||||
Here is how much of TeX's memory you used:
|
||||
2085 strings out of 497974
|
||||
28645 string characters out of 3220833
|
||||
66407 words of memory out of 3000000
|
||||
66405 words of memory out of 3000000
|
||||
2901 multiletter control sequences out of 15000+200000
|
||||
32127 words of font info for 112 fonts, out of 3000000 for 9000
|
||||
51 hyphenation exceptions out of 8191
|
||||
16i,6n,14p,319b,705s stack positions out of 5000i,500n,10000p,200000b,50000s
|
||||
|
||||
Output written on bashref.dvi (173 pages, 719680 bytes).
|
||||
Output written on bashref.dvi (173 pages, 719856 bytes).
|
||||
|
||||
+1403
-1403
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -59,9 +59,9 @@
|
||||
@numchapentry{Shell Builtin Commands}{4}{Shell Builtin Commands}{41}
|
||||
@numsecentry{Bourne Shell Builtins}{4.1}{Bourne Shell Builtins}{41}
|
||||
@numsecentry{Bash Builtin Commands}{4.2}{Bash Builtins}{48}
|
||||
@numsecentry{Modifying Shell Behavior}{4.3}{Modifying Shell Behavior}{58}
|
||||
@numsubsecentry{The Set Builtin}{4.3.1}{The Set Builtin}{58}
|
||||
@numsubsecentry{The Shopt Builtin}{4.3.2}{The Shopt Builtin}{62}
|
||||
@numsecentry{Modifying Shell Behavior}{4.3}{Modifying Shell Behavior}{59}
|
||||
@numsubsecentry{The Set Builtin}{4.3.1}{The Set Builtin}{59}
|
||||
@numsubsecentry{The Shopt Builtin}{4.3.2}{The Shopt Builtin}{63}
|
||||
@numsecentry{Special Builtins}{4.4}{Special Builtins}{68}
|
||||
@numchapentry{Shell Variables}{5}{Shell Variables}{69}
|
||||
@numsecentry{Bourne Shell Variables}{5.1}{Bourne Shell Variables}{69}
|
||||
|
||||
+10
-8
@@ -143,7 +143,7 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
routine call or _e_x_p_r does not correspond to a valid position in
|
||||
the call stack.
|
||||
|
||||
ccdd [--LL|[--PP [--ee]]] [_d_i_r]
|
||||
ccdd [--LL|[--PP [--ee]] [-@]] [_d_i_r]
|
||||
Change the current directory to _d_i_r. if _d_i_r is not supplied,
|
||||
the value of the HHOOMMEE shell variable is the default. Any addi-
|
||||
tional arguments following _d_i_r are ignored. The variable CCDDPPAATTHH
|
||||
@@ -162,13 +162,15 @@ BBAASSHH BBUUIILLTTIINN CCOOMMMMAANNDDSS
|
||||
slash or the beginning of _d_i_r. If the --ee option is supplied
|
||||
with --PP, and the current working directory cannot be success-
|
||||
fully determined after a successful directory change, ccdd will
|
||||
return an unsuccessful status. An argument of -- is converted to
|
||||
$$OOLLDDPPWWDD before the directory change is attempted. If a non-
|
||||
empty directory name from CCDDPPAATTHH is used, or if -- is the first
|
||||
argument, and the directory change is successful, the absolute
|
||||
pathname of the new working directory is written to the standard
|
||||
output. The return value is true if the directory was success-
|
||||
fully changed; false otherwise.
|
||||
return an unsuccessful status. On systems that support it, the
|
||||
--@@ option presents the extended attributes associated with a
|
||||
file as a directory. An argument of -- is converted to $$OOLLDDPPWWDD
|
||||
before the directory change is attempted. If a non-empty direc-
|
||||
tory name from CCDDPPAATTHH is used, or if -- is the first argument,
|
||||
and the directory change is successful, the absolute pathname of
|
||||
the new working directory is written to the standard output.
|
||||
The return value is true if the directory was successfully
|
||||
changed; false otherwise.
|
||||
|
||||
ccoommmmaanndd [--ppVVvv] _c_o_m_m_a_n_d [_a_r_g ...]
|
||||
Run _c_o_m_m_a_n_d with _a_r_g_s suppressing the normal shell function
|
||||
|
||||
+1211
-1208
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,6 +1,6 @@
|
||||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.19.2
|
||||
%%CreationDate: Wed Sep 11 09:17:46 2013
|
||||
%%CreationDate: Tue Oct 22 11:07:52 2013
|
||||
%%DocumentNeededResources: font Times-Roman
|
||||
%%+ font Times-Bold
|
||||
%%DocumentSuppliedResources: procset grops 1.19 2
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "error.h"
|
||||
#include "externs.h"
|
||||
#include "quit.h"
|
||||
#include "trap.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
@@ -99,13 +100,14 @@ getc_with_restart (stream)
|
||||
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
|
||||
{
|
||||
sys_error (_("cannot reset nodelay mode for fd %d"), fileno (stream));
|
||||
local_index = local_bufused = 0;
|
||||
return EOF;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (errno != EINTR)
|
||||
{
|
||||
local_index = 0;
|
||||
local_index = local_bufused = 0;
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,663 @@
|
||||
/* input.c -- functions to perform buffered input with synchronization. */
|
||||
|
||||
/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "bashtypes.h"
|
||||
#if !defined (_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include "filecntl.h"
|
||||
#include "posixstat.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "general.h"
|
||||
#include "input.h"
|
||||
#include "error.h"
|
||||
#include "externs.h"
|
||||
#include "quit.h"
|
||||
#include "trap.h"
|
||||
|
||||
#if !defined (errno)
|
||||
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)
|
||||
if a signal is received. */
|
||||
|
||||
static char localbuf[128];
|
||||
static int local_index = 0, local_bufused = 0;
|
||||
|
||||
/* Posix and USG systems do not guarantee to restart read () if it is
|
||||
interrupted by a signal. We do the read ourselves, and restart it
|
||||
if it returns EINTR. */
|
||||
int
|
||||
getc_with_restart (stream)
|
||||
FILE *stream;
|
||||
{
|
||||
unsigned char uc;
|
||||
|
||||
CHECK_TERMSIG;
|
||||
|
||||
/* Try local buffering to reduce the number of read(2) calls. */
|
||||
if (local_index == local_bufused || local_bufused == 0)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
QUIT;
|
||||
run_pending_traps ();
|
||||
|
||||
local_bufused = read (fileno (stream), localbuf, sizeof(localbuf));
|
||||
if (local_bufused > 0)
|
||||
break;
|
||||
else if (local_bufused == 0)
|
||||
{
|
||||
local_index = 0;
|
||||
return EOF;
|
||||
}
|
||||
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 (errno != EINTR)
|
||||
{
|
||||
local_index = 0;
|
||||
return EOF;
|
||||
}
|
||||
}
|
||||
local_index = 0;
|
||||
}
|
||||
uc = localbuf[local_index++];
|
||||
return uc;
|
||||
}
|
||||
|
||||
int
|
||||
ungetc_with_restart (c, stream)
|
||||
int c;
|
||||
FILE *stream;
|
||||
{
|
||||
if (local_index == 0 || c == EOF)
|
||||
return EOF;
|
||||
localbuf[--local_index] = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
#if defined (BUFFERED_INPUT)
|
||||
|
||||
/* A facility similar to stdio, but input-only. */
|
||||
|
||||
#if defined (USING_BASH_MALLOC)
|
||||
# define MAX_INPUT_BUFFER_SIZE 8176
|
||||
#else
|
||||
# define MAX_INPUT_BUFFER_SIZE 8192
|
||||
#endif
|
||||
|
||||
#if !defined (SEEK_CUR)
|
||||
# define SEEK_CUR 1
|
||||
#endif /* !SEEK_CUR */
|
||||
|
||||
#ifdef max
|
||||
# undef max
|
||||
#endif
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#ifdef min
|
||||
# undef min
|
||||
#endif
|
||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
||||
|
||||
extern int interactive_shell;
|
||||
|
||||
int bash_input_fd_changed;
|
||||
|
||||
/* This provides a way to map from a file descriptor to the buffer
|
||||
associated with that file descriptor, rather than just the other
|
||||
way around. This is needed so that buffers are managed properly
|
||||
in constructs like 3<&4. buffers[x]->b_fd == x -- that is how the
|
||||
correspondence is maintained. */
|
||||
static BUFFERED_STREAM **buffers = (BUFFERED_STREAM **)NULL;
|
||||
static int nbuffers;
|
||||
|
||||
#define ALLOCATE_BUFFERS(n) \
|
||||
do { if ((n) >= nbuffers) allocate_buffers (n); } while (0)
|
||||
|
||||
/* Make sure `buffers' has at least N elements. */
|
||||
static void
|
||||
allocate_buffers (n)
|
||||
int n;
|
||||
{
|
||||
register int i, orig_nbuffers;
|
||||
|
||||
orig_nbuffers = nbuffers;
|
||||
nbuffers = n + 20;
|
||||
buffers = (BUFFERED_STREAM **)xrealloc
|
||||
(buffers, nbuffers * sizeof (BUFFERED_STREAM *));
|
||||
|
||||
/* Zero out the new buffers. */
|
||||
for (i = orig_nbuffers; i < nbuffers; i++)
|
||||
buffers[i] = (BUFFERED_STREAM *)NULL;
|
||||
}
|
||||
|
||||
/* Construct and return a BUFFERED_STREAM corresponding to file descriptor
|
||||
FD, using BUFFER. */
|
||||
static BUFFERED_STREAM *
|
||||
make_buffered_stream (fd, buffer, bufsize)
|
||||
int fd;
|
||||
char *buffer;
|
||||
size_t bufsize;
|
||||
{
|
||||
BUFFERED_STREAM *bp;
|
||||
|
||||
bp = (BUFFERED_STREAM *)xmalloc (sizeof (BUFFERED_STREAM));
|
||||
ALLOCATE_BUFFERS (fd);
|
||||
buffers[fd] = bp;
|
||||
bp->b_fd = fd;
|
||||
bp->b_buffer = buffer;
|
||||
bp->b_size = bufsize;
|
||||
bp->b_used = bp->b_inputp = bp->b_flag = 0;
|
||||
if (bufsize == 1)
|
||||
bp->b_flag |= B_UNBUFF;
|
||||
if (O_TEXT && (fcntl (fd, F_GETFL) & O_TEXT) != 0)
|
||||
bp->b_flag |= O_TEXT;
|
||||
return (bp);
|
||||
}
|
||||
|
||||
/* Allocate a new BUFFERED_STREAM, copy BP to it, and return the new copy. */
|
||||
static BUFFERED_STREAM *
|
||||
copy_buffered_stream (bp)
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
BUFFERED_STREAM *nbp;
|
||||
|
||||
if (!bp)
|
||||
return ((BUFFERED_STREAM *)NULL);
|
||||
|
||||
nbp = (BUFFERED_STREAM *)xmalloc (sizeof (BUFFERED_STREAM));
|
||||
xbcopy ((char *)bp, (char *)nbp, sizeof (BUFFERED_STREAM));
|
||||
return (nbp);
|
||||
}
|
||||
|
||||
int
|
||||
set_bash_input_fd (fd)
|
||||
int fd;
|
||||
{
|
||||
if (bash_input.type == st_bstream)
|
||||
bash_input.location.buffered_fd = fd;
|
||||
else if (interactive_shell == 0)
|
||||
default_buffered_input = fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fd_is_bash_input (fd)
|
||||
int fd;
|
||||
{
|
||||
if (bash_input.type == st_bstream && bash_input.location.buffered_fd == fd)
|
||||
return 1;
|
||||
else if (interactive_shell == 0 && default_buffered_input == fd)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save the buffered stream corresponding to file descriptor FD (which bash
|
||||
is using to read input) to a buffered stream associated with NEW_FD. If
|
||||
NEW_FD is -1, a new file descriptor is allocated with fcntl. The new
|
||||
file descriptor is returned on success, -1 on error. */
|
||||
int
|
||||
save_bash_input (fd, new_fd)
|
||||
int fd, new_fd;
|
||||
{
|
||||
int nfd;
|
||||
|
||||
/* Sync the stream so we can re-read from the new file descriptor. We
|
||||
might be able to avoid this by copying the buffered stream verbatim
|
||||
to the new file descriptor. */
|
||||
if (buffers[fd])
|
||||
sync_buffered_stream (fd);
|
||||
|
||||
/* Now take care of duplicating the file descriptor that bash is
|
||||
using for input, so we can reinitialize it later. */
|
||||
nfd = (new_fd == -1) ? fcntl (fd, F_DUPFD, 10) : new_fd;
|
||||
if (nfd == -1)
|
||||
{
|
||||
if (fcntl (fd, F_GETFD, 0) == 0)
|
||||
sys_error (_("cannot allocate new file descriptor for bash input from fd %d"), fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buffers[nfd])
|
||||
{
|
||||
/* What's this? A stray buffer without an associated open file
|
||||
descriptor? Free up the buffer and report the error. */
|
||||
internal_error (_("save_bash_input: buffer already exists for new fd %d"), nfd);
|
||||
free_buffered_stream (buffers[nfd]);
|
||||
}
|
||||
|
||||
/* Reinitialize bash_input.location. */
|
||||
if (bash_input.type == st_bstream)
|
||||
{
|
||||
bash_input.location.buffered_fd = nfd;
|
||||
fd_to_buffered_stream (nfd);
|
||||
close_buffered_fd (fd); /* XXX */
|
||||
}
|
||||
else
|
||||
/* If the current input type is not a buffered stream, but the shell
|
||||
is not interactive and therefore using a buffered stream to read
|
||||
input (e.g. with an `eval exec 3>output' inside a script), note
|
||||
that the input fd has been changed. pop_stream() looks at this
|
||||
value and adjusts the input fd to the new value of
|
||||
default_buffered_input accordingly. */
|
||||
bash_input_fd_changed++;
|
||||
|
||||
if (default_buffered_input == fd)
|
||||
default_buffered_input = nfd;
|
||||
|
||||
SET_CLOSE_ON_EXEC (nfd);
|
||||
return nfd;
|
||||
}
|
||||
|
||||
/* Check that file descriptor FD is not the one that bash is currently
|
||||
using to read input from a script. FD is about to be duplicated onto,
|
||||
which means that the kernel will close it for us. If FD is the bash
|
||||
input file descriptor, we need to seek backwards in the script (if
|
||||
possible and necessary -- scripts read from stdin are still unbuffered),
|
||||
allocate a new file descriptor to use for bash input, and re-initialize
|
||||
the buffered stream. Make sure the file descriptor used to save bash
|
||||
input is set close-on-exec. Returns 0 on success, -1 on failure. This
|
||||
works only if fd is > 0 -- if fd == 0 and bash is reading input from
|
||||
fd 0, sync_buffered_stream is used instead, to cooperate with input
|
||||
redirection (look at redir.c:add_undo_redirect()). */
|
||||
int
|
||||
check_bash_input (fd)
|
||||
int fd;
|
||||
{
|
||||
if (fd_is_bash_input (fd))
|
||||
{
|
||||
if (fd > 0)
|
||||
return ((save_bash_input (fd, -1) == -1) ? -1 : 0);
|
||||
else if (fd == 0)
|
||||
return ((sync_buffered_stream (fd) == -1) ? -1 : 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is the buffered stream analogue of dup2(fd1, fd2). The
|
||||
BUFFERED_STREAM corresponding to fd2 is deallocated, if one exists.
|
||||
BUFFERS[fd1] is copied to BUFFERS[fd2]. This is called by the
|
||||
redirect code for constructs like 4<&0 and 3</etc/rc.local. */
|
||||
int
|
||||
duplicate_buffered_stream (fd1, fd2)
|
||||
int fd1, fd2;
|
||||
{
|
||||
int is_bash_input, m;
|
||||
|
||||
if (fd1 == fd2)
|
||||
return 0;
|
||||
|
||||
m = max (fd1, fd2);
|
||||
ALLOCATE_BUFFERS (m);
|
||||
|
||||
/* If FD2 is the file descriptor bash is currently using for shell input,
|
||||
we need to do some extra work to make sure that the buffered stream
|
||||
actually exists (it might not if fd1 was not active, and the copy
|
||||
didn't actually do anything). */
|
||||
is_bash_input = (bash_input.type == st_bstream) &&
|
||||
(bash_input.location.buffered_fd == fd2);
|
||||
|
||||
if (buffers[fd2])
|
||||
{
|
||||
/* If the two objects share the same b_buffer, don't free it. */
|
||||
if (buffers[fd1] && buffers[fd1]->b_buffer && buffers[fd1]->b_buffer == buffers[fd2]->b_buffer)
|
||||
buffers[fd2] = (BUFFERED_STREAM *)NULL;
|
||||
else
|
||||
free_buffered_stream (buffers[fd2]);
|
||||
}
|
||||
buffers[fd2] = copy_buffered_stream (buffers[fd1]);
|
||||
if (buffers[fd2])
|
||||
buffers[fd2]->b_fd = fd2;
|
||||
|
||||
if (is_bash_input)
|
||||
{
|
||||
if (!buffers[fd2])
|
||||
fd_to_buffered_stream (fd2);
|
||||
buffers[fd2]->b_flag |= B_WASBASHINPUT;
|
||||
}
|
||||
|
||||
return (fd2);
|
||||
}
|
||||
|
||||
/* Return 1 if a seek on FD will succeed. */
|
||||
#define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0)
|
||||
|
||||
/* Take FD, a file descriptor, and create and return a buffered stream
|
||||
corresponding to it. If something is wrong and the file descriptor
|
||||
is invalid, return a NULL stream. */
|
||||
BUFFERED_STREAM *
|
||||
fd_to_buffered_stream (fd)
|
||||
int fd;
|
||||
{
|
||||
char *buffer;
|
||||
size_t size;
|
||||
struct stat sb;
|
||||
|
||||
if (fstat (fd, &sb) < 0)
|
||||
{
|
||||
close (fd);
|
||||
return ((BUFFERED_STREAM *)NULL);
|
||||
}
|
||||
|
||||
size = (fd_is_seekable (fd)) ? min (sb.st_size, MAX_INPUT_BUFFER_SIZE) : 1;
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
buffer = (char *)xmalloc (size);
|
||||
|
||||
return (make_buffered_stream (fd, buffer, size));
|
||||
}
|
||||
|
||||
/* Return a buffered stream corresponding to FILE, a file name. */
|
||||
BUFFERED_STREAM *
|
||||
open_buffered_stream (file)
|
||||
char *file;
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open (file, O_RDONLY);
|
||||
return ((fd >= 0) ? fd_to_buffered_stream (fd) : (BUFFERED_STREAM *)NULL);
|
||||
}
|
||||
|
||||
/* Deallocate a buffered stream and free up its resources. Make sure we
|
||||
zero out the slot in BUFFERS that points to BP. */
|
||||
void
|
||||
free_buffered_stream (bp)
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
int n;
|
||||
|
||||
if (!bp)
|
||||
return;
|
||||
|
||||
n = bp->b_fd;
|
||||
if (bp->b_buffer)
|
||||
free (bp->b_buffer);
|
||||
free (bp);
|
||||
buffers[n] = (BUFFERED_STREAM *)NULL;
|
||||
}
|
||||
|
||||
/* Close the file descriptor associated with BP, a buffered stream, and free
|
||||
up the stream. Return the status of closing BP's file descriptor. */
|
||||
int
|
||||
close_buffered_stream (bp)
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (!bp)
|
||||
return (0);
|
||||
fd = bp->b_fd;
|
||||
free_buffered_stream (bp);
|
||||
return (close (fd));
|
||||
}
|
||||
|
||||
/* Deallocate the buffered stream associated with file descriptor FD, and
|
||||
close FD. Return the status of the close on FD. */
|
||||
int
|
||||
close_buffered_fd (fd)
|
||||
int fd;
|
||||
{
|
||||
if (fd < 0)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
if (fd >= nbuffers || !buffers || !buffers[fd])
|
||||
return (close (fd));
|
||||
return (close_buffered_stream (buffers[fd]));
|
||||
}
|
||||
|
||||
/* Make the BUFFERED_STREAM associated with buffers[FD] be BP, and return
|
||||
the old BUFFERED_STREAM. */
|
||||
BUFFERED_STREAM *
|
||||
set_buffered_stream (fd, bp)
|
||||
int fd;
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
BUFFERED_STREAM *ret;
|
||||
|
||||
ret = buffers[fd];
|
||||
buffers[fd] = bp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Read a buffer full of characters from BP, a buffered stream. */
|
||||
static int
|
||||
b_fill_buffer (bp)
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
ssize_t nr;
|
||||
off_t o;
|
||||
|
||||
CHECK_TERMSIG;
|
||||
/* In an environment where text and binary files are treated differently,
|
||||
compensate for lseek() on text files returning an offset different from
|
||||
the count of characters read() returns. Text-mode streams have to be
|
||||
treated as unbuffered. */
|
||||
if ((bp->b_flag & (B_TEXT | B_UNBUFF)) == B_TEXT)
|
||||
{
|
||||
o = lseek (bp->b_fd, 0, SEEK_CUR);
|
||||
nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
|
||||
if (nr > 0 && nr < lseek (bp->b_fd, 0, SEEK_CUR) - o)
|
||||
{
|
||||
lseek (bp->b_fd, o, SEEK_SET);
|
||||
bp->b_flag |= B_UNBUFF;
|
||||
bp->b_size = 1;
|
||||
nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
nr = zread (bp->b_fd, bp->b_buffer, bp->b_size);
|
||||
if (nr <= 0)
|
||||
{
|
||||
bp->b_used = 0;
|
||||
bp->b_buffer[0] = 0;
|
||||
if (nr == 0)
|
||||
bp->b_flag |= B_EOF;
|
||||
else
|
||||
bp->b_flag |= B_ERROR;
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
bp->b_used = nr;
|
||||
bp->b_inputp = 0;
|
||||
return (bp->b_buffer[bp->b_inputp++] & 0xFF);
|
||||
}
|
||||
|
||||
/* Get a character from buffered stream BP. */
|
||||
#define bufstream_getc(bp) \
|
||||
(bp->b_inputp == bp->b_used || !bp->b_used) \
|
||||
? b_fill_buffer (bp) \
|
||||
: bp->b_buffer[bp->b_inputp++] & 0xFF
|
||||
|
||||
/* Push C back onto buffered stream BP. */
|
||||
static int
|
||||
bufstream_ungetc(c, bp)
|
||||
int c;
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
if (c == EOF || bp->b_inputp == 0)
|
||||
return (EOF);
|
||||
|
||||
bp->b_buffer[--bp->b_inputp] = c;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* Seek backwards on file BFD to synchronize what we've read so far
|
||||
with the underlying file pointer. */
|
||||
int
|
||||
sync_buffered_stream (bfd)
|
||||
int bfd;
|
||||
{
|
||||
BUFFERED_STREAM *bp;
|
||||
off_t chars_left;
|
||||
|
||||
if (buffers == 0 || (bp = buffers[bfd]) == 0)
|
||||
return (-1);
|
||||
|
||||
chars_left = bp->b_used - bp->b_inputp;
|
||||
if (chars_left)
|
||||
lseek (bp->b_fd, -chars_left, SEEK_CUR);
|
||||
bp->b_used = bp->b_inputp = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
buffered_getchar ()
|
||||
{
|
||||
CHECK_TERMSIG;
|
||||
|
||||
#if !defined (DJGPP)
|
||||
return (bufstream_getc (buffers[bash_input.location.buffered_fd]));
|
||||
#else
|
||||
/* On DJGPP, ignore \r. */
|
||||
int ch;
|
||||
while ((ch = bufstream_getc (buffers[bash_input.location.buffered_fd])) == '\r')
|
||||
;
|
||||
return ch;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
buffered_ungetchar (c)
|
||||
int c;
|
||||
{
|
||||
return (bufstream_ungetc (c, buffers[bash_input.location.buffered_fd]));
|
||||
}
|
||||
|
||||
/* Make input come from file descriptor BFD through a buffered stream. */
|
||||
void
|
||||
with_input_from_buffered_stream (bfd, name)
|
||||
int bfd;
|
||||
char *name;
|
||||
{
|
||||
INPUT_STREAM location;
|
||||
BUFFERED_STREAM *bp;
|
||||
|
||||
location.buffered_fd = bfd;
|
||||
/* Make sure the buffered stream exists. */
|
||||
bp = fd_to_buffered_stream (bfd);
|
||||
init_yy_io (bp == 0 ? return_EOF : buffered_getchar,
|
||||
buffered_ungetchar, st_bstream, name, location);
|
||||
}
|
||||
|
||||
#if defined (TEST)
|
||||
void *
|
||||
xmalloc(s)
|
||||
int s;
|
||||
{
|
||||
return (malloc (s));
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(s, size)
|
||||
char *s;
|
||||
int size;
|
||||
{
|
||||
if (!s)
|
||||
return(malloc (size));
|
||||
else
|
||||
return(realloc (s, size));
|
||||
}
|
||||
|
||||
void
|
||||
init_yy_io ()
|
||||
{
|
||||
}
|
||||
|
||||
process(bp)
|
||||
BUFFERED_STREAM *bp;
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = bufstream_getc(bp)) != EOF)
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
BASH_INPUT bash_input;
|
||||
|
||||
struct stat dsb; /* can be used from gdb */
|
||||
|
||||
/* imitate /bin/cat */
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
register int i;
|
||||
BUFFERED_STREAM *bp;
|
||||
|
||||
if (argc == 1) {
|
||||
bp = fd_to_buffered_stream (0);
|
||||
process(bp);
|
||||
exit(0);
|
||||
}
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-' && argv[i][1] == '\0') {
|
||||
bp = fd_to_buffered_stream (0);
|
||||
if (!bp)
|
||||
continue;
|
||||
process(bp);
|
||||
free_buffered_stream (bp);
|
||||
} else {
|
||||
bp = open_buffered_stream (argv[i]);
|
||||
if (!bp)
|
||||
continue;
|
||||
process(bp);
|
||||
close_buffered_stream (bp);
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
#endif /* TEST */
|
||||
#endif /* BUFFERED_INPUT */
|
||||
+2
-2
@@ -227,7 +227,7 @@ skipname (pat, dname, flags)
|
||||
int flags;
|
||||
{
|
||||
#if EXTENDED_GLOB
|
||||
if (extglob_pattern (pat)) /* XXX */
|
||||
if (extglob_pattern_p (pat)) /* XXX */
|
||||
return (extglob_skipname (pat, dname, flags));
|
||||
#endif
|
||||
|
||||
@@ -330,7 +330,7 @@ mbskipname (pat, dname, flags)
|
||||
|
||||
ext = 0;
|
||||
#if EXTENDED_GLOB
|
||||
ext = extglob_pattern (pat);
|
||||
ext = extglob_pattern_p (pat);
|
||||
#endif
|
||||
|
||||
pat_wc = dn_wc = (wchar_t *)NULL;
|
||||
|
||||
+1358
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,8 @@ extern int glob_pattern_p __P((const char *));
|
||||
extern char **glob_vector __P((char *, char *, int));
|
||||
extern char **glob_filename __P((char *, int));
|
||||
|
||||
extern int extglob_pattern_p __P((const char *));
|
||||
|
||||
extern char *glob_error_return;
|
||||
extern int noglob_dot_filenames;
|
||||
extern int glob_ignore_case;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/* File-name wildcard pattern matching for GNU.
|
||||
Copyright (C) 1985, 1988, 1989, 2008,2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne-Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GLOB_H_
|
||||
#define _GLOB_H_
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
#define GX_MARKDIRS 0x001 /* mark directory names with trailing `/' */
|
||||
#define GX_NOCASE 0x002 /* ignore case */
|
||||
#define GX_MATCHDOT 0x004 /* match `.' literally */
|
||||
#define GX_MATCHDIRS 0x008 /* match only directory names */
|
||||
#define GX_ALLDIRS 0x010 /* match all directory names, no others */
|
||||
#define GX_NULLDIR 0x100 /* internal -- no directory preceding pattern */
|
||||
#define GX_ADDCURDIR 0x200 /* internal -- add passed directory name */
|
||||
#define GX_GLOBSTAR 0x400 /* turn on special handling of ** */
|
||||
|
||||
extern int glob_pattern_p __P((const char *));
|
||||
extern char **glob_vector __P((char *, char *, int));
|
||||
extern char **glob_filename __P((char *, int));
|
||||
|
||||
extern char *glob_error_return;
|
||||
extern int noglob_dot_filenames;
|
||||
extern int glob_ignore_case;
|
||||
|
||||
#endif /* _GLOB_H_ */
|
||||
+1
-1
@@ -201,7 +201,7 @@ bad_bracket:
|
||||
#endif
|
||||
|
||||
int
|
||||
extglob_pattern (pat)
|
||||
extglob_pattern_p (pat)
|
||||
char *pat;
|
||||
{
|
||||
switch (pat[0])
|
||||
|
||||
@@ -0,0 +1,376 @@
|
||||
/* gmisc.c -- miscellaneous pattern matching utility functions for Bash.
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne-Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "bashtypes.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "bashansi.h"
|
||||
#include "shmbutil.h"
|
||||
|
||||
#include "stdc.h"
|
||||
|
||||
#ifndef LPAREN
|
||||
# define LPAREN '('
|
||||
#endif
|
||||
#ifndef RPAREN
|
||||
# define RPAREN ')'
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
#define WLPAREN L'('
|
||||
#define WRPAREN L')'
|
||||
|
||||
/* Return 1 of the first character of WSTRING could match the first
|
||||
character of pattern WPAT. Wide character version. */
|
||||
int
|
||||
match_pattern_wchar (wpat, wstring)
|
||||
wchar_t *wpat, *wstring;
|
||||
{
|
||||
wchar_t wc;
|
||||
|
||||
if (*wstring == 0)
|
||||
return (0);
|
||||
|
||||
switch (wc = *wpat++)
|
||||
{
|
||||
default:
|
||||
return (*wstring == wc);
|
||||
case L'\\':
|
||||
return (*wstring == *wpat);
|
||||
case L'?':
|
||||
return (*wpat == WLPAREN ? 1 : (*wstring != L'\0'));
|
||||
case L'*':
|
||||
return (1);
|
||||
case L'+':
|
||||
case L'!':
|
||||
case L'@':
|
||||
return (*wpat == WLPAREN ? 1 : (*wstring == wc));
|
||||
case L'[':
|
||||
return (*wstring != L'\0');
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
wmatchlen (wpat, wmax)
|
||||
wchar_t *wpat;
|
||||
size_t wmax;
|
||||
{
|
||||
wchar_t wc;
|
||||
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
|
||||
|
||||
if (*wpat == 0)
|
||||
return (0);
|
||||
|
||||
matlen = in_cclass = in_collsym = in_equiv = 0;
|
||||
while (wc = *wpat++)
|
||||
{
|
||||
switch (wc)
|
||||
{
|
||||
default:
|
||||
matlen++;
|
||||
break;
|
||||
case L'\\':
|
||||
if (*wpat == 0)
|
||||
return ++matlen;
|
||||
else
|
||||
{
|
||||
matlen++;
|
||||
wpat++;
|
||||
}
|
||||
break;
|
||||
case L'?':
|
||||
if (*wpat == WLPAREN)
|
||||
return (matlen = -1); /* XXX for now */
|
||||
else
|
||||
matlen++;
|
||||
break;
|
||||
case L'*':
|
||||
return (matlen = -1);
|
||||
case L'+':
|
||||
case L'!':
|
||||
case L'@':
|
||||
if (*wpat == WLPAREN)
|
||||
return (matlen = -1); /* XXX for now */
|
||||
else
|
||||
matlen++;
|
||||
break;
|
||||
case L'[':
|
||||
/* scan for ending `]', skipping over embedded [:...:] */
|
||||
bracklen = 1;
|
||||
wc = *wpat++;
|
||||
do
|
||||
{
|
||||
if (wc == 0)
|
||||
{
|
||||
wpat--; /* back up to NUL */
|
||||
matlen += bracklen;
|
||||
goto bad_bracket;
|
||||
}
|
||||
else if (wc == L'\\')
|
||||
{
|
||||
/* *wpat == backslash-escaped character */
|
||||
bracklen++;
|
||||
/* If the backslash or backslash-escape ends the string,
|
||||
bail. The ++wpat skips over the backslash escape */
|
||||
if (*wpat == 0 || *++wpat == 0)
|
||||
{
|
||||
matlen += bracklen;
|
||||
goto bad_bracket;
|
||||
}
|
||||
}
|
||||
else if (wc == L'[' && *wpat == L':') /* character class */
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
in_cclass = 1;
|
||||
}
|
||||
else if (in_cclass && wc == L':' && *wpat == L']')
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
in_cclass = 0;
|
||||
}
|
||||
else if (wc == L'[' && *wpat == L'.') /* collating symbol */
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
if (*wpat == L']') /* right bracket can appear as collating symbol */
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
}
|
||||
in_collsym = 1;
|
||||
}
|
||||
else if (in_collsym && wc == L'.' && *wpat == L']')
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
in_collsym = 0;
|
||||
}
|
||||
else if (wc == L'[' && *wpat == L'=') /* equivalence class */
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
if (*wpat == L']') /* right bracket can appear as equivalence class */
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
}
|
||||
in_equiv = 1;
|
||||
}
|
||||
else if (in_equiv && wc == L'=' && *wpat == L']')
|
||||
{
|
||||
wpat++;
|
||||
bracklen++;
|
||||
in_equiv = 0;
|
||||
}
|
||||
else
|
||||
bracklen++;
|
||||
}
|
||||
while ((wc = *wpat++) != L']');
|
||||
matlen++; /* bracket expression can only match one char */
|
||||
bad_bracket:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return matlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
extglob_pattern (pat)
|
||||
char *pat;
|
||||
{
|
||||
switch (pat[0])
|
||||
{
|
||||
case '*':
|
||||
case '+':
|
||||
case '!':
|
||||
case '@':
|
||||
return (pat[1] == LPAREN);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return 1 of the first character of STRING could match the first
|
||||
character of pattern PAT. Used to avoid n2 calls to strmatch(). */
|
||||
int
|
||||
match_pattern_char (pat, string)
|
||||
char *pat, *string;
|
||||
{
|
||||
char c;
|
||||
|
||||
if (*string == 0)
|
||||
return (0);
|
||||
|
||||
switch (c = *pat++)
|
||||
{
|
||||
default:
|
||||
return (*string == c);
|
||||
case '\\':
|
||||
return (*string == *pat);
|
||||
case '?':
|
||||
return (*pat == LPAREN ? 1 : (*string != '\0'));
|
||||
case '*':
|
||||
return (1);
|
||||
case '+':
|
||||
case '!':
|
||||
case '@':
|
||||
return (*pat == LPAREN ? 1 : (*string == c));
|
||||
case '[':
|
||||
return (*string != '\0');
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
umatchlen (pat, max)
|
||||
char *pat;
|
||||
size_t max;
|
||||
{
|
||||
char c;
|
||||
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
|
||||
|
||||
if (*pat == 0)
|
||||
return (0);
|
||||
|
||||
matlen = in_cclass = in_collsym = in_equiv = 0;
|
||||
while (c = *pat++)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
default:
|
||||
matlen++;
|
||||
break;
|
||||
case '\\':
|
||||
if (*pat == 0)
|
||||
return ++matlen;
|
||||
else
|
||||
{
|
||||
matlen++;
|
||||
pat++;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if (*pat == LPAREN)
|
||||
return (matlen = -1); /* XXX for now */
|
||||
else
|
||||
matlen++;
|
||||
break;
|
||||
case '*':
|
||||
return (matlen = -1);
|
||||
case '+':
|
||||
case '!':
|
||||
case '@':
|
||||
if (*pat == LPAREN)
|
||||
return (matlen = -1); /* XXX for now */
|
||||
else
|
||||
matlen++;
|
||||
break;
|
||||
case '[':
|
||||
/* scan for ending `]', skipping over embedded [:...:] */
|
||||
bracklen = 1;
|
||||
c = *pat++;
|
||||
do
|
||||
{
|
||||
if (c == 0)
|
||||
{
|
||||
pat--; /* back up to NUL */
|
||||
matlen += bracklen;
|
||||
goto bad_bracket;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
/* *pat == backslash-escaped character */
|
||||
bracklen++;
|
||||
/* If the backslash or backslash-escape ends the string,
|
||||
bail. The ++pat skips over the backslash escape */
|
||||
if (*pat == 0 || *++pat == 0)
|
||||
{
|
||||
matlen += bracklen;
|
||||
goto bad_bracket;
|
||||
}
|
||||
}
|
||||
else if (c == '[' && *pat == ':') /* character class */
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
in_cclass = 1;
|
||||
}
|
||||
else if (in_cclass && c == ':' && *pat == ']')
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
in_cclass = 0;
|
||||
}
|
||||
else if (c == '[' && *pat == '.') /* collating symbol */
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
if (*pat == ']') /* right bracket can appear as collating symbol */
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
}
|
||||
in_collsym = 1;
|
||||
}
|
||||
else if (in_collsym && c == '.' && *pat == ']')
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
in_collsym = 0;
|
||||
}
|
||||
else if (c == '[' && *pat == '=') /* equivalence class */
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
if (*pat == ']') /* right bracket can appear as equivalence class */
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
}
|
||||
in_equiv = 1;
|
||||
}
|
||||
else if (in_equiv && c == '=' && *pat == ']')
|
||||
{
|
||||
pat++;
|
||||
bracklen++;
|
||||
in_equiv = 0;
|
||||
}
|
||||
else
|
||||
bracklen++;
|
||||
}
|
||||
while ((c = *pat++) != ']');
|
||||
matlen++; /* bracket expression can only match one char */
|
||||
bad_bracket:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return matlen;
|
||||
}
|
||||
@@ -117,6 +117,11 @@ history.ps: history.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) history.dvi
|
||||
|
||||
# can also use:
|
||||
# $(MAKEINFO) --html --no-split
|
||||
# in place of
|
||||
# $(TEXI2HTML) -menu -monolithic
|
||||
|
||||
readline.html: ${RLSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texi
|
||||
sed -e 's:rlman.html:readline.html:' rlman.html > readline.html
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
# Derived by hand from the generated readline-src/doc/Makefile
|
||||
# This makefile for Readline library documentation is in -*- text -*- mode.
|
||||
# Emacs likes it that way.
|
||||
|
||||
# Copyright (C) 1996-2002 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
topdir = .
|
||||
srcdir = .
|
||||
VPATH = .
|
||||
|
||||
prefix = /usr/local
|
||||
infodir = ${prefix}/info
|
||||
|
||||
mandir = ${prefix}/man
|
||||
manpfx = man
|
||||
|
||||
man1ext = 1
|
||||
man1dir = $(mandir)/$(manpfx)$(man1ext)
|
||||
man3ext = 3
|
||||
man3dir = $(mandir)/$(manpfx)$(man3ext)
|
||||
|
||||
SHELL = /bin/sh
|
||||
RM = rm -f
|
||||
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
|
||||
BUILD_DIR = .
|
||||
TEXINPUTDIR = $(srcdir)
|
||||
|
||||
MAKEINFO = LANGUAGE= makeinfo
|
||||
TEXI2DVI = $(srcdir)/texi2dvi
|
||||
TEXI2HTML = $(srcdir)/texi2html
|
||||
QUIETPS = #set this to -q to shut up dvips
|
||||
PSDPI = 600
|
||||
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
|
||||
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
|
||||
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
|
||||
|
||||
RLSRC = $(srcdir)/rlman.texi $(srcdir)/rluser.texi \
|
||||
$(srcdir)/rltech.texi $(srcdir)/version.texi \
|
||||
$(srcdir)/rluserman.texi
|
||||
HISTSRC = $(srcdir)/history.texi $(srcdir)/hsuser.texi \
|
||||
$(srcdir)/hstech.texi $(srcdir)/version.texi
|
||||
|
||||
# This should be a program that converts troff to an ascii-readable format
|
||||
NROFF = groff -Tascii
|
||||
|
||||
# This should be a program that converts troff to postscript
|
||||
GROFF = groff
|
||||
|
||||
DVIOBJ = readline.dvi history.dvi rluserman.dvi
|
||||
INFOOBJ = readline.info history.info rluserman.info
|
||||
PSOBJ = readline.ps history.ps rluserman.ps
|
||||
HTMLOBJ = readline.html history.html rluserman.html
|
||||
PDFOBJ = readline.pdf history.pdf rluserman.pdf
|
||||
|
||||
INTERMEDIATE_OBJ = rlman.dvi
|
||||
|
||||
CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(PDFOBJ)
|
||||
|
||||
.SUFFIXES: .ps .txt .dvi .html .pdf
|
||||
|
||||
.ps.pdf:
|
||||
$(RM) $@
|
||||
-${PSPDF} $<
|
||||
|
||||
.dvi.pdf:
|
||||
$(RM) $@
|
||||
-${DVIPDF} $<
|
||||
|
||||
all: info dvi html ps
|
||||
nodvi: info html
|
||||
pdf: $(PDFOBJ)
|
||||
|
||||
readline.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texi
|
||||
mv rlman.dvi readline.dvi
|
||||
|
||||
readline.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texi
|
||||
|
||||
rluserman.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texi
|
||||
|
||||
rluserman.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texi
|
||||
|
||||
history.dvi: ${HISTSRC}
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/history.texi
|
||||
|
||||
history.info: ${HISTSRC}
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/history.texi
|
||||
|
||||
readline.ps: readline.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) readline.dvi
|
||||
|
||||
rluserman.ps: rluserman.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) rluserman.dvi
|
||||
|
||||
history.ps: history.dvi
|
||||
$(RM) $@
|
||||
$(DVIPS) history.dvi
|
||||
|
||||
readline.html: ${RLSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texi
|
||||
sed -e 's:rlman.html:readline.html:' rlman.html > readline.html
|
||||
$(RM) rlman.html
|
||||
|
||||
rluserman.html: ${RLSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texi
|
||||
|
||||
history.html: ${HISTSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/history.texi
|
||||
|
||||
info: $(INFOOBJ)
|
||||
dvi: $(DVIOBJ)
|
||||
ps: $(PSOBJ)
|
||||
html: $(HTMLOBJ)
|
||||
|
||||
readline.pdf: readline.dvi
|
||||
history.pdf: history.dvi
|
||||
rluserman.pdf: rluserman.dvi
|
||||
|
||||
clean:
|
||||
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
|
||||
|
||||
distclean: clean
|
||||
$(RM) $(CREATED_DOCS)
|
||||
$(RM) $(INTERMEDIATE_OBJ)
|
||||
$(RM) Makefile
|
||||
|
||||
mostlyclean: clean
|
||||
|
||||
maintainer-clean: clean
|
||||
$(RM) $(CREATED_DOCS)
|
||||
$(RM) $(INTERMEDIATE_OBJ)
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
@echo "This documentation should not be installed."
|
||||
|
||||
uninstall:
|
||||
@@ -82,6 +82,11 @@ extern int errno;
|
||||
|
||||
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
#if defined (COLOR_SUPPORT)
|
||||
extern void _rl_parse_colors PARAMS((void)); /* XXX */
|
||||
#endif
|
||||
|
||||
|
||||
/* Forward declarations used in this file. */
|
||||
static char *readline_internal PARAMS((void));
|
||||
static void readline_initialize_everything PARAMS((void));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2013 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
@@ -213,7 +213,7 @@ _rl_nsearch_init (dir, pchar)
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
p = _rl_make_prompt_for_search (pchar ? pchar : ':');
|
||||
rl_message ("%s", p, 0);
|
||||
rl_message ("%s", p);
|
||||
xfree (p);
|
||||
|
||||
RL_SETSTATE(RL_STATE_NSEARCH);
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifdef abs
|
||||
# undef abs
|
||||
#endif
|
||||
#define abs(x) (((x) >= 0) ? (x) : -(x))
|
||||
|
||||
_rl_search_cxt *_rl_nscxt = 0;
|
||||
|
||||
extern HIST_ENTRY *_rl_saved_line_for_history;
|
||||
|
||||
/* Functions imported from the rest of the library. */
|
||||
extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
static char *noninc_search_string = (char *) NULL;
|
||||
static int noninc_history_pos;
|
||||
|
||||
static char *prev_line_found = (char *) NULL;
|
||||
|
||||
static int rl_history_search_len;
|
||||
static int rl_history_search_pos;
|
||||
static int rl_history_search_flags;
|
||||
|
||||
static char *history_search_string;
|
||||
static int history_string_size;
|
||||
|
||||
static void make_history_line_current PARAMS((HIST_ENTRY *));
|
||||
static int noninc_search_from_pos PARAMS((char *, int, int));
|
||||
static int noninc_dosearch PARAMS((char *, int));
|
||||
static int noninc_search PARAMS((int, int));
|
||||
static int rl_history_search_internal PARAMS((int, int));
|
||||
static void rl_history_search_reinit PARAMS((int));
|
||||
|
||||
static _rl_search_cxt *_rl_nsearch_init PARAMS((int, int));
|
||||
static int _rl_nsearch_cleanup PARAMS((_rl_search_cxt *, int));
|
||||
static void _rl_nsearch_abort PARAMS((_rl_search_cxt *));
|
||||
static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
|
||||
|
||||
/* Make the data from the history entry ENTRY be the contents of the
|
||||
current line. This doesn't do anything with rl_point; the caller
|
||||
must set it. */
|
||||
static void
|
||||
make_history_line_current (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
_rl_replace_text (entry->line, 0, rl_end);
|
||||
_rl_fix_point (1);
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
/* POSIX.2 says that the `U' command doesn't affect the copy of any
|
||||
command lines to the edit line. We're going to implement that by
|
||||
making the undo list start after the matching line is copied to the
|
||||
current editing buffer. */
|
||||
rl_free_undo_list ();
|
||||
#endif
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
POS. If STRING begins with `^', the search must match STRING at the
|
||||
beginning of a history line, otherwise a full substring match is performed
|
||||
for STRING. DIR < 0 means to search backwards through the history list,
|
||||
DIR >= 0 means to search forward. */
|
||||
static int
|
||||
noninc_search_from_pos (string, pos, dir)
|
||||
char *string;
|
||||
int pos, dir;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
if (pos < 0)
|
||||
return -1;
|
||||
|
||||
old = where_history ();
|
||||
if (history_set_pos (pos) == 0)
|
||||
return -1;
|
||||
|
||||
RL_SETSTATE(RL_STATE_SEARCH);
|
||||
if (*string == '^')
|
||||
ret = history_search_prefix (string + 1, dir);
|
||||
else
|
||||
ret = history_search (string, dir);
|
||||
RL_UNSETSTATE(RL_STATE_SEARCH);
|
||||
|
||||
if (ret != -1)
|
||||
ret = where_history ();
|
||||
|
||||
history_set_pos (old);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Search for a line in the history containing STRING. If DIR is < 0, the
|
||||
search is backwards through previous entries, else through subsequent
|
||||
entries. Returns 1 if the search was successful, 0 otherwise. */
|
||||
static int
|
||||
noninc_dosearch (string, dir)
|
||||
char *string;
|
||||
int dir;
|
||||
{
|
||||
int oldpos, pos;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir);
|
||||
if (pos == -1)
|
||||
{
|
||||
/* Search failed, current history position unchanged. */
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = 0;
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
noninc_history_pos = pos;
|
||||
|
||||
oldpos = where_history ();
|
||||
history_set_pos (noninc_history_pos);
|
||||
entry = current_history ();
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode != vi_mode)
|
||||
#endif
|
||||
history_set_pos (oldpos);
|
||||
|
||||
make_history_line_current (entry);
|
||||
|
||||
rl_point = 0;
|
||||
rl_mark = rl_end;
|
||||
|
||||
rl_clear_message ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static _rl_search_cxt *
|
||||
_rl_nsearch_init (dir, pchar)
|
||||
int dir, pchar;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
char *p;
|
||||
|
||||
cxt = _rl_scxt_alloc (RL_SEARCH_NSEARCH, 0);
|
||||
if (dir < 0)
|
||||
cxt->sflags |= SF_REVERSE; /* not strictly needed */
|
||||
|
||||
cxt->direction = dir;
|
||||
cxt->history_pos = cxt->save_line;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
|
||||
/* Clear the undo list, since reading the search string should create its
|
||||
own undo list, and the whole list will end up being freed when we
|
||||
finish reading the search string. */
|
||||
rl_undo_list = 0;
|
||||
|
||||
/* Use the line buffer to read the search string. */
|
||||
rl_line_buffer[0] = 0;
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
p = _rl_make_prompt_for_search (pchar ? pchar : ':');
|
||||
rl_message ("%s", p);
|
||||
xfree (p);
|
||||
|
||||
RL_SETSTATE(RL_STATE_NSEARCH);
|
||||
|
||||
_rl_nscxt = cxt;
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_nsearch_cleanup (cxt, r)
|
||||
_rl_search_cxt *cxt;
|
||||
int r;
|
||||
{
|
||||
_rl_scxt_dispose (cxt, 0);
|
||||
_rl_nscxt = 0;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_NSEARCH);
|
||||
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_rl_nsearch_abort (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = cxt->save_point;
|
||||
rl_mark = cxt->save_mark;
|
||||
rl_restore_prompt ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_NSEARCH);
|
||||
}
|
||||
|
||||
/* Process just-read character C according to search context CXT. Return -1
|
||||
if the caller should abort the search, 0 if we should break out of the
|
||||
loop, and 1 if we should continue to read characters. */
|
||||
static int
|
||||
_rl_nsearch_dispatch (cxt, c)
|
||||
_rl_search_cxt *cxt;
|
||||
int c;
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case CTRL('W'):
|
||||
rl_unix_word_rubout (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('U'):
|
||||
rl_unix_line_discard (1, c);
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
case NEWLINE:
|
||||
return 0;
|
||||
|
||||
case CTRL('H'):
|
||||
case RUBOUT:
|
||||
if (rl_point == 0)
|
||||
{
|
||||
_rl_nsearch_abort (cxt);
|
||||
return -1;
|
||||
}
|
||||
_rl_rubout_char (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('C'):
|
||||
case CTRL('G'):
|
||||
rl_ding ();
|
||||
_rl_nsearch_abort (cxt);
|
||||
return -1;
|
||||
|
||||
default:
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
rl_insert_text (cxt->mb);
|
||||
else
|
||||
#endif
|
||||
_rl_insert_char (1, c);
|
||||
break;
|
||||
}
|
||||
|
||||
(*rl_redisplay_function) ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Perform one search according to CXT, using NONINC_SEARCH_STRING. Return
|
||||
-1 if the search should be aborted, any other value means to clean up
|
||||
using _rl_nsearch_cleanup (). Returns 1 if the search was successful,
|
||||
0 otherwise. */
|
||||
static int
|
||||
_rl_nsearch_dosearch (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
rl_mark = cxt->save_mark;
|
||||
|
||||
/* If rl_point == 0, we want to re-use the previous search string and
|
||||
start from the saved history position. If there's no previous search
|
||||
string, punt. */
|
||||
if (rl_point == 0)
|
||||
{
|
||||
if (noninc_search_string == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
rl_restore_prompt ();
|
||||
RL_UNSETSTATE (RL_STATE_NSEARCH);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to start the search from the current history position. */
|
||||
noninc_history_pos = cxt->save_line;
|
||||
FREE (noninc_search_string);
|
||||
noninc_search_string = savestring (rl_line_buffer);
|
||||
|
||||
/* If we don't want the subsequent undo list generated by the search
|
||||
matching a history line to include the contents of the search string,
|
||||
we need to clear rl_line_buffer here. For now, we just clear the
|
||||
undo list generated by reading the search string. (If the search
|
||||
fails, the old undo list will be restored by rl_maybe_unsave_line.) */
|
||||
rl_free_undo_list ();
|
||||
}
|
||||
|
||||
rl_restore_prompt ();
|
||||
return (noninc_dosearch (noninc_search_string, cxt->direction));
|
||||
}
|
||||
|
||||
/* Search non-interactively through the history list. DIR < 0 means to
|
||||
search backwards through the history of previous commands; otherwise
|
||||
the search is for commands subsequent to the current position in the
|
||||
history list. PCHAR is the character to use for prompting when reading
|
||||
the search string; if not specified (0), it defaults to `:'. */
|
||||
static int
|
||||
noninc_search (dir, pchar)
|
||||
int dir;
|
||||
int pchar;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
int c, r;
|
||||
|
||||
cxt = _rl_nsearch_init (dir, pchar);
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
return (0);
|
||||
|
||||
/* Read the search string. */
|
||||
r = 0;
|
||||
while (1)
|
||||
{
|
||||
c = _rl_search_getchar (cxt);
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
r = _rl_nsearch_dispatch (cxt, c);
|
||||
if (r < 0)
|
||||
return 1;
|
||||
else if (r == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
r = _rl_nsearch_dosearch (cxt);
|
||||
return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1));
|
||||
}
|
||||
|
||||
/* Search forward through the history list for a string. If the vi-mode
|
||||
code calls this, KEY will be `?'. */
|
||||
int
|
||||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return noninc_search (1, (key == '?') ? '?' : 0);
|
||||
}
|
||||
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
calls this, KEY will be `/'. */
|
||||
int
|
||||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
}
|
||||
|
||||
/* Search forward through the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
r = noninc_dosearch (noninc_search_string, 1);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
/* Reverse search in the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
r = noninc_dosearch (noninc_search_string, -1);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
int
|
||||
_rl_nsearch_callback (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
int c, r;
|
||||
|
||||
c = _rl_search_getchar (cxt);
|
||||
r = _rl_nsearch_dispatch (cxt, c);
|
||||
if (r != 0)
|
||||
return 1;
|
||||
|
||||
r = _rl_nsearch_dosearch (cxt);
|
||||
return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
rl_history_search_internal (count, dir)
|
||||
int count, dir;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int ret, oldpos;
|
||||
char *t;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Search COUNT times through the history for a line matching
|
||||
history_search_string. If history_search_string[0] == '^', the
|
||||
line must match from the start; otherwise any substring can match.
|
||||
When this loop finishes, TEMP, if non-null, is the history line to
|
||||
copy into the line buffer. */
|
||||
while (count)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
/* Get the history entry we found. */
|
||||
rl_history_search_pos = ret;
|
||||
oldpos = where_history ();
|
||||
history_set_pos (rl_history_search_pos);
|
||||
temp = current_history ();
|
||||
history_set_pos (oldpos);
|
||||
|
||||
/* Don't find multiple instances of the same line. */
|
||||
if (prev_line_found && STREQ (prev_line_found, temp->line))
|
||||
continue;
|
||||
prev_line_found = temp->line;
|
||||
count--;
|
||||
}
|
||||
|
||||
/* If we didn't find anything at all, return. */
|
||||
if (temp == 0)
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_ding ();
|
||||
/* If you don't want the saved history line (last match) to show up
|
||||
in the line buffer after the search fails, change the #if 0 to
|
||||
#if 1 */
|
||||
#if 0
|
||||
if (rl_point > rl_history_search_len)
|
||||
{
|
||||
rl_point = rl_end = rl_history_search_len;
|
||||
rl_line_buffer[rl_end] = '\0';
|
||||
rl_mark = 0;
|
||||
}
|
||||
#else
|
||||
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
|
||||
rl_mark = rl_end;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy the line we found into the current line buffer. */
|
||||
make_history_line_current (temp);
|
||||
|
||||
if (rl_history_search_flags & ANCHORED_SEARCH)
|
||||
rl_point = rl_history_search_len; /* easy case */
|
||||
else
|
||||
{
|
||||
t = strstr (rl_line_buffer, history_search_string);
|
||||
rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end;
|
||||
}
|
||||
rl_mark = rl_end;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rl_history_search_reinit (flags)
|
||||
int flags;
|
||||
{
|
||||
int sind;
|
||||
|
||||
rl_history_search_pos = where_history ();
|
||||
rl_history_search_len = rl_point;
|
||||
rl_history_search_flags = flags;
|
||||
|
||||
prev_line_found = (char *)NULL;
|
||||
if (rl_point)
|
||||
{
|
||||
/* Allocate enough space for anchored and non-anchored searches */
|
||||
if (rl_history_search_len >= history_string_size - 2)
|
||||
{
|
||||
history_string_size = rl_history_search_len + 2;
|
||||
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
|
||||
}
|
||||
sind = 0;
|
||||
if (flags & ANCHORED_SEARCH)
|
||||
history_search_string[sind++] = '^';
|
||||
strncpy (history_search_string + sind, rl_line_buffer, rl_point);
|
||||
history_search_string[rl_point + sind] = '\0';
|
||||
}
|
||||
_rl_free_saved_history_line ();
|
||||
}
|
||||
|
||||
/* Search forward in the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. The search is anchored to the beginning of the history line. */
|
||||
int
|
||||
rl_history_search_forward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit (ANCHORED_SEARCH);
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_next_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
|
||||
}
|
||||
|
||||
/* Search backward through the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_backward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit (ANCHORED_SEARCH);
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_previous_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
|
||||
}
|
||||
|
||||
/* Search forward in the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. The search succeeds if the search string is present anywhere
|
||||
in the history line. */
|
||||
int
|
||||
rl_history_substr_search_forward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_substr_search_forward &&
|
||||
rl_last_func != rl_history_substr_search_backward)
|
||||
rl_history_search_reinit (NON_ANCHORED_SEARCH);
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_next_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
|
||||
}
|
||||
|
||||
/* Search backward through the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_substr_search_backward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_substr_search_forward &&
|
||||
rl_last_func != rl_history_substr_search_backward)
|
||||
rl_history_search_reinit (NON_ANCHORED_SEARCH);
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_previous_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
|
||||
}
|
||||
+1
-1
@@ -94,7 +94,7 @@ sh_makepath (path, dir, flags)
|
||||
MAKEDOT();
|
||||
}
|
||||
else if ((flags & MP_IGNDOT) && path[0] == '.' && (path[1] == '\0' ||
|
||||
path[1] == '/' && path[2] == '\0'))
|
||||
(path[1] == '/' && path[2] == '\0')))
|
||||
{
|
||||
xpath = nullpath;
|
||||
pathlen = 0;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/* makepath.c - glue PATH and DIR together into a full pathname. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash 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 Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <bashansi.h>
|
||||
#include "shell.h"
|
||||
|
||||
#include <tilde/tilde.h>
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
/* MAKE SURE THESE AGREE WITH ../../externs.h. */
|
||||
|
||||
#ifndef MP_DOTILDE
|
||||
# define MP_DOTILDE 0x01
|
||||
# define MP_DOCWD 0x02
|
||||
# define MP_RMDOT 0x04
|
||||
# define MP_IGNDOT 0x08
|
||||
#endif
|
||||
|
||||
extern char *get_working_directory __P((char *));
|
||||
|
||||
static char *nullpath = "";
|
||||
|
||||
/* Take PATH, an element from, e.g., $CDPATH, and DIR, a directory name,
|
||||
and paste them together into PATH/DIR. Tilde expansion is performed on
|
||||
PATH if (flags & MP_DOTILDE) is non-zero. If PATH is NULL or the empty
|
||||
string, it is converted to the current directory. A full pathname is
|
||||
used if (flags & MP_DOCWD) is non-zero, otherwise `./' is used. If
|
||||
(flags & MP_RMDOT) is non-zero, any `./' is removed from the beginning
|
||||
of DIR. If (flags & MP_IGNDOT) is non-zero, a PATH that is "." or "./"
|
||||
is ignored. */
|
||||
|
||||
#define MAKEDOT() \
|
||||
do { \
|
||||
xpath = (char *)xmalloc (2); \
|
||||
xpath[0] = '.'; \
|
||||
xpath[1] = '\0'; \
|
||||
pathlen = 1; \
|
||||
} while (0)
|
||||
|
||||
char *
|
||||
sh_makepath (path, dir, flags)
|
||||
const char *path, *dir;
|
||||
int flags;
|
||||
{
|
||||
int dirlen, pathlen;
|
||||
char *ret, *xpath, *xdir, *r, *s;
|
||||
|
||||
if (path == 0 || *path == '\0')
|
||||
{
|
||||
if (flags & MP_DOCWD)
|
||||
{
|
||||
xpath = get_working_directory ("sh_makepath");
|
||||
if (xpath == 0)
|
||||
{
|
||||
ret = get_string_value ("PWD");
|
||||
if (ret)
|
||||
xpath = savestring (ret);
|
||||
}
|
||||
if (xpath == 0)
|
||||
MAKEDOT();
|
||||
else
|
||||
pathlen = strlen (xpath);
|
||||
}
|
||||
else
|
||||
MAKEDOT();
|
||||
}
|
||||
else if ((flags & MP_IGNDOT) && path[0] == '.' && (path[1] == '\0' ||
|
||||
path[1] == '/' && path[2] == '\0'))
|
||||
{
|
||||
xpath = nullpath;
|
||||
pathlen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpath = ((flags & MP_DOTILDE) && *path == '~') ? bash_tilde_expand (path, 0) : (char *)path;
|
||||
pathlen = strlen (xpath);
|
||||
}
|
||||
|
||||
xdir = (char *)dir;
|
||||
dirlen = strlen (xdir);
|
||||
if ((flags & MP_RMDOT) && dir[0] == '.' && dir[1] == '/')
|
||||
{
|
||||
xdir += 2;
|
||||
dirlen -= 2;
|
||||
}
|
||||
|
||||
r = ret = (char *)xmalloc (2 + dirlen + pathlen);
|
||||
s = xpath;
|
||||
while (*s)
|
||||
*r++ = *s++;
|
||||
if (s > xpath && s[-1] != '/')
|
||||
*r++ = '/';
|
||||
s = xdir;
|
||||
while (*r++ = *s++)
|
||||
;
|
||||
if (xpath != path && xpath != nullpath)
|
||||
free (xpath);
|
||||
return (ret);
|
||||
}
|
||||
@@ -5111,7 +5111,7 @@ process_substitute (string, open_for_read_in_child)
|
||||
|
||||
#if !defined (HAVE_DEV_FD)
|
||||
/* Open the named pipe in the child. */
|
||||
fd = open (pathname, open_for_read_in_child ? O_RDONLY|O_NONBLOCK : O_WRONLY);
|
||||
fd = open (pathname, open_for_read_in_child ? O_RDONLY : O_WRONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
/* Two separate strings for ease of translation. */
|
||||
@@ -8418,7 +8418,7 @@ add_string:
|
||||
SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size);
|
||||
}
|
||||
/* This is the fix for " $@\ " */
|
||||
else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && ((sh_syntaxtab[c] & tflag) == 0) & isexp == 0 && isifs (c))
|
||||
else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && ((sh_syntaxtab[c] & tflag) == 0) && isexp == 0 && isifs (c))
|
||||
{
|
||||
RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
|
||||
DEFAULT_ARRAY_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user