bash-5.0-alpha release

This commit is contained in:
Chet Ramey
2018-05-22 16:51:07 -04:00
parent 7de27456f6
commit 9a51695bed
480 changed files with 69105 additions and 52542 deletions
+523 -1
View File
@@ -1,3 +1,526 @@
This document details the changes between this version, bash-5.0-alpha, and
the previous version, bash-4.4-release.
1. Changes to Bash
a. Fixed a bug that could cause traps in background jobs to give the terminal
to the wrong process group.
b. Fixed a bug that caused `kill -l 0' to print an out-of-range error.
c. Fixed a problem that could result in here-documents being displayed in
the wrong order.
d. Fixed a number of out-of-bounds and free memory read errors found via
fuzzing.
e. Fixed a subshell inheritance problem that could cause a subshell to wait for
the wrong process.
f. Fixed a bug that caused SHLVL to be incremented one too many times when
creating subshells.
g. A job dying due to SIGINT can now interrupt sourcing a file in a shell with
job control enabled.
h. Fixed a spurious warning about unterminated ${ or $( constructs during
word completion.
i. The shell no longer runs traps if a signal arrives while reading command
substitution output.
j. Fixed an arithmetic expansion error that could allow ++var++ as valid
syntax.
k. Fixed an error that allowed out-of-bounds references to the directory stack.
l. The shell does a better job of saving multi-line history entries with
embedded comments.
m. Fixed a bug that could cause quoted bracket expressions in regular expression
arguments to `[[' to not match correctly.
n. Fixed a bug that could cause an IFS character in a word to result in an
extra '\001' character in the expansion.
o. A trailing backslash in a glob pattern can match a trailing backslash in the
string.
p. Fixed a memory leak in the process creation code path when job control is
enabled.
q. Fixed a bug that caused `printf' to output broken surrogate pairs for
Japanese locales.
r. Fixed a bug that caused a SIGINT generated from `kill' in a dot script to
kill an interactive shell.
s. Fixed a bug that could cause the `read' builtin to not fully read a
multibyte character.
t. Fixed a bug that could cause identifiers to be evaluated in conditional
arithmetic expressions even when evaluation is suppressed.
u. Fixed a bug that could result in command substitution, when executed in a
context where word splitting is not performed, to leave a stray '\001'
character in the string.
v. Fixed a bug that could cause history expansion to be disabled in a non-
interactive shell even if `-o histexpand' is supplied at startup.
w. Fixed a bug that caused `read -N' to strip leading whitespace IFS characters.
x. Fixed a bug that caused spurious tilde expansion in arithmetic expressions.
y. If indirect expansion attempts to indirectly reference through an unset
variable, report an error.
z. Added a guard to prevent the shell from looping while receiving an endless
stream of SIGTTIN at shell startup.
aa. Fixed a bug with parsing here documents inside a command substitution when
looking for the closing delimiter.
bb. Fixed a bug that caused printf to not quote all <blank> characters in the
current locale when using the `%q' format specifier.
cc. Fixed a bug with bash's internal buffered I/O system that caused the input
pointer to not be reset when read(2) returned an EOF.
dd. Bash now installs its SIGWINCH signal handler with SA_RESTART, so it will
not interrupt open/read/write system calls.
ee. The ERR trap now reports line numbers more reliably.
ff. The shell no longer tries to manipulate the terminal process group if a
command or process substitution is killed by SIGTERM when job control is
enabled.
gg. Fixed a bug that caused extglob patterns to match filenames beginning with
a period.
hh. File descriptors open for writing to here documents are no longer available
to subshells.
ii. Make sure word completion doesn't perform command or process substitution.
jj. Fixed a bug with parsing $$'...' inside a command substitution.
kk. Fixed a bug that caused bash to remove backslash-newline pairs from the
body of a here-document with a quoted delimiter inside a command
substitution.
ll. Fixed a bug that could cause the shell to hang when adding a pid to the
table of background process exit statuses.
mm. Fixed a bug that could cause 0x01 characters to be doubled in the output
of process substitution.
nn. Restricted shells now clear the hash table before making the PATH variable
read-only.
oo. There are a number of changes to the expansion of $* and $@ in contexts
where word splitting does not occur (quoted and unquoted), with IFS set
to NULL or a non-standard value, mostly to deal with the consequences of
the behavior defined in Posix interpretation 888.
pp. There are a number of changes to nameref variable handling to avoid
creating variables with invalid names.
qq. A non-interactive posix mode shell no longer exits when an assignment
statement fails if the assignment is utimately being performed by the
`command' builtin.
rr. When using character class names for globbing, don't allow case
insensitivity, even if nocaseglob is enabled.
ss. Fixed a bug that allowed some redirections to stay in place if a later
redirection failed.
tt. Fixed a bug in how command and process substitutions are recognized within
other parameter expansions.
uu. Fixed a bug that caused bash to loop under certain circumstances when
performing arithmetic expansion on a variable whose value is an invalid
expression.
vv. Fixed a bug that could cause bash to expand aliases inappropriately while
parsing compound commands like `case'.
ww. Fixed a bug that could cause `read -N' to fail to read complete multibyte
characters, even when the sequences are incomplete or invalid, with or
without readline.
xx. Fixed a bug that could cause `case' to fail to match patterns containing
0x01 characters.
yy. Fixed a bug that caused exported functions to contain stray 0x01 characters.
zz. Fixed some inconsistencies with how the history number is handled in the
various prompt strings.
aaa. Fixed a bug that could cause a core dump if READLINE_LINE was unset
inside a shell function bound to a key sequence with `bind -x'.
bbb. Fixed a bug that could cause bash to not read a token terminator correctly
if a command substitution was used inside an arithmetic `for' command.
ccc. Fixed problems that could occur with a fatal arithmetic expansion error
in a context (like prompt expansion) where you can't jump back to the
top level.
ddd. Expression errors in arithmetic `for' commands are treated more like
shell syntax errors.
eee. Fixed a parser synchronization error resulting from a syntax error
followed immediately by an EOF.
fff. When executing a shell function, the first line in the function ($LINENO)
is line 1 instead of line 0, as Posix requires.
ggg. In Posix mode, bash will canonicalize the value of PWD it inherits from
the environment and use that to set its idea of the current directory.
hhh. If LINENO is exported, bash needs to regenerate its value each time it
constructs the environment.
iii. Fixed a bug with restoring the SIGINT handler when using `wait -n'.
jjj. Make sure the `coproc' command returns an appropriate status if the NAME
argument is invalid.
kkk. Fixed a problem with arithmetic expressions containing array references
that contain arithmetic expressions with syntax errors.
lll. The `select' command and help builtin will use $COLUMNS before the window
size returned from the kernel as the terminal width.
mmm. `read -n 0' and `read -N 0' now try a zero-length read to attempt to
detect file descriptor errors.
nnn. The `read' builtin now does a better job of acting on signals that don't
interrrupt read(2).
ooo. Fixed some cases where `printf -v' did not return failure status on a
variable assignment error.
ppp. Fixed temporary environment propagation back to the current environment
so that it doesn't happen for special builtins run by the `command'
builtin.
qqq. Fixed a bug when searhing for the end of a here-document delimiter in a
command substitution.
rrr. Fixed a bug that could cause `cd ${DIRSTACK[0]}' to fail.
sss. Fixed a bug that could cause reserved words to not be recognized in a
for statement without the `in' inside a command substitution.
ttt. Fixed a bug that could cause a double-free in a timed command with an
expansion error.
uuu. Fixed a bug that could cause a core dump if a script switches from a UTF-8
locale to a different locale after displaying a lone surrogate character.
vvv. Fixed cases where bash prematurely removed FIFOs attached to process
substitutions.
www. Fixed a problem with calculating the size of the table that stores exit
statuses from background processes when the child process resource limit
is very large.
xxx. Fixed a memory leak with functions using `return' when using FIFOs for
standard input.
yyy. `wait' without arguments attempts to wait for all active process
substitution processes.
zzz. Fixed a bug where an indirect parameter was subjected to word splitting
when trying to find the indirected variable name.
aaaa. Fixed a bug that could allow restricted shell users to add commands to
the hash table.
bbbb. When using the `!(patlist)' extended globbing operator, a filename
beginning with a `.' that doesn't match any of the patterns is not
returned as a match if leading dots must be matched explicitly.
cccc. Fixed a bug that could cause line number and source file information for
a function definition to be incorrect if there are multiple definitions.
dddd. Fixed a bug that could cause builtins like `readonly' to behave
differently when applied to arrays and scalar variables within functions.
eeee. Fixed a bug that could cause alias expansion to add an extra space to
a quoted string that begins outside the alias expansion.
ffff. Fixed a bug that could result in unwanted alias expansion after timing
the null command.
gggg. Fixed a bug that could cause a core dump if a timestamp in a history
file overflowed a time_t.
hhhh. Restricted shells can no longer redirect from /dev/tcp or /dev/udp, since
the kernel calls make those file descriptors read-write.
iiii. Fixed a problem with splitting double-quoted words for programmable
completion when the double quote immediately follows another word
delimiter.
jjjj. Fixed a bug resulting in a use-after-free if two file descriptors share
the same input buffer.
kkkk. The error message resulting from ${x:?} and ${x?} now differs depending
on whether the variable is null or unset.
llll. In Posix mode, the shell exits if a variable assignment fails and precedes
an empty simple command (after expansion).
mmmm. Fixed a timing problem with SIGALRM that could cause the read builtin to
drop characters.
nnnn. Added code to deal with kill(2) failing to send the shell a fatal signal
due to Linux pid namespace peculiarities.
oooo. Fixed a bug that made \C-@ (NUL) unusable in key sequences used for
`bind -x' commands.
pppp. Fixed a bug that could cause SIGINT recursion when running an external
command in a trap the shell takes after a command exits due to SIGINT.
qqqq. Make sure the shell turns off job control before running the command-
not-found handle, so the command doesn't try to manipulate process
groups.
rrrr. Fixed a problem with timing process substitutions that caused the shell
to print timing information for the calling command.
ssss. Fixed a bug that caused backquotes in a here-document delimiter to mark
the delimiter as quoted (inhibiting expansion of the here-document
contents).
tttt. Fixed several problems with 0x01 and 0x177 in case pattern lists and
conditional command pattern matches.
uuuu. Fixed a bug that could cause the pattern matching engine to not recognize
locale-specific character classes.
vvvv. The auto-configuration now tests for /dev/stdin and /dev/fd independently.
wwww. The `globstar' code now skips over symbolic links to directories,
preventing them from being scanned twice.
xxxx. When running `bind -x' commands, bash now sets READLINE_POINT based on
the number of characters in the readline line buffer, not the number of
bytes.
yyyy. Fixed a problem that could cause recursive trap evaluation of the RETURN
trap when using `eval return'.
zzzz. Fixed a bug with expanding 0x01 in an unquoted here-document.
aaaaa. The process substitution code now closes and unlinks FIFOs when the
process on the other side exits, in order to prevent SIGPIPE or
waiting until a FIFO opened for read has a writer.
bbbbb. Fixed a bug with recursive calls to the parser overwriting the token in
an {id}>foo construct.
ccccc. After a Posix discussion, the pattern matching engine just skips over
invalid character classes in bracket expressions, instead of matching
them like individual characters in the expression.
ddddd. Fixed a posix-mode problem with variable scoping when creating variables
from assignment statements preceding special builtins.
eeeee. Fixed a bug that could cause patterns containing backslashes to not be
run through the pattern matching engine.
fffff. Fixed a bug that could cause redirections to compound commands to not
be `undone' if the file descriptor in the redirection was closed when
the redirection was initially processed.
ggggg. Fixed a bug that could cause buffer corruption when using `bind -x' in
a command execute as a result of a key binding installed by `bind -x'.
2. Changes to Readline
a. Added a guard to prevent nested macros from causing an infinite expansion
loop.
b. Instead of allocating enough history list entries to hold the maximum list
size, cap the number allocated initially.
c. Added a strategy to avoid allocating huge amounts of memory if a block of
history entries without timestamps occurs after a block with timestamps.
d. Added support for keyboard timeouts when an ESC character is the last
character in a macro.
e. There are several performance improvements when in a UTF-8 locale.
f. Readline does a better job of preserving the original set of blocked =
signals when using pselect() to wait for input.
g. Fixed a bug that caused multibyte characters in macros to be mishandled.
h. Fixed several bugs in the code that calculates line breaks when expanding
prompts that span several lines, contain multibyte characters, and contain
invisible character seqeuences.
i. Fixed several bugs in cursor positioning when displaying lines with prompts
containing invisible characters and multibyte characters.
j. When performing case-insensitive completion, Readline no longer sorts the
list of matches unless directed to do so.
k. Fixed a problem with key sequences ending with a backslash.
l. Fixed out-of-bounds and free memory read errors found via fuzzing.
m. Fixed several cases where the mark was set to an invalid value.
n. Fixed a problem with the case-changing operators in the case where the
lower and upper case versions of a character do not have the same number
of bytes.
o. Handle incremental and non-incremental search character reads returning EOF.
p. Handle the case where a failing readline command at the end of a multi-key
sequence could be misinterpreted.
q. The history library now prints a meaningful error message if the history
file isn't a regular file.
r. Fixed a problem with vi-mode redo (`.') on a command when trying to replace
a multibyte character.
s. The key binding code now attempts to remove a keymap if a key unbinding
leaves it empty.
t. Fixed a line-wrapping issue that caused problems for some terminal
emulators.
u. If there is a key bound to the tty's VDISCARD special character, readline
disables VDISCARD while it is active.
v. Fixed a problem with exiting bracketed paste mode on terminals that assume
the bracketed paste mode character sequence contains visible characters.
w. Fixed a bug that could cause a key binding command to refer to an
uninitialized variable.
3. New Features in Bash
a. The `wait' builtin can now wait for the last process substitution created.
b. There is an EPOCHSECONDS variable, which expands to the time in seconds
since the Unix epoch.
c. There is an EPOCHREALTIME variable, which expands to the time in seconds
since the Unix epoch with microsecond granularity.
d. New loadable builtins: rm, stat, fdflags.
e. BASH_ARGV0: a new variable that expands to $0 and sets $0 on assignment.
f. When supplied a numeric argument, the shell-expand-line bindable readline
command does not perform quote removal and suppresses command and process
substitution.
g. `history -d' understands negative arguments: negative arguments offset from
the end of the history list.
h. The `name' argument to the `coproc' reserved word now undergoes word
expansion, so unique coprocs can be created in loops.
i. A nameref name resolution loop in a function now resolves to a variable by
that name in the global scope.
j. The `wait' builtin now has a `-f' option, which signfies to wait until the
specified job or process terminates, instead of waiting until it changes
state.
k. There is a define in config-top.h that allows the shell to use a static
value for $PATH, overriding whatever is in the environment at startup, for
use by the restricted shell.
l. Process substitution does not inherit the `v' option, like command
substitution.
m. If a non-interactive shell with job control enabled detects that a foreground
job died due to SIGINT, it acts as if it received the SIGINT.
n. The SIGCHLD trap is run once for each exiting child process even if job
control is not enabled when the shell is in Posix mode.
o. A new shopt option: localvar_inherit; if set, a local variable inherits the
value of a variable with the same name at the nearest preceding scope.
p. `bind -r' now checks whether a key sequence is bound before binding it to
NULL, to avoid creating keymaps for a multi-key sequence.
q. A numeric argument to the line editing `operate-and-get-next' command
specifies which history entry to use.
r. The positional parameters are now assigned before running the shell startup
files, so startup files can use $@.
s. There is a compile-time option that forces the shell to disable the check
for an inherited OLDPWD being a directory.
t. The `history' builtin can now delete ranges of history entries using
`-d start-end'.
u. The `vi-edit-and-execute-command' bindable readline command now puts readline
back in vi insertion mode after executing commands from the edited file.
v. The command completion code now matches aliases and shell function names
case-insensitively if the readline completion-ignore-case variable is set.
w. There is a new `assoc_expand_once' shell option that attempts to expand
associative array subscripts only once.
x. The shell only sets up BASH_ARGV and BASH_ARGC at startup if extended
debugging mode is active. The old behavior of unconditionally setting them
is available as part of the shell compatibility options.
y. The `umask' builtin now allows modes and masks greater than octal 777.
z. The `times' builtin now honors the current locale when printing a decimal
point.
aa. There is a new (disabled by default, undocumented) shell option to enable
and disable sending history to syslog at runtime.
4. New Features in Readline
a. Non-incremental vi-mode search (`N', `n') can search for a shell pattern, as
Posix specifies (uses fnmatch(3) if available).
b. There are new `next-screen-line' and `previous-screen-line' bindable
commands, which move the cursor to the same column in the next, or previous,
physical line, respectively.
c. There are default key bindings for control-arrow-key key combinations.
d. A negative argument (-N) to `quoted-insert' means to insert the next N
characters using quoted-insert.
e. New public function: rl_check_signals(), which allows applications to
respond to signals that readline catches while waiting for input using
a custom read function.
f. There is new support for conditionally testing the readline version in an
inputrc file, with a full set of arithmetic comparison operators available.
g. There is a simple variable comparison facility available for use within an
inputrc file. Allowable operators are equality and inequality; string
variables may be compared to a value; boolean variables must be compared to
either `on' or `off'; variable names are separated from the operator by
whitespace.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.4-release, and
the previous version, bash-4.4-rc2.
@@ -21,7 +544,6 @@ e. Fixed several potential buffer overflow issues in the word expansion code.
3. New Features in Bash
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.4-rc2, and
the previous version, bash-4.4-beta2.
+13 -3
View File
@@ -2,9 +2,9 @@ Compatibility with previous versions
====================================
This document details the incompatibilities between this version of bash,
bash-4.4, and the previous widely-available versions, bash-3.x (which is
still the `standard' version for Mac OS X), 4.1/4.2 (which are still
standard on a few Linux distributions), and bash-4.3, the current
bash-5.0, and the previous widely-available versions, bash-3.x (which is
still the `standard' version for Mac OS X), 4.2/4.3 (which are still
standard on a few Linux distributions), and bash-4.4, the current
widely-available version. These were discovered by users of bash-2.x
through 4.x, so this list is not comprehensive. Some of these
incompatibilities occur between the current version and versions 2.0 and
@@ -391,6 +391,11 @@ above.
argument to `declare' or a similar builtin expands to a word that looks
like a compound array assignment (e.g. declare w=$x where x='(foo)').
60. Bash-5.0 only sets up BASH_ARGV and BASH_ARGC at startup if extended
debugging mode is active. The old behavior of unconditionally setting
BASH_ARGC and BASH_ARGV is available at compatibility levels less than
or equal to 44.
Shell Compatibility Level
=========================
@@ -451,6 +456,11 @@ compat43 set
continue loops in the calling context. Bash-4.4 and later reset the
loop state to prevent this.
compat44 set
- the shell sets up the values used by BASH_ARGV and BASH_ARGC so
they can expand to the shell's positional parameters even if extended
debug mode is not enabled
-------------------------------------------------------------------------------
Copying and distribution of this file, with or without modification,
-339
View File
@@ -1,339 +0,0 @@
Date: Tue, 06 Feb 2007 16:06:58 -0500
From: Steve Grubb <sgrubb@redhat.com>
Subject: Re: bash and linux audit
To: chet.ramey@case.edu
Organization: Red Hat
OK, I released audit 1.4 Sunday which has the logging function for user
commands. It produces audit events like this:
type=USER_CMD msg=audit(01/30/2007 18:23:45.793:143) : user pid=22862 uid=root
auid=root subj=system_u:system_r:unconfined_t:s0-s0:c0.c1023
msg='cwd=/root/test dir cmd=ls -l (terminal=tty1 res=success)'
diff -urp bash-3.2.orig/config-bot.h bash-3.2/config-bot.h
--- bash-3.2.orig/config-bot.h 2007-01-03 09:01:05.000000000 -0500
+++ bash-3.2/config-bot.h 2007-01-20 11:59:23.000000000 -0500
@@ -97,6 +97,11 @@
# define RESTRICTED_SHELL_NAME "rbash"
#endif
+/* If the shell is called by this name, it will become audited. */
+#if defined (AUDIT_SHELL)
+# define AUDIT_SHELL_NAME "aubash"
+#endif
+
/***********************************************************/
/* Make sure feature defines have necessary prerequisites. */
/***********************************************************/
diff -urp bash-3.2.orig/config.h.in bash-3.2/config.h.in
--- bash-3.2.orig/config.h.in 2007-01-03 09:01:05.000000000 -0500
+++ bash-3.2/config.h.in 2007-01-20 11:59:23.000000000 -0500
@@ -81,6 +81,11 @@
flag. */
#undef RESTRICTED_SHELL
+/* Define AUDIT_SHELL if you want the generated shell to audit all
+ actions performed by root account. The shell thus generated can become
+ audited by being run with the name "aubash". */
+#undef AUDIT_SHELL
+
/* Define DISABLED_BUILTINS if you want "builtin foo" to always run the
shell builtin "foo", even if it has been disabled with "enable -n foo". */
#undef DISABLED_BUILTINS
diff -urp bash-3.2.orig/configure.in bash-3.2/configure.in
--- bash-3.2.orig/configure.in 2007-01-03 09:01:05.000000000 -0500
+++ bash-3.2/configure.in 2007-01-20 11:59:23.000000000 -0500
@@ -162,6 +162,7 @@ opt_history=yes
opt_bang_history=yes
opt_dirstack=yes
opt_restricted=yes
+opt_audit=yes
opt_process_subst=yes
opt_prompt_decoding=yes
opt_select=yes
@@ -195,8 +196,8 @@ dnl a minimal configuration turns everyt
dnl added individually
if test $opt_minimal_config = yes; then
opt_job_control=no opt_alias=no opt_readline=no
- opt_history=no opt_bang_history=no opt_dirstack=no
- opt_restricted=no opt_process_subst=no opt_prompt_decoding=no
+ opt_history=no opt_bang_history=no opt_dirstack=no opt_restricted=no
+ opt_audit=no opt_process_subst=no opt_prompt_decoding=no
opt_select=no opt_help=no opt_array_variables=no opt_dparen_arith=no
opt_brace_expansion=no opt_disabled_builtins=no opt_command_timing=no
opt_extended_glob=no opt_cond_command=no opt_arith_for_command=no
@@ -227,6 +228,7 @@ AC_ARG_ENABLE(progcomp, AC_HELP_STRING([
AC_ARG_ENABLE(prompt-string-decoding, AC_HELP_STRING([--enable-prompt-string-decoding], [turn on escape character decoding in prompts]), opt_prompt_decoding=$enableval)
AC_ARG_ENABLE(readline, AC_HELP_STRING([--enable-readline], [turn on command line editing]), opt_readline=$enableval)
AC_ARG_ENABLE(restricted, AC_HELP_STRING([--enable-restricted], [enable a restricted shell]), opt_restricted=$enableval)
+AC_ARG_ENABLE(audit, AC_HELP_STRING([--enable-audit], [enable an audited shell]), opt_audit=$enableval)
AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select], [include select command]), opt_select=$enableval)
AC_ARG_ENABLE(separate-helpfiles, AC_HELP_STRING([--enable-separate-helpfiles], [use external files for help builtin documentation]), opt_separate_help=$enableval)
AC_ARG_ENABLE(single-help-strings, AC_HELP_STRING([--enable-single-help-strings], [store help documentation as a single string to ease translation]), opt_single_longdoc_strings=$enableval)
@@ -254,6 +256,10 @@ fi
if test $opt_restricted = yes; then
AC_DEFINE(RESTRICTED_SHELL)
fi
+if test $opt_audit = yes; then
+AC_DEFINE(AUDIT_SHELL)
+AUDIT_LIB='-laudit'
+fi
if test $opt_process_subst = yes; then
AC_DEFINE(PROCESS_SUBSTITUTION)
fi
@@ -355,6 +361,8 @@ AC_SUBST(HELPDIRDEFINE)
AC_SUBST(HELPINSTALL)
AC_SUBST(HELPSTRINGS)
+AC_SUBST(AUDIT_LIB)
+
echo ""
echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}"
echo ""
diff -urp bash-3.2.orig/doc/bash.1 bash-3.2/doc/bash.1
--- bash-3.2.orig/doc/bash.1 2007-01-03 09:01:05.000000000 -0500
+++ bash-3.2/doc/bash.1 2007-01-20 11:59:23.000000000 -0500
@@ -155,6 +155,12 @@ single-character options to be recognize
.PP
.PD 0
.TP
+.B \-\-audit
+The shell logs all commands run by the root user (see
+.SM
+.B "AUDIT SHELL"
+below).
+.TP
.B \-\-debugger
Arrange for the debugger profile to be executed before the shell
starts.
@@ -8770,6 +8776,17 @@ turns off any restrictions in the shell
script.
.\" end of rbash.1
.if \n(zY=1 .ig zY
+.SH "AUDIT SHELL"
+.zY
+.PP
+If
+.B bash
+is started with the name
+.BR aubash ,
+or the
+.B \-\-audit
+option is supplied at invocation, the shell logs all commands issued by the root user to the audit system.
+.if \n(zY=1 .ig zY
.SH "SEE ALSO"
.PD 0
.TP
diff -urp bash-3.2.orig/eval.c bash-3.2/eval.c
--- bash-3.2.orig/eval.c 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/eval.c 2007-01-20 11:59:23.000000000 -0500
@@ -45,6 +45,11 @@
# include "bashhist.h"
#endif
+#if defined (AUDIT_SHELL)
+# include <libaudit.h>
+# include <errno.h>
+#endif
+
extern int EOF_reached;
extern int indirection_level;
extern int posixly_correct;
@@ -58,6 +63,38 @@ extern int rpm_requires;
static void send_pwd_to_eterm __P((void));
static sighandler alrm_catcher __P((int));
+#if defined (AUDIT_SHELL)
+static int audit_fd = -1;
+
+static int
+audit_start ()
+{
+ audit_fd = audit_open ();
+ if (audit_fd < 0)
+ return -1;
+ else
+ return 0;
+}
+
+static int
+audit (cmd, result)
+ char *cmd;
+ int result;
+{
+ int rc;
+
+ if (audit_fd < 0)
+ return 0;
+
+ rc = audit_log_user_command (audit_fd, AUDIT_USER_CMD, cmd,
+ NULL, !result);
+ close (audit_fd);
+ audit_fd = -1;
+ return rc;
+}
+#endif
+
+
/* Read and execute commands until EOF is reached. This assumes that
the input source has already been initialized. */
int
@@ -145,7 +182,25 @@ reader_loop ()
executing = 1;
stdin_redir = 0;
+#if defined (AUDIT_SHELL)
+ if (audited && interactive_shell && getuid () == 0)
+ {
+ if (audit_start () < 0)
+ {
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
+ errno != EAFNOSUPPORT)
+ return EXECUTION_FAILURE;
+ }
+ }
+#endif
+
execute_command (current_command);
+#if defined (AUDIT_SHELL)
+ {
+ extern char *shell_input_line;
+ audit (shell_input_line, last_command_exit_value);
+ }
+#endif
exec_done:
QUIT;
diff -urp bash-3.2.orig/externs.h bash-3.2/externs.h
--- bash-3.2.orig/externs.h 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/externs.h 2007-01-20 12:05:00.000000000 -0500
@@ -77,6 +77,10 @@ extern int shell_is_restricted __P((char
extern int maybe_make_restricted __P((char *));
#endif
+#if defined (AUDIT_SHELL)
+extern int maybe_make_audited __P((char *));
+#endif
+
extern void unset_bash_input __P((int));
extern void get_current_user_info __P((void));
diff -urp bash-3.2.orig/flags.c bash-3.2/flags.c
--- bash-3.2.orig/flags.c 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/flags.c 2007-01-20 11:59:23.000000000 -0500
@@ -142,6 +142,12 @@ int restricted = 0; /* currently restri
int restricted_shell = 0; /* shell was started in restricted mode. */
#endif /* RESTRICTED_SHELL */
+#if defined (AUDIT_SHELL)
+/* Non-zero means that this shell is audited. An audited shell records
+ each command that the root user executes. */
+int audited = 0; /* shell was started in audit mode. */
+#endif /* AUDIT_SHELL */
+
/* Non-zero means that this shell is running in `privileged' mode. This
is required if the shell is to run setuid. If the `-p' option is
not supplied at startup, and the real and effective uids or gids
diff -urp bash-3.2.orig/flags.h bash-3.2/flags.h
--- bash-3.2.orig/flags.h 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/flags.h 2007-01-20 11:59:23.000000000 -0500
@@ -66,6 +66,10 @@ extern int restricted;
extern int restricted_shell;
#endif /* RESTRICTED_SHELL */
+#if defined (AUDIT_SHELL)
+extern int audited;
+#endif /* AUDIT_SHELL */
+
extern int *find_flag __P((int));
extern int change_flag __P((int, int));
extern char *which_set_flags __P((void));
Only in bash-3.2: .made
diff -urp bash-3.2.orig/Makefile.in bash-3.2/Makefile.in
--- bash-3.2.orig/Makefile.in 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/Makefile.in 2007-01-20 11:59:23.000000000 -0500
@@ -366,6 +366,8 @@ MALLOC_LIBRARY = @MALLOC_LIBRARY@
MALLOC_LDFLAGS = @MALLOC_LDFLAGS@
MALLOC_DEP = @MALLOC_DEP@
+AUDIT_LIB = @AUDIT_LIB@
+
ALLOC_HEADERS = $(ALLOC_LIBSRC)/getpagesize.h $(ALLOC_LIBSRC)/shmalloc.h \
$(ALLOC_LIBSRC)/imalloc.h $(ALLOC_LIBSRC)/mstats.h \
$(ALLOC_LIBSRC)/table.h $(ALLOC_LIBSRC)/watch.h
@@ -386,7 +388,7 @@ BASHINCFILES = $(BASHINCDIR)/posixstat.
$(BASHINCDIR)/ocache.h
LIBRARIES = $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
- $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LOCAL_LIBS)
+ $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LOCAL_LIBS) $(AUDIT_LIB)
LIBDEP = $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_DEP) $(GLOB_DEP) \
$(TILDE_DEP) $(MALLOC_DEP)
diff -urp bash-3.2.orig/parse.y bash-3.2/parse.y
--- bash-3.2.orig/parse.y 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/parse.y 2007-01-20 11:59:23.000000000 -0500
@@ -258,7 +258,7 @@ int need_here_doc;
/* Where shell input comes from. History expansion is performed on each
line when the shell is interactive. */
-static char *shell_input_line = (char *)NULL;
+char *shell_input_line = (char *)NULL;
static int shell_input_line_index;
static int shell_input_line_size; /* Amount allocated for shell_input_line. */
static int shell_input_line_len; /* strlen (shell_input_line) */
diff -urp bash-3.2.orig/shell.c bash-3.2/shell.c
--- bash-3.2.orig/shell.c 2007-01-03 09:01:06.000000000 -0500
+++ bash-3.2/shell.c 2007-01-20 12:04:23.000000000 -0500
@@ -240,6 +240,9 @@ struct {
#if defined (RESTRICTED_SHELL)
{ "restricted", Int, &restricted, (char **)0x0 },
#endif
+#if defined (AUDIT_SHELL)
+ { "audit", Int, &audited, (char **)0x0 },
+#endif
{ "verbose", Int, &echo_input_at_read, (char **)0x0 },
{ "version", Int, &do_version, (char **)0x0 },
{ "wordexp", Int, &wordexp_only, (char **)0x0 },
@@ -644,6 +647,10 @@ main (argc, argv, env)
maybe_make_restricted (shell_name);
#endif /* RESTRICTED_SHELL */
+#if defined (AUDIT_SHELL)
+ maybe_make_audited (shell_name);
+#endif
+
if (wordexp_only)
{
startup_state = 3;
@@ -1143,6 +1150,29 @@ maybe_make_restricted (name)
}
#endif /* RESTRICTED_SHELL */
+#if defined (AUDIT_SHELL)
+/* Perhaps make this shell an `audited' one, based on NAME. If the
+ basename of NAME is "aubash", then this shell is audited. The
+ name of the audited shell is a configurable option, see config.h.
+ In an audited shell, all actions performed by root will be logged
+ to the audit system.
+ Do this also if `audited' is already set to 1 maybe the shell was
+ started with --audit. */
+int
+maybe_make_audited (name)
+ char *name;
+{
+ char *temp;
+
+ temp = base_pathname (name);
+ if (*temp == '-')
+ temp++;
+ if (audited || (STREQ (temp, AUDIT_SHELL_NAME)))
+ audited = 1;
+ return (audited);
+}
+#endif /* AUDIT_SHELL */
+
/* Fetch the current set of uids and gids and return 1 if we're running
setuid or setgid. */
static int
+3710
View File
File diff suppressed because it is too large Load Diff
-449
View File
@@ -1,449 +0,0 @@
From jwe@che.utexas.edu Wed Sep 21 17:23:40 1994
Flags: 10
Return-Path: jwe@che.utexas.edu
Received: from po.CWRU.Edu (root@po.CWRU.Edu [129.22.4.2]) by odin.INS.CWRU.Edu with ESMTP (8.6.8.1+cwru/CWRU-2.1-ins)
id RAA04010; Wed, 21 Sep 1994 17:23:39 -0400 (from jwe@che.utexas.edu for <chet@odin.INS.CWRU.Edu>)
Received: from life.ai.mit.edu (life.ai.mit.edu [128.52.32.80]) by po.CWRU.Edu with SMTP (8.6.8.1+cwru/CWRU-2.2)
id RAA02121; Wed, 21 Sep 1994 17:23:28 -0400 (from jwe@che.utexas.edu for <chet@po.cwru.edu>)
Received: from schoch.che.utexas.edu by life.ai.mit.edu (4.1/AI-4.10) for chet@po.cwru.edu id AA09989; Wed, 21 Sep 94 17:23:17 EDT
Received: from localhost (jwe@localhost) by schoch.che.utexas.edu (8.6.8.1/8.6) with SMTP id QAA05737; Wed, 21 Sep 1994 16:22:01 -0500
Message-Id: <199409212122.QAA05737@schoch.che.utexas.edu>
To: march@tudor.com
Cc: bug-bash@prep.ai.mit.edu
Subject: Re: Completion feature possible?
In-Reply-To: Your message of 21 Sep 94 13:30:22 EDT
Date: Wed, 21 Sep 94 16:22:00 EDT
From: John Eaton <jwe@che.utexas.edu>
Gregory F. March <march@tudor.com> wrote:
: I was having a discussion about MH with one of my friends the other
: day and I got to thinking that the +folder/subfolder scheme for naming
: mail folders is a real pain because completion doesn't work on
: them. Someone then mentioned that zsh (I think) has the ability to
: specify how to complete (I guess where to look for the files) for
: different prefixes. Bash right now knows about '@', '~', and '$' (any
: others?). It would be really helpful if one could define something
: like:
:
: completion '+' "$HOME/Mail"
:
: in a config file someplace. Would this be easy? Is there a list of
: TODO item that someone might want to add this to?
It would be nice to have a general completion feature like this.
Until that happens, maybe you will find the following patch useful.
It makes MH folder name completion work with bash. The diffs are
relative to version 1.14.2.
I realize that changes to readline.c and and complete.c are not good
since they add some MH-specific stuff to the readline code and not to
bash, but when I first wrote this, I had no idea what else to do.
Chet, would you consider adding this if it were cleaned up a bit?
Made optional with cpp conditionals?
This feature has been very useful to me for the last several years
(since about 1.05 or 1.06, I think).
Thanks,
--
John W. Eaton | 4.3BSD is not perfect. -- Leffler, et al. (1989).
jwe@che.utexas.edu |
-------------------------------cut here-------------------------------
diff -rc bash-1.14.2/bashline.c bash-1.14.2.local/bashline.c
*** bash-1.14.2/bashline.c Wed Aug 3 09:32:45 1994
--- bash-1.14.2.local/bashline.c Wed Sep 21 15:39:04 1994
***************
*** 58,63 ****
--- 58,64 ----
static char *hostname_completion_function ();
static char *command_word_completion_function ();
static char *command_subst_completion_function ();
+ static char *mh_folder_completion_function ();
static void snarf_hosts_from_file (), add_host_name ();
static void sort_hostname_list ();
***************
*** 90,95 ****
--- 91,98 ----
bash_complete_username_internal (),
bash_complete_hostname (), bash_possible_hostname_completions (),
bash_complete_hostname_internal (),
+ bash_complete_mh_folder (), bash_possible_mh_folder_completions (),
+ bash_complete_mh_folder_internal (),
bash_complete_variable (), bash_possible_variable_completions (),
bash_complete_variable_internal (),
bash_complete_command (), bash_possible_command_completions (),
***************
*** 134,140 ****
rl_terminal_name = get_string_value ("TERM");
rl_instream = stdin;
rl_outstream = stderr;
! rl_special_prefixes = "$@";
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "Bash";
--- 137,143 ----
rl_terminal_name = get_string_value ("TERM");
rl_instream = stdin;
rl_outstream = stderr;
! rl_special_prefixes = "$@+";
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "Bash";
***************
*** 193,198 ****
--- 196,207 ----
rl_bind_key_in_map ('@', bash_possible_hostname_completions,
emacs_ctlx_keymap);
+ rl_add_defun ("complete-mh-folder", bash_complete_mh_folder, META('+'));
+ rl_add_defun ("possible-mh-folder-completions",
+ bash_possible_mh_folder_completions, -1);
+ rl_bind_key_in_map ('+', bash_possible_mh_folder_completions,
+ emacs_ctlx_keymap);
+
rl_add_defun ("complete-variable", bash_complete_variable, -1);
rl_bind_key_in_map ('$', bash_complete_variable, emacs_meta_keymap);
rl_add_defun ("possible-variable-completions",
***************
*** 656,661 ****
--- 665,677 ----
if (!matches && *text == '@')
matches = completion_matches (text, hostname_completion_function);
+ /* Another one. Why not? If the word starts in '+', then look for
+ matching mh folders for completion first. */
+ if (!matches && *text == '+')
+ {
+ matches = completion_matches (text, mh_folder_completion_function);
+ }
+
/* And last, (but not least) if this word is in a command position, then
complete over possible command names, including aliases, functions,
and command names. */
***************
*** 1077,1082 ****
--- 1093,1185 ----
return ((char *)NULL);
}
+ /* How about a completion function for mh folders? */
+ static char *
+ mh_folder_completion_function (text, state)
+ int state;
+ char *text;
+ {
+ extern int rl_filename_completion_desired;
+
+ extern char *get_mh_path ();
+
+ static char *mh_path = (char *)NULL;
+ static int len;
+ static int istate;
+ static char *val;
+ char *hint;
+
+ static char *mh_folder_hint = (char *)NULL;
+
+ /* If we don't have any state, make some. */
+ if (!state)
+ {
+ val = (char *)NULL;
+
+ if (mh_path)
+ free (mh_path);
+
+ mh_path = get_mh_path ();
+ if (!mh_path && !(hint[1] == '/' || hint[1] == '.'))
+ return ((char *)NULL);
+
+ len = strlen (mh_path);
+ }
+
+ if (mh_folder_hint)
+ free (mh_folder_hint);
+
+ hint = text;
+ if (*hint == '+')
+ hint++;
+
+ mh_folder_hint = (char *)xmalloc (2 + len + strlen (hint));
+ if (*hint == '/' || *hint == '.') {
+ len = -1;
+ sprintf (mh_folder_hint, "%s", hint);
+ } else
+ sprintf (mh_folder_hint, "%s/%s", mh_path, hint);
+
+ istate = (val != (char *)NULL);
+
+ again:
+ val = filename_completion_function (mh_folder_hint, istate);
+ istate = 1;
+
+ if (!val)
+ {
+ return ((char *)NULL);
+ }
+ else
+ {
+ char *ptr = val + len + 1, *temp;
+ struct stat sb;
+ int status = stat (val, &sb);
+
+ if (status != 0)
+ return ((char *)NULL);
+
+ if ((sb.st_mode & S_IFDIR) == S_IFDIR)
+ {
+ temp = (char *)xmalloc (2 + strlen (ptr));
+ *temp = '+';
+ strcpy (temp + 1, ptr);
+
+ free (val);
+ val = "";
+
+ rl_filename_completion_desired = 1;
+
+ return (temp);
+ }
+ else
+ {
+ free (val);
+ }
+ goto again;
+ }
+ }
+
/* History and alias expand the line. */
static char *
history_expand_line_internal (line)
***************
*** 1628,1633 ****
--- 1731,1773 ----
{
bash_specific_completion
(what_to_do, (Function *)username_completion_function);
+ }
+
+ static void
+ bash_complete_mh_folder (ignore, ignore2)
+ int ignore, ignore2;
+ {
+ bash_complete_mh_folder_internal (TAB);
+ }
+
+ static void
+ bash_possible_mh_folder_completions (ignore, ignore2)
+ int ignore, ignore2;
+ {
+ bash_complete_mh_folder_internal ('?');
+ }
+
+ static void
+ bash_complete_mh_folder_internal (what_to_do)
+ int what_to_do;
+ {
+ Function *orig_func;
+ CPPFunction *orig_attempt_func;
+ char *orig_rl_completer_word_break_characters;
+ extern char *rl_completer_word_break_characters;
+
+ orig_func = rl_completion_entry_function;
+ orig_attempt_func = rl_attempted_completion_function;
+ orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
+ rl_completion_entry_function = (Function *)mh_folder_completion_function;
+ rl_attempted_completion_function = (CPPFunction *)NULL;
+ rl_completer_word_break_characters = " \t\n\"\'";
+
+ rl_complete_internal (what_to_do);
+
+ rl_completion_entry_function = orig_func;
+ rl_attempted_completion_function = orig_attempt_func;
+ rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
}
static void
Only in bash-1.14.2.local: bashline.c.orig
diff -rc bash-1.14.2/lib/readline/complete.c bash-1.14.2.local/lib/readline/complete.c
*** bash-1.14.2/lib/readline/complete.c Tue Jul 26 12:59:57 1994
--- bash-1.14.2.local/lib/readline/complete.c Wed Sep 21 15:41:19 1994
***************
*** 733,751 ****
if (rl_filename_completion_desired)
{
struct stat finfo;
! char *filename = tilde_expand (matches[0]);
! if ((stat (filename, &finfo) == 0) && S_ISDIR (finfo.st_mode))
{
! if (rl_line_buffer[rl_point] != '/')
! rl_insert_text ("/");
}
! else
{
! if (rl_point == rl_end)
! rl_insert_text (temp_string);
}
- free (filename);
}
else
{
--- 733,768 ----
if (rl_filename_completion_desired)
{
struct stat finfo;
! char *tilde_expand ();
! char *plus_expand ();
! char *filename = (char *) NULL;
! switch (*matches[0])
{
! case '+':
! filename = plus_expand (matches[0]);
! break;
! case '~':
! default:
! filename = tilde_expand (matches[0]);
! break;
}
!
! if (filename)
{
! if ((stat (filename, &finfo) == 0)
! && S_ISDIR (finfo.st_mode))
! {
! if (rl_line_buffer[rl_point] != '/')
! rl_insert_text ("/");
! }
! else
! {
! if (rl_point == rl_end)
! rl_insert_text (temp_string);
! }
! free (filename);
}
}
else
{
Only in bash-1.14.2.local/lib/readline: diffs
diff -rc bash-1.14.2/lib/readline/readline.c bash-1.14.2.local/lib/readline/readline.c
*** bash-1.14.2/lib/readline/readline.c Fri Aug 12 12:47:46 1994
--- bash-1.14.2.local/lib/readline/readline.c Wed Sep 21 15:36:07 1994
***************
*** 23,28 ****
--- 23,29 ----
#define READLINE_LIBRARY
#include <stdio.h>
+ #include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#if !defined (NO_SYS_FILE)
***************
*** 3518,3523 ****
--- 3519,3616 ----
}
#endif /* TEST */
+
+ #define cr_whitespace(c) ((c) == '\r' || (c) == '\n' || whitespace(c))
+
+ char *
+ get_mh_path ()
+ {
+ static FILE *fp = (FILE *)NULL;
+ char buf[512]; /* XXX */
+ char profile[512]; /* XXX */
+ char *bp;
+ char *temp_home;
+ char *temp_path;
+
+ temp_home = (char *)getenv ("HOME");
+ if (!temp_home)
+ return ((char *)NULL);
+
+ strcpy (profile, temp_home);
+ strcat (profile, "/.mh_profile");
+
+ if (fp)
+ fclose (fp);
+
+ fp = fopen (profile, "r");
+ if (fp == (FILE *)NULL)
+ return ((char *)NULL);
+
+ while (fgets (buf, 512, fp) != (char *)NULL) /* XXX */
+ {
+ if ((bp = strstr (buf, "Path:")) != (char *)NULL)
+ {
+ bp += 5;
+ while (whitespace (*bp))
+ bp++;
+
+ if (*bp == '\0')
+ return ((char *)NULL);
+
+ temp_path = (char *)xmalloc (3 + strlen (bp) + strlen (temp_home));
+
+ strcpy (temp_path, temp_home);
+ strcat (temp_path, "/");
+ strcat (temp_path, bp);
+
+ bp = temp_path;
+
+ while (!(cr_whitespace (*bp)))
+ bp++;
+
+ *bp = '\0';
+
+ return temp_path;
+ }
+ }
+
+ return ((char *)NULL);
+ }
+
+ /* Expand FILENAME if it begins with a plus. This always returns
+ a new string. */
+ char *
+ plus_expand (filename)
+ char *filename;
+ {
+ static char *dirname = (char *)NULL;
+
+ if (filename && *filename == '+')
+ {
+ char *mh_path = get_mh_path ();
+
+ if (filename[1] == '/' || filename[1] == '.')
+ {
+ dirname = (char *)xmalloc (1 + strlen (filename));
+
+ strcpy(dirname, filename+1);
+
+ return dirname;
+ }
+
+ if (mh_path)
+ {
+ dirname = (char *)xmalloc (1 + strlen (filename) + strlen (mh_path));
+
+ strcpy (dirname, mh_path);
+ strcat (dirname, "/");
+ strcat (dirname, filename+1);
+
+ return dirname;
+ }
+ }
+ return (char *)NULL;
+ }
/*
+26 -20
View File
@@ -38,10 +38,24 @@ don't want to keep, you may remove or edit it.
To find out more about the options and arguments that the 'configure'
script understands, type
bash-2.04$ ./configure --help
bash-4.2$ ./configure --help
at the Bash prompt in your Bash source directory.
If you want to build Bash in a directory separate from the source
directory - to build for multiple architectures, for example - just use
the full path to the configure script. The following commands will
build bash in a directory under '/usr/local/build' from the source code
in '/usr/local/src/bash-4.4':
mkdir /usr/local/build/bash-4.4
cd /usr/local/build/bash-4.4
bash /usr/local/src/bash-4.4/configure
make
See *note Compiling For Multiple Architectures:: for more information
about building in a directory separate from the source.
If you need to do unusual things to compile Bash, please try to figure
out how 'configure' could check whether or not to do them, and mail
diffs or instructions to <bash-maintainers@gnu.org> so they can be
@@ -57,8 +71,6 @@ code directory by typing 'make clean'. To also remove the files that
'configure' created (so you can compile Bash for a different kind of
computer), type 'make distclean'.
Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
Compilers and Options
=====================
@@ -76,8 +88,6 @@ On systems that have the 'env' program, you can do it like this:
The configuration process uses GCC to build Bash if it is available.
Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
Compiling For Multiple Architectures
====================================
@@ -86,10 +96,10 @@ time, by placing the object files for each architecture in their own
directory. To do this, you must use a version of 'make' that supports
the 'VPATH' variable, such as GNU 'make'. 'cd' to the directory where
you want the object files and executables to go and run the 'configure'
script from the source directory. You may need to supply the
'--srcdir=PATH' argument to tell 'configure' where the source files are.
'configure' automatically checks for the source code in the directory
that 'configure' is in and in '..'.
script from the source directory (*note Basic Installation::). You may
need to supply the '--srcdir=PATH' argument to tell 'configure' where
the source files are. 'configure' automatically checks for the source
code in the directory that 'configure' is in and in '..'.
If you have to use a 'make' that does not supports the 'VPATH' variable,
you can compile Bash for one architecture at a time in the source code
@@ -108,8 +118,6 @@ The 'mkclone' script requires Bash, so you must have already built Bash
for at least one architecture before you can create build directories
for other architectures.
Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
Installation Names
==================
@@ -125,8 +133,6 @@ option '--exec-prefix=PATH', 'make install' will use PATH as the prefix
for installing programs and libraries. Documentation and other data
files will still use the regular prefix.
Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
Specifying the System Type
==========================
@@ -140,8 +146,6 @@ canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g.,
See the file 'support/config.sub' for the possible values of each field.
Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
Sharing Defaults
================
@@ -154,8 +158,6 @@ looks for 'PREFIX/share/config.site' if it exists, then
A warning: the Bash 'configure' looks for a site script, but not all
'configure' scripts do.
Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
Operation Controls
==================
@@ -185,8 +187,6 @@ Operation Controls
'configure' also accepts some other, not widely used, boilerplate
options. 'configure --help' prints the complete list.
Prev: Operation Controls, Up: Installing Bash
Optional Features
=================
@@ -321,6 +321,12 @@ unless the operating system does not provide the necessary support.
'--enable-debugger'
Include support for the bash debugger (distributed separately).
'--enable-dev-fd-stat-broken'
If calling 'stat' on /dev/fd/N returns different results than
calling 'fstat' on file descriptor N, supply this option to enable
a workaround. This has implications for conditional commands that
test file attributes.
'--enable-direxpand-default'
Cause the 'direxpand' shell option (*note The Shopt Builtin::) to
be enabled by default when the shell starts. It is normally
@@ -391,7 +397,7 @@ unless the operating system does not provide the necessary support.
'--enable-prompt-string-decoding'
Turn on the interpretation of a number of backslash-escaped
characters in the '$PS1', '$PS2', '$PS3', and '$PS4' prompt
characters in the '$PS0', '$PS1', '$PS2', and '$PS4' prompt
strings. See *note Controlling the Prompt::, for a complete list
of prompt string escape sequences.
+62 -1
View File
@@ -11,6 +11,7 @@ cross-build d
doc d
examples d
#examples/obashdb d
examples/bash-completion d
examples/complete d
examples/functions d
examples/scripts d
@@ -209,6 +210,7 @@ builtins/bashgetopt.h f
cross-build/cygwin32.cache f
cross-build/x86-beos.cache f
cross-build/opennt.cache f
cross-build/qnx.cache f
include/ansi_stdlib.h f
include/chartypes.h f
include/filecntl.h f
@@ -239,6 +241,7 @@ lib/glob/glob.c f
lib/glob/glob.h f
lib/glob/glob_loop.c f
lib/glob/gmisc.c f
lib/glob/gm_loop.c f
lib/glob/xmbsrtowcs.c f
lib/glob/collsyms.h f
lib/glob/doc/Makefile f
@@ -534,6 +537,8 @@ po/nb.gmo f
po/nl.po f
po/pl.gmo f
po/pl.po f
po/pt.gmo f
po/pt.po f
po/pt_BR.gmo f
po/pt_BR.po f
po/ro.gmo f
@@ -631,6 +636,7 @@ support/mkversion.sh f 755
support/mksignames.c f
support/signames.c f
support/bashbug.sh f
support/bashbug.sh.in f
support/man2html.c f
support/recho.c f
support/zecho.c f
@@ -649,6 +655,8 @@ examples/INDEX.html f
#examples/obashdb/README f
#examples/obashdb/bashdb f
#examples/obashdb/bashdb.el f
examples/bash-completion/README f
examples/bash-completion/bash-completion-2.5.tar.xz f
examples/complete/bash_completion f
examples/complete/cdfunc f
examples/complete/complete-examples f
@@ -672,6 +680,7 @@ examples/loadables/strftime.c f
examples/loadables/truefalse.c f
#examples/loadables/getconf.h f
#examples/loadables/getconf.c f
examples/loadables/fdflags.c f
examples/loadables/finfo.c f
examples/loadables/cat.c f
#examples/loadables/cut.c f
@@ -681,6 +690,7 @@ examples/loadables/dirname.c f
examples/loadables/tty.c f
examples/loadables/pathchk.c f
examples/loadables/tee.c f
examples/loadables/rm.c f
examples/loadables/rmdir.c f
examples/loadables/head.c f
examples/loadables/printenv.c f
@@ -693,6 +703,7 @@ examples/loadables/mkdir.c f
examples/loadables/ln.c f
examples/loadables/mypid.c f
examples/loadables/unlink.c f
examples/loadables/stat.c f
examples/loadables/perl/Makefile.in f
examples/loadables/perl/README f
examples/loadables/perl/bperl.c f
@@ -701,9 +712,12 @@ examples/loadables/perl/iperl.c f
#examples/loadables/xtitle.c f
examples/functions/array-stuff f
examples/functions/array-to-string f
examples/functions/arrayops.bash f
examples/functions/autoload f
examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
examples/functions/autoload.v4 f
examples/functions/autoload.v4.t f
examples/functions/basename f
#examples/functions/basename2 f
#examples/functions/coproc.bash f
@@ -808,6 +822,8 @@ tests/test-glue-functions f
tests/alias.tests f
tests/alias1.sub f
tests/alias2.sub f
tests/alias3.sub f
tests/alias4.sub f
tests/alias.right f
tests/appendop.tests f
tests/appendop1.sub f
@@ -824,6 +840,7 @@ tests/arith4.sub f
tests/arith5.sub f
tests/arith6.sub f
tests/arith7.sub f
tests/arith8.sub f
tests/array.tests f
tests/array.right f
tests/array1.sub f
@@ -847,6 +864,10 @@ tests/array18.sub f
tests/array19.sub f
tests/array20.sub f
tests/array21.sub f
tests/array22.sub f
tests/array23.sub f
tests/array24.sub f
tests/array25.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
@@ -859,6 +880,7 @@ tests/assoc5.sub f
tests/assoc6.sub f
tests/assoc7.sub f
tests/assoc8.sub f
tests/assoc9.sub f
tests/attr.tests f
tests/attr.right f
tests/attr1.sub f
@@ -883,6 +905,8 @@ tests/source7.sub f
tests/case.tests f
tests/case.right f
tests/case1.sub f
tests/case2.sub f
tests/case3.sub f
tests/casemod.tests f
tests/casemod.right f
tests/comsub.tests f
@@ -890,6 +914,7 @@ tests/comsub.right f
tests/comsub1.sub f
tests/comsub2.sub f
tests/comsub3.sub f
tests/comsub4.sub f
tests/comsub-eof.tests f
tests/comsub-eof0.sub f
tests/comsub-eof1.sub f
@@ -910,6 +935,7 @@ tests/cond-regexp2.sub f
tests/cond-regexp3.sub f
tests/coproc.tests f
tests/coproc.right f
tests/coproc1.sub f
tests/cprint.tests f
tests/cprint.right f
tests/dbg-support.right f
@@ -933,6 +959,7 @@ tests/dollar-at3.sub f
tests/dollar-at4.sub f
tests/dollar-at5.sub f
tests/dollar-at6.sub f
tests/dollar-at7.sub f
tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar-star3.sub f
@@ -940,11 +967,15 @@ tests/dollar-star4.sub f
tests/dollar-star5.sub f
tests/dollar-star6.sub f
tests/dollar-star7.sub f
tests/dollar-star8.sub f
tests/dollar-star9.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
tests/dstack2.tests f
tests/dstack2.right f
tests/dynvar.tests f
tests/dynvar.right f
tests/errors.tests f
tests/errors.right f
tests/errors1.sub f
@@ -953,6 +984,7 @@ tests/errors3.sub f
tests/errors4.sub f
tests/errors5.sub f
tests/errors6.sub f
tests/errors7.sub f
tests/execscript f
tests/exec.right f
tests/exec1.sub f 755
@@ -979,6 +1011,9 @@ tests/exp6.sub f
tests/exp7.sub f
tests/exp8.sub f
tests/exp9.sub f
tests/exp10.sub f
tests/exp11.sub f
tests/exp12.sub f
tests/exportfunc.tests f
tests/exportfunc.right f
tests/exportfunc1.sub f
@@ -995,6 +1030,7 @@ tests/extglob3.sub f
tests/extglob3.tests f
tests/extglob3.right f
tests/extglob4.sub f
tests/extglob5.sub f
tests/func.tests f
tests/func.right f
tests/func1.sub f
@@ -1015,6 +1051,8 @@ tests/getopts9.sub f
tests/getopts10.sub f
tests/glob.tests f
tests/glob1.sub f
tests/glob2.sub f
tests/glob3.sub f
tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
@@ -1025,6 +1063,7 @@ tests/heredoc.right f
tests/heredoc1.sub f
tests/heredoc2.sub f
tests/heredoc3.sub f
tests/heredoc4.sub f
tests/herestr.tests f
tests/herestr.right f
tests/herestr1.sub f
@@ -1039,8 +1078,10 @@ tests/history.right f
tests/history.list f 444
tests/history1.sub f
tests/history2.sub f
tests/history3.sub f
tests/ifs.tests f
tests/ifs.right f
tests/ifs1.sub f
tests/ifs-posix.tests f
tests/ifs-posix.right f
tests/input-line.sh f
@@ -1062,6 +1103,7 @@ tests/jobs2.sub f
tests/jobs3.sub f
tests/jobs4.sub f
tests/jobs5.sub f
tests/jobs6.sub f
tests/jobs.right f
tests/lastpipe.right f
tests/lastpipe.tests f
@@ -1093,6 +1135,7 @@ tests/nameref15.sub f
tests/nameref16.sub f
tests/nameref17.sub f
tests/nameref18.sub f
tests/nameref19.sub f
tests/nameref.right f
tests/new-exp.tests f
tests/new-exp1.sub f
@@ -1105,6 +1148,7 @@ tests/new-exp7.sub f
tests/new-exp8.sub f
tests/new-exp9.sub f
tests/new-exp10.sub f
tests/new-exp11.sub f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
@@ -1126,10 +1170,15 @@ tests/parser.right f
tests/parser1.sub f
tests/posix2.tests f
tests/posix2.right f
tests/posix2syntax.sub f
tests/posixexp.tests f
tests/posixexp.right f
tests/posixexp1.sub f
tests/posixexp2.sub f
tests/posixexp3.sub f
tests/posixexp4.sub f
tests/posixexp5.sub f
tests/posixexp6.sub f
tests/posixexp2.tests f
tests/posixexp2.right f
tests/posixpat.tests f
@@ -1144,6 +1193,9 @@ tests/printf1.sub f
tests/printf2.sub f
tests/printf3.sub f
tests/printf4.sub f
tests/procsub.tests f
tests/procsub.right f
tests/procsub1.sub f
tests/quote.tests f
tests/quote.right f
tests/quote1.sub f
@@ -1171,12 +1223,13 @@ tests/redir8.sub f
tests/redir9.sub f
tests/redir10.sub f
tests/redir11.sub f
tests/redir12.sub f
tests/rhs-exp.tests f
tests/rhs-exp.right f
tests/rhs-exp1.sub f
tests/rsh.tests f
tests/rsh.right f
tests/rsh1.sub f
tests/rsh2.sub f
tests/run-all f
tests/run-minimal f
tests/run-alias f
@@ -1201,6 +1254,7 @@ tests/run-dbg-support f
tests/run-dbg-support2 f
tests/run-dirstack f
tests/run-dollars f
tests/run-dynvar f
tests/run-errors f
tests/run-execscript f
tests/run-exp-tests f
@@ -1242,6 +1296,7 @@ tests/run-posixpat f
tests/run-posixpipe f
tests/run-precedence f
tests/run-printf f
tests/run-procsub f
tests/run-quote f
tests/run-read f
tests/run-redir f
@@ -1272,6 +1327,7 @@ tests/shopt.right f
tests/strip.tests f
tests/strip.right f
tests/test.tests f
tests/test1.sub f
tests/test.right f
tests/tilde.tests f
tests/tilde.right f
@@ -1285,6 +1341,7 @@ tests/trap2a.sub f 755
tests/trap3.sub f
tests/trap4.sub f
tests/trap5.sub f
tests/trap6.sub f
tests/type.tests f
tests/type.right f
tests/type1.sub f
@@ -1304,6 +1361,10 @@ tests/varenv5.sub f
tests/varenv6.sub f
tests/varenv7.sub f
tests/varenv8.sub f
tests/varenv9.sub f
tests/varenv10.sub f
tests/varenv11.sub f
tests/varenv12.sub f
tests/version f
tests/version.mini f
tests/vredir.tests f
-24
View File
@@ -1,24 +0,0 @@
#
# Master Manifest file for documentation-only distribution
#
doc d
MANIFEST.doc f
doc/article.ps f
doc/rose94.ps f
doc/bash.ps f
doc/bashbug.ps f
doc/builtins.ps f
doc/rbash.ps f
doc/bashref.ps f
doc/bashref.dvi f
doc/bash.0 f
doc/bashbug.0 f
doc/builtins.0 f
doc/rbash.0 f
doc/article.txt f
doc/bash.html f
doc/bashref.html f
doc/article.pdf f
doc/bash.pdf f
doc/bashref.pdf f
doc/rose94.pdf f
+78 -49
View File
@@ -1,6 +1,6 @@
# Makefile for bash-4.4, version 4.18
# Makefile for bash-5.0, version 4.25
#
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
# Copyright (C) 1996-2018 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
@@ -77,6 +77,7 @@ AR = @AR@
ARFLAGS = @ARFLAGS@
RANLIB = @RANLIB@
SIZE = @SIZE@
STRIP = strip
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -144,16 +145,23 @@ LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
BASE_CCFLAGS = $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
$(DEFS) $(LOCAL_CFLAGS) $(INCLUDES)
CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
CCFLAGS = $(ADDON_CFLAGS) $(BASE_CCFLAGS) ${PROFILE_FLAGS} $(CPPFLAGS) $(CFLAGS)
CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
LDFLAGS = @LDFLAGS@ $(STATIC_LD) $(LOCAL_LDFLAGS) $(PROFILE_FLAGS) $(CFLAGS)
BASE_LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
LDFLAGS = ${ADDON_LDFLAGS} ${BASE_LDFLAGS} ${PROFILE_FLAGS} ${STATIC_LD}
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD)
ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer
ASAN_XLDFLAGS = -fsanitize=address
GCOV_XCFLAGS = -fprofile-arcs -ftest-coverage
GCOV_XLDFLAGS = -fprofile-arcs -ftest-coverage
INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC)
# Maybe add: -Wextra
@@ -583,22 +591,38 @@ $(Program): .build $(OBJECTS) $(BUILTINS_DEP) $(LIBDEP)
@echo " ***********************************************************"
@echo
bashbug: $(SUPPORT_SRC)bashbug.sh config.h Makefile $(VERSPROG)
@sed -e "s%!MACHINE!%$(Machine)%" -e "s%!OS!%$(OS)%" \
-e "s%!CFLAGS!%$(CCFLAGS)%" -e "s%!CC!%$(CC)%" \
-e "s%!RELEASE!%$(Version)%" -e "s%!PATCHLEVEL!%$(PatchLevel)%" \
-e "s%!MACHTYPE!%$(MACHTYPE)%" -e "s%!RELSTATUS!%$(RELSTATUS)%" \
$(SUPPORT_SRC)bashbug.sh > $@
bashbug: $(SDIR)/bashbug.sh config.h Makefile $(VERSPROG)
@sed -e "s%!PATCHLEVEL!%$(PatchLevel)%" \
$(SDIR)/bashbug.sh > $@
@chmod a+rx bashbug
strip: $(Program) .made
strip $(Program)
$(STRIP) $(Program)
ls -l $(Program)
-$(SIZE) $(Program)
lint:
${MAKE} ${MFLAGS} CFLAGS='${GCC_LINT_FLAGS}' .made
asan:
${MAKE} ${MFLAGS} ADDON_CFLAGS='${ASAN_XCFLAGS}' ADDON_LDFLAGS='${ASAN_XLDFLAGS}' .made
# cheating
gcov:
${MAKE} ${MFLAGS} CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made
# have to make this separate because making tests depend on $(PROGRAM)
asan-tests: asan $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@cp $(TESTS_SUPPORT) tests
@( cd $(srcdir)/tests && \
PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
profiling-tests: ${PROGRAM}
@test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be built with profiling enabled" >&2; exit 1; }
@${MAKE} ${MFLAGS} tests TESTSCRIPT=run-gprof
version.h: $(SOURCES) config.h Makefile patchlevel.h
$(SHELL) $(SUPPORT_SRC)mkversion.sh -b -S ${topdir} -s $(RELSTATUS) -d $(Version) -o newversion.h \
&& mv newversion.h version.h
@@ -902,7 +926,7 @@ maintainer-clean: basic-clean
$(RM) $(CREATED_SUPPORT) Makefile pathnames.h
maybe-clean:
-if test "X$(topdir)" != "X$(BUILD_DIR)" ; then \
-if test X"`cd $(topdir) && pwd -P`" != X"`cd $(BUILD_DIR) && pwd -P`" ; then \
$(RM) parser-built y.tab.c y.tab.h ; \
fi
@@ -981,19 +1005,19 @@ error.o: command.h general.h xmalloc.h externs.h input.h bashhist.h
error.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
error.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
error.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
error.o: make_cmd.h subst.h sig.h pathnames.h externs.h
error.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
error.o: input.h execute_cmd.h
eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
eval.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
eval.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
eval.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h
eval.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
eval.o: input.h execute_cmd.h
execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
execute_cmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
execute_cmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
execute_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
execute_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
execute_cmd.o: ${BASHINCDIR}/memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.h
execute_cmd.o: execute_cmd.h findcmd.h redir.h trap.h test.h pathexp.h
execute_cmd.o: $(DEFSRC)/common.h ${DEFDIR}/builtext.h ${GLOB_LIBSRC}/strmatch.h
@@ -1003,31 +1027,31 @@ expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
expr.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h execute_cmd.h
expr.o: ${BASHINCDIR}/chartypes.h
findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h xmalloc.h variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h
findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h execute_cmd.h
findcmd.o: ${BASHINCDIR}/chartypes.h
flags.o: config.h flags.h
flags.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
flags.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h execute_cmd.h
flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h bashhist.h
general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
general.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
general.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
general.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
general.o: make_cmd.h subst.h sig.h pathnames.h externs.h
general.o: make_cmd.h subst.h sig.h pathnames.h externs.h flags.h parser.h
general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
general.o: ${BASHINCDIR}/chartypes.h
hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashcmd.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashcmd.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashcmd.h
hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h pathnames.h hashlib.h
hashcmd.o: quit.h sig.h
hashcmd.o: quit.h sig.h flags.h
hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
hashlib.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashlib.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
@@ -1035,7 +1059,7 @@ hashlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
hashlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
input.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h input.h error.h externs.h
input.o: quit.h
input.o: quit.h shell.h pathnames.h
list.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
list.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
@@ -1058,11 +1082,12 @@ make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h flags.h m
make_cmd.o: variables.h arrayfunc.h conftypes.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h sig.h siglist.h syntax.h dispose_cmd.h parser.h
make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h ${BASHINCDIR}/ocache.h
make_cmd.o: shell.h execute_cmd.h pathnames.h
y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
y.tab.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
y.tab.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h test.h execute_cmd.o
y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
@@ -1089,7 +1114,7 @@ shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}
shell.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
shell.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h bashline.h
shell.o: ${GLOB_LIBSRC}/strmatch.h ${BASHINCDIR}/posixtime.h
@@ -1097,7 +1122,7 @@ sig.o: config.h bashtypes.h
sig.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
sig.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
sig.o: ${DEFDIR}/builtext.h
siglist.o: config.h bashtypes.h siglist.h trap.h
@@ -1127,8 +1152,8 @@ test.o: ${DEFSRC}/common.h
trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
trap.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
trap.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h
trap.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
trap.o: make_cmd.h subst.h sig.h pathnames.h externs.h execute_cmd.h
trap.o: signames.h $(DEFSRC)/common.h
trap.o: ${DEFDIR}/builtext.h jobs.h
unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
@@ -1137,7 +1162,7 @@ variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINC
variables.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
variables.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
variables.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h
variables.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
variables.o: flags.h execute_cmd.h mailcheck.h input.h $(DEFSRC)/common.h
variables.o: findcmd.h bashhist.h hashcmd.h pathexp.h
variables.o: pcomplete.h ${BASHINCDIR}/chartypes.h
@@ -1152,14 +1177,14 @@ jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDI
jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
jobs.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
jobs.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h parser.h
jobs.o: execute_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
jobs.o: ${BASHINCDIR}/posixtime.h
nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h xmalloc.h jobs.h quit.h siglist.h externs.h
nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h
nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h parser.h
nojobs.o: $(DEFDIR)/builtext.h
# shell features that may be compiled in
@@ -1175,6 +1200,7 @@ arrayfunc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h comman
arrayfunc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
arrayfunc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
arrayfunc.o: make_cmd.h subst.h sig.h pathnames.h externs.h pathexp.h
arrayfunc.o: execute_cmd.h
arrayfunc.o: $(DEFSRC)/common.h
arrayfunc.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
@@ -1217,14 +1243,14 @@ bashhist.o: ${BASHINCDIR}/filecntl.h
bashhist.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashhist.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
bashhist.o: $(GLOB_LIBSRC)/strmatch.h
bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
bashline.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashline.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h array.h hashlib.h
bashline.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashline.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
bashline.o: builtins.h bashhist.h bashline.h execute_cmd.h findcmd.h pathexp.h
bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h
bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h
@@ -1279,6 +1305,7 @@ mailcheck.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
make_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
nojobs.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
y.tab.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
pathexp.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
pcomplete.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
pcomplib.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
print_cmd.o: bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
@@ -1310,12 +1337,12 @@ builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h arrayfunc.h conftypes.h
builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h
builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h xmalloc.h error.h pathnames.h
builtins/common.o: ${DEFDIR}/builtext.h
builtins/common.o: ${DEFDIR}/builtext.h parser.h
builtins/common.o: ${BASHINCDIR}/chartypes.h
builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/evalfile.o: shell.h syntax.h config.h bashjmp.h command.h general.h xmalloc.h error.h
builtins/evalfile.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h parser.h
builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
@@ -1345,12 +1372,12 @@ builtins/bind.o: $(DEFSRC)/bashgetopt.h pathnames.h
builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/break.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/break.o: pathnames.h
builtins/break.o: pathnames.h execute_cmd.h
builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/builtin.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/builtin.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/builtin.o: pathnames.h
builtins/builtin.o: pathnames.h execute_cmd.h
builtins/caller.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/caller.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/caller.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
@@ -1391,33 +1418,34 @@ builtins/exit.o: bashtypes.h
builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/exit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/exit.o: pathnames.h
builtins/exit.o: pathnames.h execute_cmd.h
builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h
builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/fc.o: flags.h unwind_prot.h variables.h arrayfunc.h conftypes.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h
builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h
builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h pathnames.h parser.h
builtins/fc.o: ${BASHINCDIR}/chartypes.h
builtins/fg_bg.o: bashtypes.h $(DEFSRC)/bashgetopt.h
builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/fg_bg.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/fg_bg.o: pathnames.h
builtins/fg_bg.o: pathnames.h execute_cmd.h
builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/getopts.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/getopts.o: pathnames.h
builtins/hash.o: bashtypes.h
builtins/getopts.o: pathnames.h execute_cmd.h
builtins/hash.o: bashtypes.h execute_cmd.h
builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/hash.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/hash.o: pathnames.h
builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h quit.h
builtins/help.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h
builtins/help.o: conftypes.h quit.h execute_cmd.h
builtins/help.o: $(GLOB_LIBSRC)/glob.h pathnames.h
builtins/history.o: bashtypes.h pathnames.h
builtins/history.o: bashtypes.h pathnames.h parser.h
builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
@@ -1457,16 +1485,16 @@ builtins/read.o: pathnames.h
builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/return.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/return.o: pathnames.h
builtins/return.o: pathnames.h execute_cmd.h
builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/set.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h flags.h
builtins/set.o: pathnames.h
builtins/set.o: pathnames.h parser.h
builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
builtins/setattr.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/setattr.o: pathnames.h flags.h
builtins/setattr.o: pathnames.h flags.h execute_cmd.h
builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/shift.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@@ -1481,7 +1509,7 @@ builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/source.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/source.o: findcmd.h $(DEFSRC)/bashgetopt.h flags.h trap.h
builtins/source.o: pathnames.h
builtins/source.o: pathnames.h execute_cmd.h
builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/suspend.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@@ -1489,7 +1517,7 @@ builtins/suspend.o: pathnames.h
builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/test.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/test.o: test.h pathnames.h
builtins/test.o: execute_cmd.h test.h pathnames.h
builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/times.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@@ -1503,7 +1531,7 @@ builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h x
builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
builtins/type.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/type.o: pathnames.h
builtins/type.o: pathnames.h execute_cmd.h parser.h
builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/ulimit.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
@@ -1515,6 +1543,7 @@ builtins/umask.o: ${BASHINCDIR}/chartypes.h pathnames.h
builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h
builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/wait.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h
builtins/wait.o: execute_cmd.h
builtins/wait.o: ${BASHINCDIR}/chartypes.h pathnames.h
builtins/complete.o: config.h shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
+115
View File
@@ -1,3 +1,118 @@
This is a terse description of the new features added to bash-5.0 since
the release of bash-4.4. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
1. New Features in Bash
a. The `wait' builtin can now wait for the last process substitution created.
b. There is an EPOCHSECONDS variable, which expands to the time in seconds
since the Unix epoch.
c. There is an EPOCHREALTIME variable, which expands to the time in seconds
since the Unix epoch with microsecond granularity.
d. New loadable builtins: rm, stat, fdflags.
e. BASH_ARGV0: a new variable that expands to $0 and sets $0 on assignment.
f. When supplied a numeric argument, the shell-expand-line bindable readline
command does not perform quote removal and suppresses command and process
substitution.
g. `history -d' understands negative arguments: negative arguments offset from
the end of the history list.
h. The `name' argument to the `coproc' reserved word now undergoes word
expansion, so unique coprocs can be created in loops.
i. A nameref name resolution loop in a function now resolves to a variable by
that name in the global scope.
j. The `wait' builtin now has a `-f' option, which signfies to wait until the
specified job or process terminates, instead of waiting until it changes
state.
k. There is a define in config-top.h that allows the shell to use a static
value for $PATH, overriding whatever is in the environment at startup, for
use by the restricted shell.
l. Process substitution does not inherit the `v' option, like command
substitution.
m. If a non-interactive shell with job control enabled detects that a foreground
job died due to SIGINT, it acts as if it received the SIGINT.
n. The SIGCHLD trap is run once for each exiting child process even if job
control is not enabled when the shell is in Posix mode.
o. A new shopt option: localvar_inherit; if set, a local variable inherits the
value of a variable with the same name at the nearest preceding scope.
p. `bind -r' now checks whether a key sequence is bound before binding it to
NULL, to avoid creating keymaps for a multi-key sequence.
q. A numeric argument to the line editing `operate-and-get-next' command
specifies which history entry to use.
r. The positional parameters are now assigned before running the shell startup
files, so startup files can use $@.
s. There is a compile-time option that forces the shell to disable the check
for an inherited OLDPWD being a directory.
t. The `history' builtin can now delete ranges of history entries using
`-d start-end'.
u. The `vi-edit-and-execute-command' bindable readline command now puts readline
back in vi insertion mode after executing commands from the edited file.
v. The command completion code now matches aliases and shell function names
case-insensitively if the readline completion-ignore-case variable is set.
w. There is a new `assoc_expand_once' shell option that attempts to expand
associative array subscripts only once.
x. The shell only sets up BASH_ARGV and BASH_ARGC at startup if extended
debugging mode is active. The old behavior of unconditionally setting them
is available as part of the shell compatibility options.
y. The `umask' builtin now allows modes and masks greater than octal 777.
z. The `times' builtin now honors the current locale when printing a decimal
point.
aa. There is a new (disabled by default, undocumented) shell option to enable
and disable sending history to syslog at runtime.
2. New Features in Readline
a. Non-incremental vi-mode search (`N', `n') can search for a shell pattern, as
Posix specifies (uses fnmatch(3) if available).
b. There are new `next-screen-line' and `previous-screen-line' bindable
commands, which move the cursor to the same column in the next, or previous,
physical line, respectively.
c. There are default key bindings for control-arrow-key key combinations.
d. A negative argument (-N) to `quoted-insert' means to insert the next N
characters using quoted-insert.
e. New public function: rl_check_signals(), which allows applications to
respond to signals that readline catches while waiting for input using
a custom read function.
f. There is new support for conditionally testing the readline version in an
inputrc file, with a full set of arithmetic comparison operators available.
g. There is a simple variable comparison facility available for use within an
inputrc file. Allowable operators are equality and inequality; string
variables may be compared to a value; boolean variables must be compared to
either `on' or `off'; variable names are separated from the operator by
whitespace.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-4.4 since
the release of bash-4.3. As always, the manual page (doc/bash.1) is
the place to look for complete descriptions.
+47 -40
View File
@@ -58,158 +58,165 @@ The following list is what's changed when 'POSIX mode' is in effect:
14. POSIX special builtins are found before shell functions during
command lookup.
15. Literal tildes that appear as the first character in elements of
15. When printing shell function definitions (e.g., by 'type'), Bash
does not print the 'function' keyword.
16. Literal tildes that appear as the first character in elements of
the 'PATH' variable are not expanded as described above under *note
Tilde Expansion::.
16. The 'time' reserved word may be used by itself as a command. When
17. The 'time' reserved word may be used by itself as a command. When
used in this way, it displays timing statistics for the shell and
its completed children. The 'TIMEFORMAT' variable controls the
format of the timing information.
17. When parsing and expanding a ${...} expansion that appears within
18. When parsing and expanding a ${...} expansion that appears within
double quotes, single quotes are no longer special and cannot be
used to quote a closing brace or other special character, unless
the operator is one of those defined to perform pattern removal.
In this case, they do not have to appear as matched pairs.
18. The parser does not recognize 'time' as a reserved word if the
19. The parser does not recognize 'time' as a reserved word if the
next token begins with a '-'.
19. The '!' character does not introduce history expansion within a
20. The '!' character does not introduce history expansion within a
double-quoted string, even if the 'histexpand' option is enabled.
20. If a POSIX special builtin returns an error status, a
21. If a POSIX special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
21. A non-interactive shell exits with an error status if a variable
22. A non-interactive shell exits with an error status if a variable
assignment error occurs when no command name follows the assignment
statements. A variable assignment error occurs, for example, when
trying to assign a value to a readonly variable.
22. A non-interactive shell exits with an error status if a variable
23. A non-interactive shell exits with an error status if a variable
assignment error occurs in an assignment statement preceding a
special builtin, but not with any other simple command.
23. A non-interactive shell exits with an error status if the
24. A non-interactive shell exits with an error status if the
iteration variable in a 'for' statement or the selection variable
in a 'select' statement is a readonly variable.
24. Non-interactive shells exit if FILENAME in '.' FILENAME is not
25. Non-interactive shells exit if FILENAME in '.' FILENAME is not
found.
25. Non-interactive shells exit if a syntax error in an arithmetic
26. Non-interactive shells exit if a syntax error in an arithmetic
expansion results in an invalid expression.
26. Non-interactive shells exit on word expansion errors.
27. Non-interactive shells exit if a parameter expansion error occurs.
27. Non-interactive shells exit if there is a syntax error in a script
28. Non-interactive shells exit if there is a syntax error in a script
read with the '.' or 'source' builtins, or in a string processed by
the 'eval' builtin.
28. Process substitution is not available.
29. Process substitution is not available.
29. While variable indirection is available, it may not be applied to
30. While variable indirection is available, it may not be applied to
the '#' and '?' special parameters.
30. Assignment statements preceding POSIX special builtins persist in
31. When expanding the '*' special parameter in a pattern context
where the expansion is double-quoted does not treat the '$*' as if
it were double-quoted.
32. Assignment statements preceding POSIX special builtins persist in
the shell environment after the builtin completes.
31. Assignment statements preceding shell function calls persist in
33. Assignment statements preceding shell function calls persist in
the shell environment after the function returns, as if a POSIX
special builtin command had been executed.
32. The 'command' builtin does not prevent builtins that take
34. The 'command' builtin does not prevent builtins that take
assignment statements as arguments from expanding them as
assignment statements; when not in POSIX mode, assignment builtins
lose their assignment statement expansion properties when preceded
by 'command'.
33. The 'bg' builtin uses the required format to describe each job
35. The 'bg' builtin uses the required format to describe each job
placed in the background, which does not include an indication of
whether the job is the current or previous job.
34. The output of 'kill -l' prints all the signal names on a single
36. The output of 'kill -l' prints all the signal names on a single
line, separated by spaces, without the 'SIG' prefix.
35. The 'kill' builtin does not accept signal names with a 'SIG'
37. The 'kill' builtin does not accept signal names with a 'SIG'
prefix.
36. The 'export' and 'readonly' builtin commands display their output
38. The 'export' and 'readonly' builtin commands display their output
in the format required by POSIX.
37. The 'trap' builtin displays signal names without the leading
39. The 'trap' builtin displays signal names without the leading
'SIG'.
38. The 'trap' builtin doesn't check the first argument for a possible
40. The 'trap' builtin doesn't check the first argument for a possible
signal specification and revert the signal handling to the original
disposition if it is, unless that argument consists solely of
digits and is a valid signal number. If users want to reset the
handler for a given signal to the original disposition, they should
use '-' as the first argument.
39. The '.' and 'source' builtins do not search the current directory
41. The '.' and 'source' builtins do not search the current directory
for the filename argument if it is not found by searching 'PATH'.
40. Enabling POSIX mode has the effect of setting the
42. Enabling POSIX mode has the effect of setting the
'inherit_errexit' option, so subshells spawned to execute command
substitutions inherit the value of the '-e' option from the parent
shell. When the 'inherit_errexit' option is not enabled, Bash
clears the '-e' option in such subshells.
41. When the 'alias' builtin displays alias definitions, it does not
43. When the 'alias' builtin displays alias definitions, it does not
display them with a leading 'alias ' unless the '-p' option is
supplied.
42. When the 'set' builtin is invoked without options, it does not
44. When the 'set' builtin is invoked without options, it does not
display shell function names and definitions.
43. When the 'set' builtin is invoked without options, it displays
45. When the 'set' builtin is invoked without options, it displays
variable values without quotes, unless they contain shell
metacharacters, even if the result contains nonprinting characters.
44. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname
46. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from '$PWD' and the directory name supplied as an
argument does not refer to an existing directory, 'cd' will fail
instead of falling back to PHYSICAL mode.
45. The 'pwd' builtin verifies that the value it prints is the same as
47. The 'pwd' builtin verifies that the value it prints is the same as
the current directory, even if it is not asked to check the file
system with the '-P' option.
46. When listing the history, the 'fc' builtin does not include an
48. When listing the history, the 'fc' builtin does not include an
indication of whether or not a history entry has been modified.
47. The default editor used by 'fc' is 'ed'.
49. The default editor used by 'fc' is 'ed'.
48. The 'type' and 'command' builtins will not report a non-executable
50. The 'type' and 'command' builtins will not report a non-executable
file as having been found, though the shell will attempt to execute
such a file if it is the only so-named file found in '$PATH'.
49. The 'vi' editing mode will invoke the 'vi' editor directly when
51. The 'vi' editing mode will invoke the 'vi' editor directly when
the 'v' command is run, instead of checking '$VISUAL' and
'$EDITOR'.
50. When the 'xpg_echo' option is enabled, Bash does not attempt to
52. When the 'xpg_echo' option is enabled, Bash does not attempt to
interpret any arguments to 'echo' as options. Each argument is
displayed, after escape characters are converted.
51. The 'ulimit' builtin uses a block size of 512 bytes for the '-c'
53. The 'ulimit' builtin uses a block size of 512 bytes for the '-c'
and '-f' options.
52. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not
54. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not
interrupt the 'wait' builtin and cause it to return immediately.
The trap command is run once for each child that exits.
53. The 'read' builtin may be interrupted by a signal for which a trap
55. The 'read' builtin may be interrupted by a signal for which a trap
has been set. If Bash receives a trapped signal while executing
'read', the trap handler executes and 'read' returns an exit status
greater than 128.
54. Bash removes an exited background process's status from the list
56. Bash removes an exited background process's status from the list
of such statuses after the 'wait' builtin is used to obtain it.
There is other POSIX behavior that Bash does not implement by default
+15 -3
View File
@@ -1,7 +1,7 @@
Introduction
============
This is GNU Bash, version 4.4. Bash is the GNU Project's Bourne
This is GNU Bash, version 5.0. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX shell spec,
but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history
@@ -15,8 +15,8 @@ See the file POSIX for a discussion of how the Bash defaults differ
from the POSIX spec and a description of the Bash `posix mode'.
There are some user-visible incompatibilities between this version
of Bash and previous widely-distributed versions, bash-4.2 and
bash-4.3. For details, see the file COMPAT. The NEWS file tersely
of Bash and previous widely-distributed versions, bash-4.3 and
bash-4.4. For details, see the file COMPAT. The NEWS file tersely
lists features that are new in this release.
Bash is free software, distributed under the terms of the [GNU] General
@@ -88,6 +88,18 @@ to bash-maintainers@gnu.org.
While the Bash maintainers do not promise to fix all bugs, we would
like this shell to be the best that we can make it.
Other Packages
==============
This distribution includes, in examples/bash-completion, a recent version
of the `bash-completion' package, which provides programmable completions
for a number of commands. It's available as a package in many distributions,
and that is the first place from which to obtain it. If it's not a package
from your vendor, you may install the included version.
The latest version of bash-completion is always available from
https://github.com/scop/bash-completion.
Enjoy!
Chet Ramey
Vendored
+46 -19
View File
@@ -1,4 +1,4 @@
dnl
nl
dnl Bash specific tests
dnl
dnl Some derived from PDKSH 5.1.3 autoconf tests
@@ -1357,7 +1357,7 @@ AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
AC_MSG_CHECKING(for presence of necessary job control definitions)
AC_CACHE_VAL(bash_cv_job_control_missing,
[AC_TRY_RUN([
[AC_TRY_COMPILE([
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
@@ -1367,42 +1367,38 @@ AC_CACHE_VAL(bash_cv_job_control_missing,
#endif
#include <signal.h>
/* Add more tests in here as appropriate. */
main()
{
/* add more tests in here as appropriate */
/* signal type */
#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
exit(1);
#error
#endif
/* signals and tty control. */
#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
exit (1);
#error
#endif
/* process control */
#if !defined (WNOHANG) || !defined (WUNTRACED)
exit(1);
#error
#endif
/* Posix systems have tcgetpgrp and waitpid. */
#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
exit(1);
#error
#endif
#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
exit(1);
#error
#endif
/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
exit(1);
#error
#endif
exit(0);
}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
[AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
bash_cv_job_control_missing=missing]
], , bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing
)])
AC_MSG_RESULT($bash_cv_job_control_missing)
if test $bash_cv_job_control_missing = missing; then
@@ -1585,9 +1581,7 @@ fi
AC_DEFUN(BASH_CHECK_DEV_STDIN,
[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
AC_CACHE_VAL(bash_cv_dev_stdin,
[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
[if (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
else
bash_cv_dev_stdin=absent
@@ -1798,6 +1792,8 @@ if test "$am_cv_func_iconv" = yes; then
LIBS="$OLDLIBS"
fi
AC_CHECK_SIZEOF(wchar_t, 4)
])
dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
@@ -1856,7 +1852,7 @@ main()
],
ac_cv_rl_version=`cat conftest.rlv`,
ac_cv_rl_version='0.0',
ac_cv_rl_version='6.3')])
ac_cv_rl_version='7.0')])
CFLAGS="$_save_CFLAGS"
LDFLAGS="$_save_LDFLAGS"
@@ -4195,3 +4191,34 @@ fi
AC_MSG_RESULT($bash_cv_wexitstatus_offset)
AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
])
AC_DEFUN([BASH_FUNC_SBRK],
[
AC_CHECK_FUNCS_ONCE([sbrk])
if test X$ac_cv_func_sbrk = Xyes; then
AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
int
main(int c, char **v)
{
void *x;
x = sbrk (4096);
exit ((x == (void *)-1) ? 1 : 0);
}
], bash_cv_func_sbrk=yes, bash_cv_func_snprintf=sbrk,
[AC_MSG_WARN([cannot check working sbrk if cross-compiling])
bash_cv_func_sbrk=yes]
)])
if test $bash_cv_func_sbrk = no; then
ac_cv_func_sbrk=no
fi
fi
if test $ac_cv_func_sbrk = no; then
AC_DEFINE(HAVE_SBRK, 0,
[Define if you have a working sbrk function.])
fi
])
+4
View File
@@ -158,6 +158,10 @@ free_alias_data (data)
register alias_t *a;
a = (alias_t *)data;
if (a->flags & AL_BEINGEXPANDED)
clear_string_list_expander (a); /* call back to the parser */
free (a->value);
free (a->name);
free (data);
+3
View File
@@ -67,4 +67,7 @@ extern char *alias_expand_word __P((char *));
/* Return a new line, with any aliases expanded. */
extern char *alias_expand __P((char *));
/* Helper definition for the parser */
extern void clear_string_list_expander __P((alias_t *));
#endif /* _ALIAS_H_ */
+126 -44
View File
@@ -9,7 +9,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 1997-2009 Free Software Foundation, Inc.
/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -52,40 +52,30 @@
ae->prev = new; \
new->next = ae; \
} while(0)
#define ADD_AFTER(ae, new) \
do { \
ae->next->prev = new; \
new->next = ae->next; \
new->prev = ae; \
ae->next = new; \
} while (0)
static char *array_to_string_internal __P((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int));
/* lastref should be moved into the array structure so each array can be
optimized separately */
static char *spacesep = " ";
static ARRAY *lastarray = 0;
static ARRAY_ELEMENT *lastref = 0;
#define IS_LASTREF(a) (lastarray && (a) == lastarray)
#define IS_LASTREF(a) (a->lastref)
#define LASTREF_START(a, i) \
(IS_LASTREF(a) && i >= element_index(lastref)) ? lastref \
: element_forw(a->head)
(IS_LASTREF(a) && i >= element_index(a->lastref)) ? a->lastref \
: element_forw(a->head)
#define INVALIDATE_LASTREF(a) \
do { \
if ((a) == lastarray) { \
lastarray = 0; \
lastref = 0; \
} \
} while (0)
#define LASTREF(a) (a->lastref ? a->lastref : element_forw(a->head))
#define SET_LASTREF(a, e) \
do { \
lastarray = (a); \
lastref = (e); \
} while (0)
#define UNSET_LASTREF() \
do { \
lastarray = 0; \
lastref = 0; \
} while (0)
#define INVALIDATE_LASTREF(a) a->lastref = 0
#define SET_LASTREF(a, e) a->lastref = (e)
#define UNSET_LASTREF(a) a->lastref = 0;
ARRAY *
array_create()
@@ -93,10 +83,11 @@ array_create()
ARRAY *r;
ARRAY_ELEMENT *head;
r =(ARRAY *)xmalloc(sizeof(ARRAY));
r = (ARRAY *)xmalloc(sizeof(ARRAY));
r->type = array_indexed;
r->max_index = -1;
r->num_elements = 0;
r->lastref = (ARRAY_ELEMENT *)0;
head = array_create_element(-1, (char *)NULL); /* dummy head */
head->prev = head->next = head;
r->head = head;
@@ -149,6 +140,8 @@ ARRAY *a;
for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) {
new = array_create_element(element_index(ae), element_value(ae));
ADD_BEFORE(a1->head, new);
if (ae == LASTREF(a))
SET_LASTREF(a1, new);
}
return(a1);
}
@@ -391,7 +384,6 @@ array_remove_quoted_nulls(array)
ARRAY *array;
{
ARRAY_ELEMENT *a;
char *t;
if (array == 0 || array_head(array) == 0 || array_empty(array))
return (ARRAY *)NULL;
@@ -498,9 +490,13 @@ int mflags;
if (mflags & MATCH_STARSUB) {
array_remove_quoted_nulls (a2);
sifs = ifs_firstchar((int *)NULL);
if ((mflags & MATCH_QUOTED) == 0 && ifs_is_null)
sifs = spacesep;
else
sifs = ifs_firstchar((int *)NULL);
t = array_to_string (a2, sifs, 0);
free(sifs);
if (sifs != spacesep)
free(sifs);
} else if (mflags & MATCH_QUOTED) {
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
@@ -549,9 +545,13 @@ int mflags;
if (mflags & MATCH_STARSUB) {
array_remove_quoted_nulls (a2);
sifs = ifs_firstchar((int *)NULL);
if ((mflags & MATCH_QUOTED) == 0 && ifs_is_null)
sifs = spacesep;
else
sifs = ifs_firstchar((int *)NULL);
t = array_to_string (a2, sifs, 0);
free(sifs);
if (sifs != spacesep)
free(sifs);
} else if (mflags & MATCH_QUOTED) {
/* ${array[@]} */
sifs = ifs_firstchar (&slen);
@@ -618,6 +618,8 @@ arrayind_t i;
char *v;
{
register ARRAY_ELEMENT *new, *ae, *start;
arrayind_t startind;
int direction;
if (a == 0)
return(-1);
@@ -633,6 +635,12 @@ char *v;
a->num_elements++;
SET_LASTREF(a, new);
return(0);
} else if (i < array_first_index(a)) {
/* Hook at the beginning */
ADD_AFTER(a->head, new);
a->num_elements++;
SET_LASTREF(a, new);
return(0);
}
#if OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT
/*
@@ -640,26 +648,48 @@ char *v;
* handle optimizes the case of sequential or almost-sequential
* assignments that are not at the end of the array.
*/
start = LASTREF_START(a, i);
start = LASTREF(a);
/* Use same strategy as array_reference to avoid paying large penalty
for semi-random assignment pattern. */
startind = element_index(start);
if (i < startind/2) {
start = element_forw(a->head);
startind = element_index(start);
direction = 1;
} else if (i >= startind) {
direction = 1;
} else {
direction = -1;
}
#else
start = element_forw(ae->head);
startind = element_index(start);
direction = 1;
#endif
for (ae = start; ae != a->head; ae = element_forw(ae)) {
for (ae = start; ae != a->head; ) {
if (element_index(ae) == i) {
/*
* Replacing an existing element.
*/
array_dispose_element(new);
free(element_value(ae));
ae->value = v ? savestring(v) : (char *)NULL;
/* Just swap in the new value */
ae->value = new->value;
new->value = 0;
array_dispose_element(new);
SET_LASTREF(a, ae);
return(0);
} else if (element_index(ae) > i) {
} else if (direction == 1 && element_index(ae) > i) {
ADD_BEFORE(ae, new);
a->num_elements++;
SET_LASTREF(a, new);
return(0);
} else if (direction == -1 && element_index(ae) < i) {
ADD_AFTER(ae, new);
a->num_elements++;
SET_LASTREF(a, new);
return(0);
}
ae = direction == 1 ? element_forw(ae) : element_back(ae);
}
array_dispose_element(new);
INVALIDATE_LASTREF(a);
@@ -676,11 +706,27 @@ ARRAY *a;
arrayind_t i;
{
register ARRAY_ELEMENT *ae, *start;
arrayind_t startind;
int direction;
if (a == 0 || array_empty(a))
return((ARRAY_ELEMENT *) NULL);
start = LASTREF_START(a, i);
for (ae = start; ae != a->head; ae = element_forw(ae))
if (i > array_max_index(a) || i < array_first_index(a))
return((ARRAY_ELEMENT *)NULL); /* Keep roving pointer into array to optimize sequential access */
start = LASTREF(a);
/* Use same strategy as array_reference to avoid paying large penalty
for semi-random assignment pattern. */
startind = element_index(start);
if (i < startind/2) {
start = element_forw(a->head);
startind = element_index(start);
direction = 1;
} else if (i >= startind) {
direction = 1;
} else {
direction = -1;
}
for (ae = start; ae != a->head; ) {
if (element_index(ae) == i) {
ae->next->prev = ae->prev;
ae->prev->next = ae->next;
@@ -699,6 +745,12 @@ arrayind_t i;
#endif
return(ae);
}
ae = (direction == 1) ? element_forw(ae) : element_back(ae);
if (direction == 1 && element_index(ae) > i)
break;
else if (direction == -1 && element_index(ae) < i)
break;
}
return((ARRAY_ELEMENT *) NULL);
}
@@ -711,18 +763,48 @@ ARRAY *a;
arrayind_t i;
{
register ARRAY_ELEMENT *ae, *start;
arrayind_t startind;
int direction;
if (a == 0 || array_empty(a))
return((char *) NULL);
if (i > array_max_index(a))
if (i > array_max_index(a) || i < array_first_index(a))
return((char *)NULL); /* Keep roving pointer into array to optimize sequential access */
start = LASTREF_START(a, i);
for (ae = start; ae != a->head; ae = element_forw(ae))
start = LASTREF(a); /* lastref pointer */
startind = element_index(start);
if (i < startind/2) { /* XXX - guess */
start = element_forw(a->head);
startind = element_index(start);
direction = 1;
} else if (i >= startind) {
direction = 1;
} else {
direction = -1;
}
for (ae = start; ae != a->head; ) {
if (element_index(ae) == i) {
SET_LASTREF(a, ae);
return(element_value(ae));
}
UNSET_LASTREF(); /* XXX SET_LASTREF(a, start) ? */
ae = (direction == 1) ? element_forw(ae) : element_back(ae);
/* Take advantage of index ordering to short-circuit */
/* If we don't find it, set the lastref pointer to the element
that's `closest', assuming that the unsuccessful reference
will quickly be followed by an assignment. No worse than
not changing it from the previous value or resetting it. */
if (direction == 1 && element_index(ae) > i) {
start = ae; /* use for SET_LASTREF below */
break;
} else if (direction == -1 && element_index(ae) < i) {
start = ae; /* use for SET_LASTREF below */
break;
}
}
#if 0
UNSET_LASTREF(a);
#else
SET_LASTREF(a, start);
#endif
return((char *) NULL);
}
+4
View File
@@ -33,6 +33,7 @@ typedef struct array {
enum atype type;
arrayind_t max_index;
int num_elements;
struct array_element *lastref;
struct array_element *head;
} ARRAY;
@@ -94,6 +95,7 @@ extern ARRAY *array_from_string __P((char *, char *));
#define array_num_elements(a) ((a)->num_elements)
#define array_max_index(a) ((a)->max_index)
#define array_first_index(a) ((a)->head->next->ind)
#define array_head(a) ((a)->head)
#define array_empty(a) ((a)->num_elements == 0)
@@ -102,6 +104,8 @@ extern ARRAY *array_from_string __P((char *, char *));
#define element_forw(ae) ((ae)->next)
#define element_back(ae) ((ae)->prev)
#define set_element_value(ae, val) ((ae)->value = (val))
/* Convenience */
#define array_push(a,v) \
do { array_rshift ((a), 1, (v)); } while (0)
+65 -36
View File
@@ -30,6 +30,7 @@
#include "bashintl.h"
#include "shell.h"
#include "execute_cmd.h"
#include "pathexp.h"
#include "shmbutil.h"
@@ -39,9 +40,12 @@
#include "builtins/common.h"
extern char *this_command_name;
extern int last_command_exit_value;
extern int array_needs_making;
/* This variable means to not expand associative array subscripts more than
once, when performing variable expansion. */
int assoc_expand_once = 0;
/* Ditto for indexed array subscripts -- currently unused */
int array_expand_once = 0;
static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *, char *, int));
static SHELL_VAR *assign_array_element_internal __P((SHELL_VAR *, char *, char *, char *, int, char *, int));
@@ -258,9 +262,6 @@ bind_assoc_variable (entry, name, key, value, flags)
char *value;
int flags;
{
SHELL_VAR *dentry;
char *newval;
if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
{
if (readonly_p (entry))
@@ -272,7 +273,8 @@ bind_assoc_variable (entry, name, key, value, flags)
}
/* Parse NAME, a lhs of an assignment statement of the form v[s], and
assign VALUE to that array element by calling bind_array_variable(). */
assign VALUE to that array element by calling bind_array_variable().
Flags are ASS_ assignment flags */
SHELL_VAR *
assign_array_element (name, value, flags)
char *name, *value;
@@ -280,9 +282,9 @@ assign_array_element (name, value, flags)
{
char *sub, *vname;
int sublen;
SHELL_VAR *entry, *nv;
SHELL_VAR *entry;
vname = array_variable_name (name, &sub, &sublen);
vname = array_variable_name (name, (flags & ASS_NOEXPAND) != 0, &sub, &sublen);
if (vname == 0)
return ((SHELL_VAR *)NULL);
@@ -317,7 +319,10 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
if (entry && assoc_p (entry))
{
sub[sublen-1] = '\0';
akey = expand_assignment_string_to_string (sub, 0); /* [ */
if ((flags & ASS_NOEXPAND) == 0)
akey = expand_assignment_string_to_string (sub, 0); /* [ */
else
akey = savestring (sub);
sub[sublen-1] = ']';
if (akey == 0 || *akey == 0)
{
@@ -329,7 +334,7 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
}
else
{
ind = array_expand_index (entry, sub, sublen);
ind = array_expand_index (entry, sub, sublen, 0);
/* negative subscripts to indexed arrays count back from end */
if (entry && ind < 0)
ind = (array_p (entry) ? array_max_index (array_cell (entry)) : 0) + 1 + ind;
@@ -450,7 +455,6 @@ expand_compound_array_assignment (var, value, flags)
int flags;
{
WORD_LIST *list, *nlist;
WORD_LIST *hd, *tl, *t, *n;
char *val;
int ni;
@@ -583,7 +587,7 @@ assign_compound_array_list (var, nlist, flags)
if (array_p (var))
{
ind = array_expand_index (var, w + 1, len);
ind = array_expand_index (var, w + 1, len, 0);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
@@ -759,17 +763,19 @@ quote_array_assignment_chars (list)
/* This function is called with SUB pointing to just after the beginning
`[' of an array subscript and removes the array element to which SUB
expands from array VAR. A subscript of `*' or `@' unsets the array. */
/* If FLAGS&1 we don't expand the subscript; we just use it as-is. */
int
unbind_array_element (var, sub)
unbind_array_element (var, sub, flags)
SHELL_VAR *var;
char *sub;
int flags;
{
int len;
arrayind_t ind;
char *akey;
ARRAY_ELEMENT *ae;
len = skipsubscript (sub, 0, (var && assoc_p(var)));
len = skipsubscript (sub, 0, (flags&1) || (var && assoc_p(var)));
if (sub[len] != ']' || len == 0)
{
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
@@ -790,7 +796,7 @@ unbind_array_element (var, sub)
if (assoc_p (var))
{
akey = expand_assignment_string_to_string (sub, 0); /* [ */
akey = (flags & 1) ? sub : expand_assignment_string_to_string (sub, 0);
if (akey == 0 || *akey == 0)
{
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
@@ -798,11 +804,12 @@ unbind_array_element (var, sub)
return -1;
}
assoc_remove (assoc_cell (var), akey);
free (akey);
if (akey != sub)
free (akey);
}
else if (array_p (var))
{
ind = array_expand_index (var, sub, len+1);
ind = array_expand_index (var, sub, len+1, 0);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
@@ -818,7 +825,7 @@ unbind_array_element (var, sub)
else /* array_p (var) == 0 && assoc_p (var) == 0 */
{
akey = this_command_name;
ind = array_expand_index (var, sub, len+1);
ind = array_expand_index (var, sub, len+1, 0);
this_command_name = akey;
if (ind == 0)
{
@@ -895,26 +902,34 @@ valid_array_reference (name, flags)
*t = '[';
if (r == 0)
return 0;
/* Check for a properly-terminated non-blank subscript. */
len = skipsubscript (t, 0, 0);
/* Check for a properly-terminated non-null subscript. */
len = skipsubscript (t, 0, flags);
if (t[len] != ']' || len == 1)
return 0;
if (t[len+1] != '\0')
return 0;
#if 1
/* Could check and allow subscripts consisting only of whitespace for
existing associative arrays. */
for (r = 1; r < len; r++)
if (whitespace (t[r]) == 0)
return 1;
return 0;
#else
/* This allows blank subscripts */
return 1;
#endif
}
return 0;
}
/* Expand the array index beginning at S and extending LEN characters. */
arrayind_t
array_expand_index (var, s, len)
array_expand_index (var, s, len, flags)
SHELL_VAR *var;
char *s;
int len;
int flags;
{
char *exp, *t, *savecmd;
int expok;
@@ -923,12 +938,19 @@ array_expand_index (var, s, len)
exp = (char *)xmalloc (len);
strncpy (exp, s, len - 1);
exp[len - 1] = '\0';
#if 0 /* XXX - not yet -- maybe bash-5.0 */
if ((flags & AV_NOEXPAND) == 0)
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
else
t = exp;
#endif
t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */
savecmd = this_command_name;
this_command_name = (char *)NULL;
val = evalexp (t, &expok);
val = evalexp (t, 0, &expok);
this_command_name = savecmd;
free (t);
if (t != exp)
free (t);
free (exp);
if (expok == 0)
{
@@ -947,8 +969,9 @@ array_expand_index (var, s, len)
in *SUBP. If LENP is non-null, the length of the subscript is returned
in *LENP. This returns newly-allocated memory. */
char *
array_variable_name (s, subp, lenp)
array_variable_name (s, flags, subp, lenp)
const char *s;
int flags;
char **subp;
int *lenp;
{
@@ -965,7 +988,7 @@ array_variable_name (s, subp, lenp)
return ((char *)NULL);
}
ind = t - s;
ni = skipsubscript (s, ind, 0);
ni = skipsubscript (s, ind, flags); /* XXX - was 0 not flags */
if (ni <= ind + 1 || s[ni] != ']')
{
err_badarraysub (s);
@@ -992,15 +1015,16 @@ array_variable_name (s, subp, lenp)
non-null, return a pointer to the start of the subscript in *SUBP.
If LENP is non-null, the length of the subscript is returned in *LENP. */
SHELL_VAR *
array_variable_part (s, subp, lenp)
array_variable_part (s, flags, subp, lenp)
const char *s;
int flags;
char **subp;
int *lenp;
{
char *t;
SHELL_VAR *var;
t = array_variable_name (s, subp, lenp);
t = array_variable_name (s, flags, subp, lenp);
if (t == 0)
return ((SHELL_VAR *)NULL);
var = find_variable (t); /* XXX - handle namerefs here? */
@@ -1042,7 +1066,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
WORD_LIST *l;
SHELL_VAR *var;
var = array_variable_part (s, &t, &len);
var = array_variable_part (s, (flags&AV_NOEXPAND) ? 1 : 0, &t, &len); /* XXX */
/* Expand the index, even if the variable doesn't exist, in case side
effects are needed, like ${w[i++]} where w is unset. */
@@ -1082,15 +1106,17 @@ array_value_internal (s, quoted, flags, rtype, indp)
return ((char *) NULL);
}
/* Caller of array_value takes care of inspecting rtype and duplicating
retval if rtype == 0, so this is not a memory leak */
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l);
retval = quote_string (temp); /* XXX - leak here */
temp = string_list_dollar_star (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0);
retval = quote_string (temp);
free (temp);
}
else /* ${name[@]} or unquoted ${name[*]} */
/* XXX - bash-4.4/bash-5.0 test AV_ASSIGNRHS and pass PF_ASSIGNRHS */
retval = string_list_dollar_at (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0); /* XXX - leak here */
retval = string_list_dollar_at (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0);
dispose_words (l);
}
@@ -1102,7 +1128,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
{
if ((flags & AV_USEIND) == 0 || indp == 0)
{
ind = array_expand_index (var, t, len);
ind = array_expand_index (var, t, len, flags);
if (ind < 0)
{
/* negative subscripts to indexed arrays count back from end */
@@ -1120,7 +1146,10 @@ array_value_internal (s, quoted, flags, rtype, indp)
else if (assoc_p (var))
{
t[len - 1] = '\0';
akey = expand_assignment_string_to_string (t, 0); /* [ */
if ((flags & AV_NOEXPAND) == 0)
akey = expand_assignment_string_to_string (t, 0); /* [ */
else
akey = savestring (t);
t[len - 1] = ']';
if (akey == 0 || *akey == 0)
{
@@ -1182,7 +1211,7 @@ array_keys (s, quoted)
WORD_LIST *l;
SHELL_VAR *var;
var = array_variable_part (s, &t, &len);
var = array_variable_part (s, 0, &t, &len);
/* [ */
if (var == 0 || ALL_ELEMENT_SUB (t[0]) == 0 || t[1] != ']')
@@ -1202,7 +1231,7 @@ array_keys (s, quoted)
if (t[0] == '*' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
{
temp = string_list_dollar_star (l);
temp = string_list_dollar_star (l, quoted, 0);
retval = quote_string (temp);
free (temp);
}
+12 -4
View File
@@ -25,12 +25,20 @@
#if defined (ARRAY_VARS)
/* This variable means to not expand associative array subscripts more than
once, when performing variable expansion. */
extern int assoc_expand_once;
/* The analog for indexed array subscripts */
extern int array_expand_once;
/* Flags for array_value_internal and callers array_value/get_array_value */
#define AV_ALLOWALL 0x001
#define AV_QUOTED 0x002
#define AV_USEIND 0x004
#define AV_USEVAL 0x008 /* XXX - should move this */
#define AV_ASSIGNRHS 0x010 /* no splitting, special case ${a[@]} */
#define AV_NOEXPAND 0x020 /* don't run assoc subscripts through word expansion */
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
@@ -52,21 +60,21 @@ extern WORD_LIST *expand_compound_array_assignment __P((SHELL_VAR *, char *, int
extern void assign_compound_array_list __P((SHELL_VAR *, WORD_LIST *, int));
extern SHELL_VAR *assign_array_var_from_string __P((SHELL_VAR *, char *, int));
extern int unbind_array_element __P((SHELL_VAR *, char *));
extern int unbind_array_element __P((SHELL_VAR *, char *, int));
extern int skipsubscript __P((const char *, int, int));
extern void print_array_assignment __P((SHELL_VAR *, int));
extern void print_assoc_assignment __P((SHELL_VAR *, int));
extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int));
extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int, int));
extern int valid_array_reference __P((const char *, int));
extern char *array_value __P((const char *, int, int, int *, arrayind_t *));
extern char *get_array_value __P((const char *, int, int *, arrayind_t *));
extern char *array_keys __P((char *, int));
extern char *array_variable_name __P((const char *, char **, int *));
extern SHELL_VAR *array_variable_part __P((const char *, char **, int *));
extern char *array_variable_name __P((const char *, int, char **, int *));
extern SHELL_VAR *array_variable_part __P((const char *, int, char **, int *));
#else
+54 -15
View File
@@ -44,6 +44,7 @@
#include "shell.h"
#include "flags.h"
#include "parser.h"
#include "input.h"
#include "parser.h" /* for the struct dstack stuff. */
#include "pathexp.h" /* for the struct ignorevar stuff */
@@ -140,6 +141,11 @@ int command_oriented_history = 1;
the history-manipluating builtins can see it. */
int current_command_first_line_saved = 0;
/* Set to the number of the most recent line of a possibly-multi-line command
that contains a shell comment. Used by bash_add_history() to determine
whether to add a newline or a semicolon. */
int current_command_line_comment = 0;
/* Non-zero means to store newlines in the history list when using
command_oriented_history rather than trying to use semicolons. */
int literal_history;
@@ -182,12 +188,6 @@ int hist_verify;
/* Non-zero means to not save function definitions in the history list. */
int dont_save_function_defs;
/* Variables declared in other files used here. */
extern int current_command_line_count;
extern struct dstack dstack;
extern int parser_state;
#if defined (BANG_HISTORY)
static int bash_history_inhibit_expansion __P((char *, int));
#endif
@@ -267,8 +267,8 @@ bash_history_reinit (interact)
int interact;
{
#if defined (BANG_HISTORY)
history_expansion = interact != 0;
history_expansion_inhibited = 1; /* XXX */
history_expansion = (interact == 0) ? histexp_flag : HISTEXPAND_DEFAULT;
history_expansion_inhibited = (interact == 0) ? 1 - histexp_flag : 0; /* changed in bash_history_enable() */
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#endif
remember_on_history = enable_history_list;
@@ -350,6 +350,21 @@ bash_delete_histent (i)
return 1;
}
int
bash_delete_history_range (first, last)
int first, last;
{
register int i;
HIST_ENTRY **discard_list;
discard_list = remove_history_range (first, last);
for (i = 0; discard_list && discard_list[i]; i++)
free_history_entry (discard_list[i]);
history_lines_this_session -= i;
return 1;
}
int
bash_delete_last_history ()
{
@@ -597,16 +612,24 @@ pre_process_line (line, print_changes, addit)
}
/* Return 1 if the first non-whitespace character in LINE is a `#', indicating
* that the line is a shell comment. */
that the line is a shell comment. Return 2 if there is a comment after the
first non-whitespace character. Return 0 if the line does not contain a
comment. */
static int
shell_comment (line)
char *line;
{
char *p;
int n;
if (line == 0)
return 0;
for (p = line; p && *p && whitespace (*p); p++)
;
return (p && *p == '#');
if (p && *p == '#')
return 1;
n = skip_to_delim (line, p - line, "#", SD_NOJMP|SD_GLOB|SD_EXTGLOB|SD_COMPLETE);
return (line[n] == '#') ? 2 : 0;
}
#ifdef INCLUDE_UNUSED
@@ -700,7 +723,10 @@ void
maybe_add_history (line)
char *line;
{
int is_comment;
hist_last_line_added = 0;
is_comment = shell_comment (line);
/* Don't use the value of history_control to affect the second
and subsequent lines of a multi-line command (old code did
@@ -708,13 +734,15 @@ maybe_add_history (line)
if (current_command_line_count > 1)
{
if (current_command_first_line_saved &&
((parser_state & PST_HEREDOC) || literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0))
((parser_state & PST_HEREDOC) || literal_history || dstack.delimiter_depth != 0 || is_comment != 1))
bash_add_history (line);
current_command_line_comment = is_comment ? current_command_line_count : -2;
return;
}
/* This is the first line of a (possible multi-line) command. Note whether
or not we should save the first line and remember it. */
current_command_line_comment = is_comment ? current_command_line_count : -2;
current_command_first_line_saved = check_add_history (line, 0);
}
@@ -748,12 +776,16 @@ check_add_history (line, force)
#if defined (SYSLOG_HISTORY)
#define SYSLOG_MAXLEN 600
extern char *shell_name;
#ifndef OPENLOG_OPTS
#define OPENLOG_OPTS 0
#endif
#if defined (SYSLOG_SHOPT)
int syslog_history = SYSLOG_SHOPT;
#else
int syslog_history = 1;
#endif
void
bash_syslog_history (line)
const char *line;
@@ -803,12 +835,18 @@ bash_add_history (line)
so we have to duplicate some of what that function does here. */
if ((parser_state & PST_HEREDOC) && literal_history && current_command_line_count > 2 && line[strlen (line) - 1] == '\n')
chars_to_add = "";
else if (current_command_line_count == current_command_line_comment+1)
chars_to_add = "\n";
else if (literal_history)
chars_to_add = "\n";
else
chars_to_add = literal_history ? "\n" : history_delimiting_chars (line);
chars_to_add = history_delimiting_chars (line);
using_history ();
current = previous_history ();
current_command_line_comment = shell_comment (line) ? current_command_line_count : -2;
if (current)
{
/* If the previous line ended with an escaped newline (escaped
@@ -851,7 +889,8 @@ bash_add_history (line)
really_add_history (line);
#if defined (SYSLOG_HISTORY)
bash_syslog_history (line);
if (syslog_history)
bash_syslog_history (line);
#endif
using_history ();
+15
View File
@@ -30,6 +30,12 @@
#define HC_IGNBOTH (HC_IGNSPACE|HC_IGNDUPS)
#if defined (STRICT_POSIX)
# define HISTEXPAND_DEFAULT 0
#else
# define HISTEXPAND_DEFAULT 1
#endif
extern int remember_on_history;
extern int enable_history_list; /* value for `set -o history' */
extern int literal_history; /* controlled by `shopt lithist' */
@@ -40,11 +46,19 @@ extern int history_expansion;
extern int history_control;
extern int command_oriented_history;
extern int current_command_first_line_saved;
extern int current_command_first_line_comment;
extern int hist_last_line_added;
extern int hist_last_line_pushed;
extern int dont_save_function_defs;
# if defined (READLINE)
extern int hist_verify;
# endif
# if defined (BANG_HISTORY)
extern int history_expansion_inhibited;
extern int double_quotes_inhibit_history_expansion;
# endif /* BANG_HISTORY */
extern void bash_initialize_history __P((void));
@@ -53,6 +67,7 @@ extern void bash_history_disable __P((void));
extern void bash_history_enable __P((void));
extern void bash_clear_history __P((void));
extern int bash_delete_histent __P((int));
extern int bash_delete_history_range __P((int, int));
extern int bash_delete_last_history __P((void));
extern void load_history __P((void));
extern void save_history __P((void));
+4
View File
@@ -47,4 +47,8 @@
# define setlocale(cat, loc)
#endif
#if !defined (HAVE_LOCALE_H) || !defined (HAVE_LOCALECONV)
# define locale_decpoint() '.'
#endif
#endif /* !_BASHINTL_H_ */
+1
View File
@@ -26,6 +26,7 @@
extern procenv_t top_level;
extern procenv_t subshell_top_level;
extern procenv_t return_catch; /* used by `return' builtin */
extern procenv_t wait_intr_buf;
extern int no_longjmp_on_fatal_error;
+89 -59
View File
@@ -1,6 +1,6 @@
/* bashline.c -- Bash's interface to the readline library. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -46,6 +46,7 @@
#include "shell.h"
#include "input.h"
#include "parser.h"
#include "builtins.h"
#include "bashhist.h"
#include "bashline.h"
@@ -65,6 +66,7 @@
#include <readline/rlconf.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <readline/rlmbutil.h>
#include <glob/glob.h>
@@ -200,19 +202,8 @@ static char *prog_complete_return __P((const char *, int));
static char **prog_complete_matches;
#endif
/* Variables used here but defined in other files. */
#if defined (BANG_HISTORY)
extern int hist_verify;
#endif
extern int current_command_line_count, saved_command_line_count;
extern int last_command_exit_value;
extern int array_needs_making;
extern int posixly_correct, no_symbolic_links;
extern int sigalrm_seen;
extern char *current_prompt_string, *ps1_prompt;
extern int no_symbolic_links;
extern STRING_INT_ALIST word_token_alist[];
extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
completion functions which indicate what type of completion should be
@@ -919,9 +910,9 @@ operate_and_get_next (count, c)
rl_newline (1, c);
/* Find the current line, and find the next line to use. */
where = where_history ();
where = rl_explicit_arg ? count : where_history ();
if (HISTORY_FULL () || (where >= history_length - 1))
if (HISTORY_FULL () || (where >= history_length - 1) || rl_explicit_arg)
saved_history_line_to_use = where;
else
saved_history_line_to_use = where + 1;
@@ -969,8 +960,11 @@ edit_and_execute_command (count, c, editing_mode, edit_command)
/* This breaks down when using command-oriented history and are not
finished with the command, so we should not ignore the last command */
using_history ();
current_command_line_count++; /* for rl_newline above */
bash_add_history (rl_line_buffer);
if (rl_line_buffer[0])
{
current_command_line_count++; /* for rl_newline above */
bash_add_history (rl_line_buffer);
}
current_command_line_count = 0; /* for dummy history entry */
bash_add_history ("");
history_lines_this_session++;
@@ -999,6 +993,11 @@ edit_and_execute_command (count, c, editing_mode, edit_command)
rl_done = 0;
rl_readline_state = rrs;
#if defined (VI_MODE)
if (editing_mode == VI_EDITING_MODE)
rl_vi_insertion_mode (1, c);
#endif
rl_forced_update_display ();
return r;
@@ -1056,7 +1055,7 @@ bash_forward_shellword (count, key)
int count, key;
{
size_t slen;
int sindex, c, p;
int c, p;
DECLARE_MBSTATE;
if (count < 0)
@@ -1165,15 +1164,18 @@ bash_backward_shellword (count, key)
int count, key;
{
size_t slen;
int sindex, c, p;
int c, p;
DECLARE_MBSTATE;
if (count < 0)
return (bash_forward_shellword (-count, key));
p = rl_point;
slen = rl_end;
if (p == rl_end && p > 0)
p--;
while (count)
{
if (p == 0)
@@ -1186,9 +1188,9 @@ bash_backward_shellword (count, key)
while (p > 0)
{
c = rl_line_buffer[p];
if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0)
BACKUP_CHAR (rl_line_buffer, slen, p);
break;
if (WORDDELIM (c) == 0 || char_is_quoted (rl_line_buffer, p))
break;
BACKUP_CHAR (rl_line_buffer, slen, p);
}
if (p == 0)
@@ -1420,7 +1422,7 @@ attempt_shell_completion (text, start, end)
const char *text;
int start, end;
{
int in_command_position, ti, saveti, qc, dflags;
int in_command_position, ti, qc, dflags;
char **matches, *command_separator_chars;
#if defined (PROGRAMMABLE_COMPLETION)
int have_progcomps, was_assignment;
@@ -1442,7 +1444,7 @@ attempt_shell_completion (text, start, end)
appears after a character that separates commands. It cannot be a
command word if we aren't at the top-level prompt. */
ti = start - 1;
saveti = qc = -1;
qc = -1;
while ((ti > -1) && (whitespace (rl_line_buffer[ti])))
ti--;
@@ -1453,7 +1455,7 @@ attempt_shell_completion (text, start, end)
if (ti >= 0 && (rl_line_buffer[ti] == '"' || rl_line_buffer[ti] == '\''))
{
qc = rl_line_buffer[ti];
saveti = ti--;
ti--;
while (ti > -1 && (whitespace (rl_line_buffer[ti])))
ti--;
}
@@ -1639,7 +1641,7 @@ bash_default_completion (text, start, end, qc, compflags)
matches = (char **)NULL;
/* New posix-style command substitution or variable name? */
if (!matches && *text == '$')
if (*text == '$')
{
if (qc != '\'' && text[1] == '(') /* ) */
matches = rl_completion_matches (text, command_subst_completion_function);
@@ -1803,7 +1805,7 @@ command_word_completion_function (hint_text, state)
static char *dequoted_hint = (char *)NULL;
static char *directory_part = (char *)NULL;
static char **glob_matches = (char **)NULL;
static int path_index, hint_len, dequoted_len, istate, igncase;
static int path_index, hint_len, istate, igncase;
static int mapping_over, local_index, searching_path, hint_is_dir;
static int old_glob_ignore_case, globpat;
static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
@@ -1881,7 +1883,7 @@ command_word_completion_function (hint_text, state)
free (hint);
hint = dequoted_hint;
}
dequoted_len = hint_len = strlen (hint);
hint_len = strlen (hint);
if (filename_hint)
free (filename_hint);
@@ -1909,13 +1911,10 @@ command_word_completion_function (hint_text, state)
}
dequoted_hint = hint = savestring (hint_text);
dequoted_len = hint_len = strlen (hint);
hint_len = strlen (hint);
if (rl_completion_found_quote && rl_completion_quote_character == 0)
{
dequoted_hint = bash_dequote_filename (hint, 0);
dequoted_len = strlen (dequoted_hint);
}
dequoted_hint = bash_dequote_filename (hint, 0);
path = get_string_value ("PATH");
path_index = dot_in_path = 0;
@@ -1949,7 +1948,9 @@ command_word_completion_function (hint_text, state)
alias = alias_list[local_index++]->name;
if (STREQN (alias, hint, hint_len))
if (igncase == 0 && (STREQN (alias, hint, hint_len)))
return (savestring (alias));
else if (igncase && strncasecmp (alias, hint, hint_len) == 0)
return (savestring (alias));
}
#endif /* ALIAS */
@@ -1978,7 +1979,10 @@ command_word_completion_function (hint_text, state)
varname = varlist[local_index++]->name;
if (STREQN (varname, hint, hint_len))
/* Honor completion-ignore-case for shell function names. */
if (igncase == 0 && (STREQN (varname, hint, hint_len)))
return (savestring (varname));
else if (igncase && strncasecmp (varname, hint, hint_len) == 0)
return (savestring (varname));
}
local_index = 0;
@@ -2304,7 +2308,6 @@ variable_completion_function (text, state)
static char **varlist = (char **)NULL;
static int varlist_index;
static char *varname = (char *)NULL;
static int namelen;
static int first_char, first_char_loc;
if (!state)
@@ -2323,7 +2326,6 @@ variable_completion_function (text, state)
varname = savestring (text + first_char_loc);
namelen = strlen (varname);
if (varlist)
strvec_dispose (varlist);
@@ -2411,7 +2413,7 @@ bash_servicename_completion_function (text, state)
#else
static char *sname = (char *)NULL;
static struct servent *srvent;
static int snamelen, firstc;
static int snamelen;
char *value;
char **alist, *aentry;
int afound;
@@ -2419,7 +2421,6 @@ bash_servicename_completion_function (text, state)
if (state == 0)
{
FREE (sname);
firstc = *text;
sname = savestring (text);
snamelen = strlen (sname);
@@ -2552,7 +2553,7 @@ static void
maybe_make_readline_line (new_line)
char *new_line;
{
if (strcmp (new_line, rl_line_buffer) != 0)
if (new_line && strcmp (new_line, rl_line_buffer) != 0)
{
rl_point = rl_end;
@@ -2704,6 +2705,7 @@ shell_expand_line (count, ignore)
{
char *new_line;
WORD_LIST *expanded_string;
WORD_DESC *w;
new_line = 0;
#if defined (BANG_HISTORY)
@@ -2733,9 +2735,19 @@ shell_expand_line (count, ignore)
/* If there is variable expansion to perform, do that as a separate
operation to be undone. */
#if 1
w = alloc_word_desc ();
w->word = savestring (rl_line_buffer);
w->flags = rl_explicit_arg ? (W_NOPROCSUB|W_NOCOMSUB) : 0;
expanded_string = expand_word (w, rl_explicit_arg ? Q_HERE_DOCUMENT : 0);
dispose_word (w);
#else
new_line = savestring (rl_line_buffer);
expanded_string = expand_string (new_line, 0);
FREE (new_line);
#endif
if (expanded_string == 0)
{
new_line = (char *)xmalloc (1);
@@ -3138,7 +3150,6 @@ bash_filename_stat_hook (dirname)
int should_expand_dirname, return_value;
int global_nounset;
WORD_LIST *wl;
struct stat sb;
local_dirname = *dirname;
should_expand_dirname = return_value = 0;
@@ -3216,10 +3227,8 @@ bash_directory_completion_hook (dirname)
char **dirname;
{
char *local_dirname, *new_dirname, *t;
int return_value, should_expand_dirname, nextch, closer, changed;
size_t local_dirlen;
int return_value, should_expand_dirname, nextch, closer;
WORD_LIST *wl;
struct stat sb;
return_value = should_expand_dirname = nextch = closer = 0;
local_dirname = *dirname;
@@ -3236,6 +3245,17 @@ bash_directory_completion_hook (dirname)
closer = '}';
else
nextch = 0;
if (closer)
{
int p;
char delims[2];
delims[0] = closer; delims[1] = 0;
p = skip_to_delim (t, 1, delims, SD_NOJMP|SD_COMPLETE);
if (t[p] != closer)
should_expand_dirname = 0;
}
}
else if (local_dirname[0] == '~')
should_expand_dirname = '~';
@@ -3450,6 +3470,7 @@ history_completion_generator (hint_text, state)
while (history_completion_array && history_completion_array[local_index])
{
/* XXX - should this use completion-ignore-case? */
if (strncmp (text, history_completion_array[local_index++], len) == 0)
return (savestring (history_completion_array[local_index - 1]));
}
@@ -3870,7 +3891,7 @@ bash_dequote_filename (text, quote_char)
*r++ = *p;
/* Backslashes are preserved within double quotes unless the
character is one that is defined to be escaped */
else if (quoted == '"' && ((sh_syntaxtab[p[1]] & CBSDQUOTE) == 0))
else if (quoted == '"' && ((sh_syntaxtab[(unsigned char)p[1]] & CBSDQUOTE) == 0))
*r++ = *p;
*r++ = *++p;
@@ -4071,21 +4092,18 @@ bash_execute_unix_command (count, key)
int count; /* ignored */
int key;
{
Keymap ckmap; /* current keymap */
Keymap xkmap; /* unix command executing keymap */
rl_command_func_t *func;
int type;
register int i, r;
intmax_t mi;
sh_parser_state_t ps;
char *cmd, *value, *l, *l1, *ce;
char *cmd, *value, *ce, old_ch;
SHELL_VAR *v;
char ibuf[INT_STRLEN_BOUND(int) + 1];
/* First, we need to find the right command to execute. This is tricky,
because we might have already indirected into another keymap, so we
have to walk cmd_xmap using the entire key sequence. */
cmd = (char *)rl_function_of_keyseq (rl_executing_keyseq, cmd_xmap, &type);
cmd = (char *)rl_function_of_keyseq_len (rl_executing_keyseq, rl_key_sequence_length, cmd_xmap, &type);
if (cmd == 0 || type != ISMACR)
{
@@ -4112,25 +4130,37 @@ bash_execute_unix_command (count, key)
v = bind_variable ("READLINE_LINE", rl_line_buffer, 0);
if (v)
VSETATTR (v, att_exported);
l = v ? value_cell (v) : 0;
value = inttostr (rl_point, ibuf, sizeof (ibuf));
v = bind_int_variable ("READLINE_POINT", value);
i = rl_point;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1)
{
old_ch = rl_line_buffer[rl_point];
rl_line_buffer[rl_point] = '\0';
i = MB_STRLEN (rl_line_buffer);
rl_line_buffer[rl_point] = old_ch;
}
#endif
value = inttostr (i, ibuf, sizeof (ibuf));
v = bind_int_variable ("READLINE_POINT", value, 0);
if (v)
VSETATTR (v, att_exported);
array_needs_making = 1;
save_parser_state (&ps);
r = parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
r = parse_and_execute (savestring (cmd), "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
restore_parser_state (&ps);
v = find_variable ("READLINE_LINE");
l1 = v ? value_cell (v) : 0;
if (l1 != l)
maybe_make_readline_line (value_cell (v));
maybe_make_readline_line (v ? value_cell (v) : 0);
v = find_variable ("READLINE_POINT");
if (v && legal_number (value_cell (v), &mi))
{
i = mi;
#if defined (HANDLE_MULTIBYTE)
if (i > 0 && MB_CUR_MAX > 1)
i = _rl_find_next_mbchar (rl_line_buffer, 0, i, 0);
#endif
if (i != rl_point)
{
rl_point = i;
+10
View File
@@ -24,6 +24,16 @@
#include "stdc.h"
extern int bash_readline_initialized;
extern int hostname_list_initialized;
/* these are controlled via shopt */
extern int perform_hostname_completion;
extern int no_empty_command_completion;
extern int force_fignore;
extern int dircomplete_spelling;
extern int dircomplete_expand;
extern int dircomplete_expand_relpath;
extern int complete_fullquote;
extern void posix_readline_initialize __P((int));
extern void reset_completer_word_break_chars __P((void));
+5 -17
View File
@@ -61,7 +61,9 @@ extern int errno;
extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
#if defined (NOTDEF)
extern int last_command_exit_value;
#endif
/* Basic idea:
@@ -383,7 +385,7 @@ mkseq (start, end, incr, type, width)
int type, width;
{
intmax_t n, prevn;
int i, j, nelem;
int i, nelem;
char **result, *t;
if (incr == 0)
@@ -424,7 +426,7 @@ mkseq (start, end, incr, type, width)
result = strvec_mcreate (nelem + 1);
if (result == 0)
{
internal_error (_("brace expansion: failed to allocate memory for %d elements"), nelem);
internal_error (_("brace expansion: failed to allocate memory for %u elements"), (unsigned int)nelem);
return ((char **)NULL);
}
@@ -494,7 +496,7 @@ expand_seqterm (text, tlen)
size_t tlen;
{
char *t, *lhs, *rhs;
int i, lhs_t, rhs_t, lhs_l, rhs_l, width;
int lhs_t, rhs_t, lhs_l, rhs_l, width;
intmax_t lhs_v, rhs_v, incr;
intmax_t tl, tr;
char **result, *ep, *oep;
@@ -743,20 +745,6 @@ comsub:
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)
+5
View File
@@ -18,6 +18,9 @@
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BUILTINS_H
#define BUILTINS_H
#include "config.h"
#if defined (HAVE_UNISTD_H)
@@ -60,3 +63,5 @@ extern int num_shell_builtins; /* Number of shell builtins. */
extern struct builtin static_shell_builtins[];
extern struct builtin *shell_builtins;
extern struct builtin *current_builtin;
#endif /* BUILTINS_H */
+24 -16
View File
@@ -1,6 +1,6 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
# Copyright (C) 1996-2015 Free Software Foundation, Inc.
# Copyright (C) 1996-2017 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
@@ -94,7 +94,7 @@ INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$
BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \
${INCLUDES} $(LOCAL_CFLAGS)
CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
CCFLAGS = ${ADDON_CFLAGS} $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS)
CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
@@ -331,7 +331,7 @@ bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h
bashgetopt.o: $(BASHINCDIR)/chartypes.h
common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
common.o: $(topdir)/sig.h $(topdir)/command.h
common.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/parser.h
common.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h
common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
@@ -347,7 +347,7 @@ evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir
evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
evalfile.o: ../pathnames.h $(topdir)/externs.h
evalfile.o: ../pathnames.h $(topdir)/externs.h $(topdir)/parser.h
evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
@@ -386,19 +386,18 @@ bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/
bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
bind.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
bind.o: ../pathnames.h
break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
break.o: ../pathnames.h
break.o: ../pathnames.h $(topdir)/execute_cmd.h
builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h
builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h
builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h $(topdir)/execute_cmd.h
caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
@@ -457,10 +456,11 @@ exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h
exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
exit.o: $(topdir)/execute_cmd.h
exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h
fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
fc.o: $(topdir)/bashhist.h
fc.o: $(topdir)/bashhist.h $(topdir)/parser.h
fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
@@ -474,30 +474,34 @@ fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
fg_bg.o: $(topdir)/execute_cmd.h
fg_bg.o: $(topdir)/jobs.h ../pathnames.h
getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
getopts.o: $(topdir)/execute_cmd.h
getopts.o: ../pathnames.h
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h
hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h
help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
help.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h
history.o: $(topdir)/bashtypes.h
history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h $(topdir)/parser.h
history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h
history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
history.o: ../pathnames.h
@@ -552,20 +556,22 @@ return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
return.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
return.o: ../pathnames.h
set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h
set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.h
set.o: $(topdir)/arrayfunc.h ../pathnames.h
set.o: $(topdir)/arrayfunc.h ../pathnames.h $(topdir)/parser.h
setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
setattr.o: $(topdir)/externs.h $(topdir)/flags.h $(topdir)/sig.h
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h
setattr.o: $(topdir)/conftypes.h $(topdir)/execute_cmd.h
setattr.o: $(topdir)/arrayfunc.h ../pathnames.h
shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
@@ -586,6 +592,7 @@ source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir
source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h
source.o: $(topdir)/execute_cmd.h
source.o: ../pathnames.h
suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
@@ -598,7 +605,7 @@ test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
test.o: $(topdir)/test.h ../pathnames.h
test.o: $(topdir)/execute_cmd.h $(topdir)/test.h ../pathnames.h
times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h
@@ -615,6 +622,7 @@ type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/execute_cmd.h $(topdir)/parser.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h ../pathnames.h
type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
@@ -634,7 +642,7 @@ wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h
wait.o: $(topdir)/jobs.h $(topdir)/sig.h
wait.o: $(topdir)/jobs.h $(topdir)/sig.h $(topdir)/execute_cmd.h
wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h
complete.o: ../config.h ../pathnames.h
-2
View File
@@ -65,8 +65,6 @@ $END
static void print_alias __P((alias_t *, int));
extern int posixly_correct;
/* Hack the alias command in a Korn shell way. */
int
alias_builtin (list)
+37 -7
View File
@@ -88,8 +88,7 @@ extern int errno;
static int query_bindings __P((char *));
static int unbind_command __P((char *));
extern int no_line_editing;
static int unbind_keyseq __P((char *));
#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0)
@@ -265,11 +264,8 @@ bind_builtin (list)
if ((flags & RFLAG) && remove_seq)
{
if (rl_bind_keyseq (remove_seq, (rl_command_func_t *)NULL) != 0)
{
builtin_error (_("`%s': cannot unbind"), remove_seq);
BIND_RETURN (EXECUTION_FAILURE);
}
opt = unbind_keyseq (remove_seq);
BIND_RETURN (opt);
}
if (flags & XFLAG)
@@ -342,4 +338,38 @@ unbind_command (name)
rl_unbind_function_in_map (function, rl_get_keymap ());
return EXECUTION_SUCCESS;
}
static int
unbind_keyseq (seq)
char *seq;
{
char *kseq;
int kslen;
kseq = (char *)xmalloc ((2 * strlen (seq)) + 1);
if (rl_translate_keyseq (seq, kseq, &kslen))
{
free (kseq);
builtin_error (_("`%s': cannot unbind"), seq);
return EXECUTION_FAILURE;
}
if (rl_function_of_keyseq (kseq, (Keymap)0, (int *)0) == 0)
{
free (kseq);
return (EXECUTION_SUCCESS);
}
/* I wish this didn't have to translate the key sequence again, but readline
doesn't have a binding function that takes a translated key sequence as
an argument. */
if (rl_bind_keyseq (seq, (rl_command_func_t *)NULL) != 0)
{
free (kseq);
builtin_error (_("`%s': cannot unbind"), seq);
return (EXECUTION_FAILURE);
}
free (kseq);
return (EXECUTION_SUCCESS);
}
#endif /* READLINE */
+1 -3
View File
@@ -43,11 +43,9 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "common.h"
extern char *this_command_name;
extern int posixly_correct;
static int check_loop_level __P((void));
/* The depth of while's and until's. */
+5 -5
View File
@@ -1,7 +1,7 @@
This file is builtin.def, from which is created builtin.c.
It implements the builtin "builtin" in Bash.
Copyright (C) 1987-2009 Free Software Foundation, Inc.
Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -31,7 +31,7 @@ as a shell function, but need to execute the builtin within the function.
Exit Status:
Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
not a shell builtin..
not a shell builtin.
$END
#include <config.h>
@@ -43,11 +43,10 @@ $END
#endif
#include "../shell.h"
#include "../execute_cmd.h"
#include "common.h"
#include "bashgetopt.h"
extern char *this_command_name;
/* Run the command mentioned in list directly, without going through the
normal alias/function/builtin/filename lookup process. */
int
@@ -71,7 +70,7 @@ builtin_builtin (list)
function = find_shell_builtin (command);
#endif /* !DISABLED_BUILTINS */
if (!function)
if (function == 0)
{
sh_notbuiltin (command);
return (EXECUTION_FAILURE);
@@ -79,6 +78,7 @@ builtin_builtin (list)
else
{
this_command_name = command;
this_shell_builtin = function; /* overwrite "builtin" as this builtin */
list = list->next;
return ((*function) (list));
}
+1 -4
View File
@@ -54,8 +54,6 @@ $PRODUCES cd.c
extern int errno;
#endif /* !errno */
extern int posixly_correct;
extern int array_needs_making;
extern const char * const bash_getcwd_errstr;
static int bindpwd __P((int));
@@ -547,7 +545,7 @@ change_to_directory (newdir, nolinks, xattr)
int nolinks, xattr;
{
char *t, *tdir, *ndir;
int err, canon_failed, r, ndlen, dlen;
int err, canon_failed, r, ndlen;
tdir = (char *)NULL;
@@ -566,7 +564,6 @@ change_to_directory (newdir, nolinks, xattr)
: sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
ndlen = strlen (newdir);
dlen = strlen (t);
/* Use the canonicalized version of NEWDIR, or, if canonicalization
failed, use the non-canonical form. */
-22
View File
@@ -60,10 +60,6 @@ $END
extern size_t confstr __P((int, char *, size_t));
#endif
extern int subshell_environment;
static void restore_path __P((char *));
/* Run the commands mentioned in LIST without paying attention to shell
functions. */
int
@@ -71,7 +67,6 @@ command_builtin (list)
WORD_LIST *list;
{
int result, verbose, use_standard_path, opt;
char *old_path, *standard_path;
COMMAND *command;
verbose = use_standard_path = 0;
@@ -144,20 +139,3 @@ command_builtin (list)
return (result);
}
/* Restore the value of the $PATH variable after replacing it when
executing `command -p'. */
static void
restore_path (var)
char *var;
{
if (var)
{
bind_variable ("PATH", var, 0);
free (var);
}
else
unbind_variable ("PATH");
stupidly_hack_special_variables ("PATH");
}
+4 -14
View File
@@ -1,6 +1,6 @@
/* common.c - utility functions for all builtins */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,6 +49,7 @@
#include "../shell.h"
#include "maxpath.h"
#include "../flags.h"
#include "../parser.h"
#include "../jobs.h"
#include "../builtins.h"
#include "../input.h"
@@ -67,13 +68,6 @@
extern int errno;
#endif /* !errno */
extern int indirection_level, subshell_environment;
extern int line_number;
extern int last_command_exit_value;
extern int trap_saved_exit_value;
extern int running_trap;
extern int posixly_correct;
extern char *this_command_name, *shell_name;
extern const char * const bash_getcwd_errstr;
/* Used by some builtins and the mainline code. */
@@ -543,7 +537,7 @@ read_octal (string)
{
digits++;
result = (result * 8) + (*string++ - '0');
if (result > 0777)
if (result > 07777)
return -1;
}
@@ -782,13 +776,9 @@ display_signal_list (list, forcecols)
list = list->next;
continue;
}
#if defined (JOB_CONTROL)
/* POSIX.2 says that `kill -l signum' prints the signal name without
the `SIG' prefix. */
printf ("%s\n", (this_shell_builtin == kill_builtin) ? name + 3 : name);
#else
printf ("%s\n", name);
#endif
printf ("%s\n", (this_shell_builtin == kill_builtin && signum > 0) ? name + 3 : name);
}
else
{
+28 -2
View File
@@ -23,7 +23,7 @@
#include "stdc.h"
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
#define ISOPTION(s, c) (s[0] == '-' && s[1] == c && !s[2])
#define ISHELP(s) (STREQ ((s), "--help"))
#define CHECK_HELPOPT(l) \
@@ -200,10 +200,11 @@ extern WORD_LIST *get_directory_stack __P((int));
/* Functions from evalstring.c */
extern int parse_and_execute __P((char *, const char *, int));
extern int evalstring __P((char *, const char *, int));
extern void parse_and_execute_cleanup __P((void));
extern void parse_and_execute_cleanup __P((int));
extern int parse_string __P((char *, const char *, int, char **));
extern int should_suppress_fork __P((COMMAND *));
extern void optimize_fork __P((COMMAND *));
extern void optimize_subshell_command __P((COMMAND *));
/* Functions from evalfile.c */
extern int maybe_execute_file __P((const char *, int));
@@ -211,4 +212,29 @@ extern int force_execute_file __P((const char *, int));
extern int source_file __P((const char *, int));
extern int fc_execute_file __P((const char *));
/* variables from common.c */
extern sh_builtin_func_t *this_shell_builtin;
extern sh_builtin_func_t *last_shell_builtin;
/* variables from evalfile.c */
extern int sourcelevel;
/* variables from evalstring.c */
extern int parse_and_execute_level;
/* variables from break.def/continue.def */
extern int breaking;
extern int continuing;
extern int loop_level;
/* variables from read.def */
extern int sigalrm_seen;
/* variables from source.def */
extern int source_searches_cwd;
extern int source_uses_path;
/* variables from wait.def */
extern int wait_intr_flag;
#endif /* !__COMMON_H */
+16
View File
@@ -515,6 +515,8 @@ print_one_completion (cmd, cs)
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
PRINTCOMPOPT (COPT_NOQUOTE, "noquote");
PRINTCOMPOPT (COPT_NOSORT, "nosort");
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
@@ -589,6 +591,8 @@ print_compopts (cmd, cs, full)
XPRINTCOMPOPT (COPT_DEFAULT, "default");
XPRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
XPRINTCOMPOPT (COPT_FILENAMES, "filenames");
XPRINTCOMPOPT (COPT_NOQUOTE, "noquote");
XPRINTCOMPOPT (COPT_NOSORT, "nosort");
XPRINTCOMPOPT (COPT_NOSPACE, "nospace");
XPRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
}
@@ -598,6 +602,8 @@ print_compopts (cmd, cs, full)
PRINTCOMPOPT (COPT_DEFAULT, "default");
PRINTCOMPOPT (COPT_DIRNAMES, "dirnames");
PRINTCOMPOPT (COPT_FILENAMES, "filenames");
PRINTCOMPOPT (COPT_NOQUOTE, "noquote");
PRINTCOMPOPT (COPT_NOSORT, "nosort");
PRINTCOMPOPT (COPT_NOSPACE, "nospace");
PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs");
}
@@ -675,6 +681,8 @@ compgen_builtin (list)
COMPSPEC *cs;
STRINGLIST *sl;
char *word, **matches;
char *old_line;
int old_ind;
if (list == 0)
return (EXECUTION_SUCCESS);
@@ -715,7 +723,15 @@ compgen_builtin (list)
cs->filterpat = STRDUP (Xarg);
rval = EXECUTION_FAILURE;
/* probably don't have to save these, just being safe */
old_line = pcomp_line;
old_ind = pcomp_ind;
pcomp_line = (char *)NULL;
pcomp_ind = 0;
sl = gen_compspec_completions (cs, "compgen", word, 0, 0, 0);
pcomp_line = old_line;
pcomp_ind = old_ind;
/* If the compspec wants the bash default completions, temporarily
turn off programmable completion and call the bash completion code. */
+78 -24
View File
@@ -40,11 +40,11 @@ Options which set attributes:
-a to make NAMEs indexed arrays (if supported)
-A to make NAMEs associative arrays (if supported)
-i to make NAMEs have the `integer' attribute
-l to convert NAMEs to lower case on assignment
-l to convert the value of each NAME to lower case on assignment
-n make NAME a reference to the variable named by its value
-r to make NAMEs readonly
-t to make NAMEs have the `trace' attribute
-u to convert NAMEs to upper case on assignment
-u to convert the value of each NAME to upper case on assignment
-x to make NAMEs export
Using `+' instead of `-' turns off the given attribute.
@@ -88,9 +88,7 @@ $END
#include "builtext.h"
#include "bashgetopt.h"
extern int array_needs_making;
extern int posixly_correct;
static SHELL_VAR *declare_find_variable __P((const char *, int, int));
static int declare_internal __P((register WORD_LIST *, int));
/* Declare or change variable attributes. */
@@ -120,6 +118,13 @@ int
local_builtin (list)
register WORD_LIST *list;
{
/* Catch a straight `local --help' before checking function context */
if (list && list->word && STREQ (list->word->word, "--help"))
{
builtin_help ();
return (EX_USAGE);
}
if (variable_context)
return (declare_internal (list, 1));
else
@@ -130,11 +135,31 @@ local_builtin (list)
}
#if defined (ARRAY_VARS)
# define DECLARE_OPTS "+acfgilnprtuxAF"
# define DECLARE_OPTS "+acfgilnprtuxAFG"
#else
# define DECLARE_OPTS "+cfgilnprtuxF"
# define DECLARE_OPTS "+cfgilnprtuxFG"
#endif
static SHELL_VAR *
declare_find_variable (name, mkglobal, chklocal)
const char *name;
int mkglobal, chklocal;
{
SHELL_VAR *var;
if (mkglobal == 0)
return (find_variable (name));
else if (chklocal)
{
var = find_variable (name);
if (var && local_p (var) && var->context == variable_context)
return var;
return (find_global_variable (name));
}
else
return (find_global_variable (name));
}
/* The workhorse function. */
static int
declare_internal (list, local_var)
@@ -142,12 +167,14 @@ declare_internal (list, local_var)
int local_var;
{
int flags_on, flags_off, *flags;
int any_failed, assign_error, pflag, nodefs, opt, mkglobal, onref, offref;
int any_failed, assign_error, pflag, nodefs, opt, onref, offref;
int mkglobal, chklocal;
char *t, *subscript_start;
SHELL_VAR *var, *refvar, *v;
FUNCTION_DEF *shell_fn;
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0;
flags_on = flags_off = any_failed = assign_error = pflag = nodefs = 0;
mkglobal = chklocal = 0;
refvar = (SHELL_VAR *)NULL;
reset_internal_getopt ();
while ((opt = internal_getopt (list, DECLARE_OPTS)) != -1)
@@ -185,6 +212,10 @@ declare_internal (list, local_var)
case 'f':
*flags |= att_function;
break;
case 'G':
if (flags == &flags_on)
chklocal = 1;
/*FALLTHROUGH*/
case 'g':
if (flags == &flags_on)
mkglobal = 1;
@@ -288,6 +319,7 @@ declare_internal (list, local_var)
{
char *value, *name, *oldname;
int offset, aflags, wflags, created_var, namelen;
int assoc_noexpand;
#if defined (ARRAY_VARS)
int making_array_special, compound_array_assign, simple_array_assign;
int var_exists, array_exists, creating_array, array_subscript_assignment;
@@ -295,13 +327,18 @@ declare_internal (list, local_var)
name = savestring (list->word->word);
wflags = list->word->flags;
offset = assignment (name, 0);
#if defined (ARRAY_VARS)
assoc_noexpand = assoc_expand_once && (wflags & W_ASSIGNMENT);
#else
assoc_noexpand = 0;
#endif
offset = assignment (name, assoc_noexpand ? 2 : 0);
aflags = 0;
created_var = 0;
if (local_var && variable_context && STREQ (name, "-"))
{
var = make_local_variable ("-");
var = make_local_variable ("-", 0);
FREE (value_cell (var)); /* just in case */
value = get_current_options ();
var_setvalue (var, value);
@@ -363,7 +400,7 @@ restart_new_var_name:
compound_array_assign = simple_array_assign = 0;
array_subscript_assignment = 0;
subscript_start = (char *)NULL;
if (t = strchr (name, '[')) /* ] */
if ((t = strchr (name, '[')) && (flags_on & att_function) == 0) /* ] */
{
/* If offset != 0 we have already validated any array reference
because assignment() calls skipsubscript() */
@@ -423,18 +460,18 @@ restart_new_var_name:
if (refvar && refvar->context != variable_context)
{
refvar = 0;
var = make_local_variable (name);
var = make_local_variable (name, 0);
}
else if (refvar && refvar->context == variable_context)
var = refvar;
/* Maybe we just want to create a new local variable */
else if (var == 0 || var->context != variable_context)
var = make_local_variable (name);
var = make_local_variable (name, 0);
/* otherwise we have a var at the right context */
}
else
/* XXX - check name for validity here with valid_nameref_value */
var = make_local_variable (name); /* sets att_invisible for new vars */
var = make_local_variable (name, 0); /* sets att_invisible for new vars */
if (var == 0)
{
any_failed++;
@@ -528,21 +565,17 @@ restart_new_var_name:
#endif
if (var == 0 && (flags_on & att_nameref))
{
#if 0
/* See if we are trying to modify an existing nameref variable */
var = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1);
#else
/* See if we are trying to modify an existing nameref variable,
but don't follow the nameref chain. */
var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name);
#endif
if (var && nameref_p (var) == 0)
var = 0;
}
/* However, if we're turning off the nameref attribute on an existing
nameref variable, we first follow the nameref chain to the end,
modify the value of the variable this nameref variable references,
*CHANGING ITS VALUE AS A SIDE EFFECT* then turn off the nameref
modify the value of the variable this nameref variable references
if there is an assignment statement argument,
*CHANGING ITS VALUE AS A SIDE EFFECT*, then turn off the nameref
flag *LEAVING THE NAMEREF VARIABLE'S VALUE UNCHANGED* */
else if (var == 0 && (flags_off & att_nameref))
{
@@ -560,7 +593,18 @@ restart_new_var_name:
any_failed++;
NEXT_VARIABLE ();
}
/* If all we're doing is turning off the nameref attribute, don't
bother with VAR at all, whether it exists or not. Just turn it
off and go on. */
if (refvar && flags_on == 0 && offset == 0 && (flags_off & ~att_nameref) == 0)
{
VUNSETATTR (refvar, att_nameref);
NEXT_VARIABLE ();
}
if (refvar)
/* XXX - use declare_find_variable here? */
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
}
#if defined (ARRAY_VARS)
@@ -592,6 +636,7 @@ restart_new_var_name:
if (refvar && nameref_p (refvar) == 0)
refvar = 0;
if (refvar)
/* XXX - use declare_find_variable here? */
var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar));
if (refvar && var == 0)
{
@@ -637,12 +682,18 @@ restart_new_var_name:
value = name + namelen;
}
free (oldname);
/* OK, let's turn off the nameref attribute.
Now everything else applies to VAR. */
if (flags_off & att_nameref)
VUNSETATTR (refvar, att_nameref);
goto restart_new_var_name;
/* NOTREACHED */
}
}
if (var == 0)
var = mkglobal ? find_global_variable (name) : find_variable (name);
var = declare_find_variable (name, mkglobal, chklocal);
#if defined (ARRAY_VARS)
var_exists = var != 0;
@@ -821,10 +872,13 @@ restart_new_var_name:
assign_array_var_from_string (var, value, aflags|ASS_FORCE);
else if (simple_array_assign && subscript_start)
{
int local_aflags;
/* declare [-aA] name[N]=value */
*subscript_start = '['; /* ] */
/* XXX - problem here with appending */
var = assign_array_element (name, value, aflags&ASS_APPEND); /* XXX - not aflags */
local_aflags = aflags&ASS_APPEND;
local_aflags |= assoc_noexpand ? ASS_NOEXPAND : 0;
var = assign_array_element (name, value, local_aflags); /* XXX - not aflags */
*subscript_start = '\0';
if (var == 0) /* some kind of assignment error */
{
-2
View File
@@ -99,8 +99,6 @@ int xpg_echo = 1;
int xpg_echo = 0;
#endif /* DEFAULT_ECHO_TO_XPG */
extern int posixly_correct;
/* Print the words in LIST to standard output. If the first word is
`-n', then don't print a trailing newline. We also support the
echo syntax from Version 9 Unix systems. */
+7 -11
View File
@@ -1,6 +1,6 @@
/* evalfile.c - read and evaluate commands from a file or file descriptor */
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -36,6 +36,7 @@
#include "../bashintl.h"
#include "../shell.h"
#include "../parser.h"
#include "../jobs.h"
#include "../builtins.h"
#include "../flags.h"
@@ -68,13 +69,6 @@ extern int errno;
#define FEVAL_REGFILE 0x080
#define FEVAL_NOPUSHARGS 0x100
extern int posixly_correct;
extern int indirection_level, subshell_environment;
extern int return_catch_flag, return_catch_value;
extern int last_command_exit_value;
extern int executing_command_builtin;
extern int current_token; /* parse.y */
/* How many `levels' of sourced files we have. */
int sourcelevel = 0;
@@ -92,7 +86,7 @@ _evalfile (filename, flags)
size_t file_size;
sh_vmsg_func_t *errfunc;
#if defined (ARRAY_VARS)
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v;
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
struct func_array_state *fa;
# if defined (DEBUGGER)
@@ -260,7 +254,9 @@ file_error_and_exit:
arguments */
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
array_push (bash_argv_a, (char *)filename);
if (shell_compatibility_level <= 44)
init_bash_argv ();
array_push (bash_argv_a, (char *)filename); /* XXX - unconditionally? */
tt[0] = '1'; tt[1] = '\0';
array_push (bash_argc_a, tt);
if (flags & FEVAL_UNWINDPROT)
@@ -282,7 +278,7 @@ file_error_and_exit:
force parse_and_execute () to clean up. */
if (return_val)
{
parse_and_execute_cleanup ();
parse_and_execute_cleanup (-1);
result = return_catch_value;
}
else
+39 -18
View File
@@ -1,6 +1,6 @@
/* evalstring.c - evaluate a string as one or more shell commands. */
/* Copyright (C) 1996-2015 Free Software Foundation, Inc.
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -39,6 +39,7 @@
#include "../jobs.h"
#include "../builtins.h"
#include "../flags.h"
#include "../parser.h"
#include "../input.h"
#include "../execute_cmd.h"
#include "../redir.h"
@@ -60,19 +61,6 @@ extern int errno;
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
extern int indirection_level, subshell_environment;
extern int line_number, line_number_for_err_trap;
extern int current_token, shell_eof_token;
extern int last_command_exit_value;
extern int running_trap;
extern int loop_level;
extern int executing_list;
extern int comsub_ignore_return;
extern int posixly_correct;
extern int return_catch_flag, return_catch_value;
extern sh_builtin_func_t *this_shell_builtin;
extern char *the_printed_command_except_trap;
int parse_and_execute_level = 0;
static int cat_file __P((REDIRECT *));
@@ -124,14 +112,41 @@ optimize_fork (command)
command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK;
}
}
void
optimize_subshell_command (command)
COMMAND *command;
{
if (running_trap == 0 &&
command->type == cm_simple &&
signal_is_trapped (EXIT_TRAP) == 0 &&
signal_is_trapped (ERROR_TRAP) == 0 &&
any_signals_trapped () < 0 &&
command->redirects == 0 && command->value.Simple->redirects == 0 &&
((command->flags & CMD_TIME_PIPELINE) == 0) &&
((command->flags & CMD_INVERT_RETURN) == 0))
{
command->flags |= CMD_NO_FORK;
command->value.Simple->flags |= CMD_NO_FORK;
}
else if (command->type == cm_connection &&
(command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR))
optimize_subshell_command (command->value.Connection->second);
}
/* How to force parse_and_execute () to clean up after itself. */
void
parse_and_execute_cleanup ()
parse_and_execute_cleanup (old_running_trap)
int old_running_trap;
{
if (running_trap)
if (running_trap > 0)
{
run_trap_cleanup (running_trap - 1);
/* We assume if we have a different value for running_trap than when
we started (the only caller that cares is evalstring()), the
original caller will perform the cleanup, and we should not step
on them. */
if (running_trap != old_running_trap)
run_trap_cleanup (running_trap - 1);
unfreeze_jobs_list ();
}
@@ -644,6 +659,10 @@ evalstring (string, from_file, flags)
int flags;
{
volatile int r, rflag, rcatch;
volatile int was_trap;
/* Are we running a trap when we execute this function? */
was_trap = running_trap;
rcatch = 0;
rflag = return_catch_flag;
@@ -663,7 +682,9 @@ evalstring (string, from_file, flags)
if (rcatch)
{
parse_and_execute_cleanup ();
/* We care about whether or not we are running the same trap we were
when we entered this function. */
parse_and_execute_cleanup (was_trap);
r = return_catch_value;
}
else
+5 -3
View File
@@ -74,7 +74,6 @@ $END
extern int errno;
#endif /* !errno */
extern int subshell_environment;
extern REDIRECT *redirection_undo_list;
extern char *exec_argv0;
@@ -190,8 +189,11 @@ exec_builtin (list)
/* Decrement SHLVL by 1 so a new shell started here has the same value,
preserving the appearance. After we do that, we need to change the
exported environment to include the new value. */
if (cleanenv == 0)
exported environment to include the new value. If we've already forked
and are in a subshell, we don't want to decrement the shell level,
since we are `increasing' the level */
if (cleanenv == 0 && (subshell_environment & SUBSHELL_PAREN) == 0)
adjust_shell_level (-1);
if (cleanenv)
+2 -5
View File
@@ -41,17 +41,14 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../jobs.h"
#include "../trap.h"
#include "common.h"
#include "builtext.h" /* for jobs_builtin */
extern int check_jobs_at_exit;
extern int last_command_exit_value;
extern int running_trap, trap_saved_exit_value;
extern int subshell_environment;
extern sh_builtin_func_t *this_shell_builtin;
extern sh_builtin_func_t *last_shell_builtin;
static int exit_or_logout __P((WORD_LIST *));
static int sourced_logout;
+2 -6
View File
@@ -75,6 +75,7 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../flags.h"
#include "../parser.h"
#include "../bashhist.h"
#include "maxpath.h"
#include <readline/history.h>
@@ -85,11 +86,6 @@ $END
extern int errno;
#endif /* !errno */
extern int current_command_line_count;
extern int literal_history;
extern int posixly_correct;
extern int subshell_environment, interactive_shell;
extern int unlink __P((const char *));
extern FILE *sh_mktmpfp __P((char *, int, char **));
@@ -463,7 +459,7 @@ fc_builtin (list)
/* Turn on the `v' flag while fc_execute_file runs so the commands
will be echoed as they are read by the parser. */
begin_unwind_frame ("fc builtin");
add_unwind_protect ((Function *)xfree, fn);
add_unwind_protect (xfree, fn);
add_unwind_protect (unlink, fn);
add_unwind_protect (set_verbose_flag, (char *)NULL);
echo_input_at_read = 1;
+1 -2
View File
@@ -46,13 +46,12 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../jobs.h"
#include "common.h"
#include "bashgetopt.h"
#if defined (JOB_CONTROL)
extern char *this_command_name;
static int fg_bg __P((WORD_LIST *, int));
/* How to bring a job into the foreground. */
+1 -2
View File
@@ -77,6 +77,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "common.h"
#include "bashgetopt.h"
#include "getopt.h"
@@ -85,8 +86,6 @@ $END
#define G_INVALID_OPT -2
#define G_ARG_MISSING -3
extern char *this_command_name;
static int getopts_unbind_variable __P((char *));
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
+17 -5
View File
@@ -61,15 +61,14 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../execute_cmd.h"
#include "../flags.h"
#include "../findcmd.h"
#include "../hashcmd.h"
#include "common.h"
#include "bashgetopt.h"
extern int posixly_correct;
extern int dot_found_in_search;
extern char *this_command_name;
static int add_hashed_command __P((char *, int));
static int print_hash_info __P((BUCKET_CONTENTS *));
@@ -149,10 +148,23 @@ hash_builtin (list)
return (list_hashed_filename_targets (list, list_portably));
#if defined (RESTRICTED_SHELL)
if (restricted && pathname && strchr (pathname, '/'))
if (restricted && pathname)
{
sh_restricted (pathname);
return (EXECUTION_FAILURE);
if (strchr (pathname, '/'))
{
sh_restricted (pathname);
return (EXECUTION_FAILURE);
}
/* If we are changing the hash table in a restricted shell, make sure the
target pathname can be found using a $PATH search. */
w = find_user_command (pathname);
if (w == 0 || *w == 0 || executable_file (w) == 0)
{
sh_notfound (pathname);
free (w);
return (EXECUTION_FAILURE);
}
free (w);
}
#endif
+7 -12
View File
@@ -37,7 +37,7 @@ Options:
PATTERN
Arguments:
PATTERN Pattern specifiying a help topic
PATTERN Pattern specifying a help topic
Exit Status:
Returns success unless PATTERN is not found or an invalid option is given.
@@ -64,6 +64,7 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../execute_cmd.h"
#include "../pathexp.h"
#include "common.h"
#include "bashgetopt.h"
@@ -78,9 +79,6 @@ extern int errno;
extern const char * const bash_copyright;
extern const char * const bash_license;
extern char *this_command_name;
extern struct builtin *current_builtin;
static void show_builtin_command_help __P((void));
static int open_helpfile __P((char *));
static void show_desc __P((char *, int));
@@ -132,7 +130,7 @@ help_builtin (list)
if (glob_pattern_p (list->word->word))
{
printf (ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));
printf ("%s", ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));
print_word_list (list, ", ");
printf ("'\n\n");
}
@@ -260,7 +258,7 @@ show_desc (name, i)
char *name;
int i;
{
register int j;
register int j, r;
char **doc, *line;
int fd, usefile;
@@ -272,8 +270,9 @@ show_desc (name, i)
fd = open_helpfile (doc[0]);
if (fd < 0)
return;
zmapfd (fd, &line, doc[0]);
r = zmapfd (fd, &line, doc[0]);
close (fd);
/* XXX - handle errors if zmapfd returns < 0 */
}
else
line = doc ? doc[0] : (char *)NULL;
@@ -421,7 +420,6 @@ wdispcolumn (i, buf, bufsize, width, height)
char *helpdoc;
wchar_t *wcstr;
size_t slen, n;
int wclen;
/* first column */
helpdoc = _(shell_builtins[i].short_doc);
@@ -531,10 +529,7 @@ Use `man -k' or `info' to find out more about commands not in this list.\n\
A star (*) next to a name means that the command is disabled.\n\
\n"));
t = get_string_value ("COLUMNS");
width = (t && *t) ? atoi (t) : 80;
if (width <= 0)
width = 80;
width = default_columns ();
width /= 2;
if (width > sizeof (blurb))
+80 -13
View File
@@ -1,7 +1,7 @@
This file is history.def, from which is created history.c.
It implements the builtin "history" in Bash.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -31,7 +31,8 @@ entry with a `*'. An argument of N lists only the last N entries.
Options:
-c clear the history list by deleting all of the entries
-d offset delete the history entry at position OFFSET.
-d offset delete the history entry at position OFFSET. Negative
offsets count back from the end of the history list
-a append history lines from this session to the history file
-n read all history lines not already read from the history file
@@ -74,6 +75,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../parser.h"
#include "../bashhist.h"
#include <readline/history.h>
#include "bashgetopt.h"
@@ -83,9 +85,6 @@ $END
extern int errno;
#endif
extern int current_command_line_count;
extern int force_append_history; /* shopt -s histappend */
static char *histtime __P((HIST_ENTRY *, const char *));
static int display_history __P((WORD_LIST *));
static void push_history __P((WORD_LIST *));
@@ -104,8 +103,8 @@ int
history_builtin (list)
WORD_LIST *list;
{
int flags, opt, result, old_history_lines, obase;
char *filename, *delete_arg;
int flags, opt, result, old_history_lines, obase, ind;
char *filename, *delete_arg, *range;
intmax_t delete_offset;
flags = 0;
@@ -178,16 +177,82 @@ history_builtin (list)
return (sh_chkwrite (EXECUTION_SUCCESS));
}
#endif
else if ((flags & DFLAG) && (range = strchr ((delete_arg[0] == '-') ? delete_arg + 1 : delete_arg, '-')))
{
intmax_t delete_start, delete_end;
*range++ = '\0';
if (legal_number (delete_arg, &delete_start) == 0 || legal_number (range, &delete_end) == 0)
{
range[-1] = '-';
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
}
if (delete_arg[0] == '-' && delete_start < 0)
{
/* the_history[history_length] == 0x0, so this is correct */
delete_start += history_length;
if (delete_start < history_base)
{
start_error:
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
}
}
/* numbers as displayed by display_history are offset by history_base */
else if (delete_start > 0)
delete_start -= history_base;
if (delete_start < 0 || delete_start >= history_length)
goto start_error;
if (range[0] == '-' && delete_end < 0)
{
delete_end += history_length;
if (delete_end < history_base)
{
range_error:
sh_erange (range, _("history position"));
return (EXECUTION_FAILURE);
}
}
else if (delete_end > 0)
delete_end -= history_base;
if (delete_end < 0 || delete_end >= history_length)
goto range_error;
result = bash_delete_history_range (delete_start, delete_end);
if (where_history () > history_length)
history_set_pos (history_length);
return (result ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
}
else if (flags & DFLAG)
{
if ((legal_number (delete_arg, &delete_offset) == 0)
|| (delete_offset < history_base)
|| (delete_offset > (history_base + history_length)))
if (legal_number (delete_arg, &delete_offset) == 0)
{
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
}
opt = delete_offset;
/* check for negative offsets, count back from end of list */
if (delete_arg[0] == '-' && delete_offset < 0)
{
/* since the_history[history_length] == 0x0, this calculation means
that history -d -1 will delete the last history entry, which at
this point is the history -d -1 we just added. */
ind = history_length + delete_offset;
if (ind < history_base)
{
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
}
opt = ind + history_base; /* compensate for opt - history_base below */
}
else if ((delete_offset < history_base) || (delete_offset > (history_base + history_length)))
{
sh_erange (delete_arg, _("history position"));
return (EXECUTION_FAILURE);
}
else
opt = delete_offset;
/* Positive arguments from numbers as displayed by display_history need
to be offset by history_base */
result = bash_delete_histent (opt - history_base);
/* Since remove_history changes history_length, this can happen if
we delete the last history entry. */
@@ -256,10 +321,12 @@ histtime (hlist, histtimefmt)
{
static char timestr[128];
time_t t;
struct tm *tm;
t = history_get_time (hlist);
if (t)
strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t));
tm = t ? localtime (&t) : 0;
if (t && tm)
strftime (timestr, sizeof (timestr), histtimefmt, tm);
else if (hlist->timestamp && hlist->timestamp[0])
snprintf (timestr, sizeof (timestr), _("%s: invalid timestamp"),
(hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp);
-2
View File
@@ -70,8 +70,6 @@ $END
extern int errno;
#endif /* !errno */
extern int posixly_correct;
static void kill_error __P((pid_t, int));
#if !defined (CONTINUE_AFTER_KILL_ERROR)
+2 -2
View File
@@ -100,7 +100,7 @@ let_builtin (list)
for (; list; list = list->next)
{
ret = evalexp (list->word->word, &expok);
ret = evalexp (list->word->word, EXP_EXPANDED, &expok);
if (expok == 0)
return (EXECUTION_FAILURE);
}
@@ -124,7 +124,7 @@ exp_builtin (list)
}
exp = string_list (list);
ret = evalexp (exp, &expok);
ret = evalexp (exp, EXP_EXPANDED, &expok);
(void)free (exp);
return (((ret == 0) || (expok == 0)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
+3 -4
View File
@@ -59,7 +59,7 @@ $END
$BUILTIN readarray
$FUNCTION mapfile_builtin
$SHORT_DOC readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
$SHORT_DOC readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
Read lines from a file into an array variable.
A synonym for `mapfile'.
@@ -232,7 +232,7 @@ mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_n
break;
}
xfree (line);
free (line);
if (unbuffered_read == 0)
zsyncfd (fd);
@@ -244,12 +244,11 @@ int
mapfile_builtin (list)
WORD_LIST *list;
{
int opt, code, fd, clear_array, flags;
int opt, code, fd, flags;
intmax_t intval;
long lines, origin, nskip, callback_quantum;
char *array_name, *callback;
clear_array = 1;
fd = 0;
lines = origin = nskip = 0;
flags = MAPF_CLEARARRAY;
+23 -18
View File
@@ -1,7 +1,7 @@
This file is printf.def, from which is created printf.c.
It implements the builtin "printf" in Bash.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
Copyright (C) 1997-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -148,8 +148,11 @@ extern int errno;
QUIT; \
if (vflag) \
{ \
bind_printf_variable (vname, vbuf, 0); \
SHELL_VAR *v; \
v = bind_printf_variable (vname, vbuf, 0); \
stupidly_hack_special_variables (vname); \
if (v == 0 || readonly_p (v) || noassign_p (v)) \
return (EXECUTION_FAILURE); \
} \
if (conv_bufsize > 4096 ) \
{ \
@@ -258,7 +261,7 @@ printf_builtin (list)
case 'v':
vname = list_optarg;
#if defined (ARRAY_VARS)
if (legal_identifier (vname) || valid_array_reference (vname, 0))
if (legal_identifier (vname) || valid_array_reference (vname, assoc_expand_once))
#else
if (legal_identifier (vname))
#endif
@@ -293,9 +296,10 @@ printf_builtin (list)
/* Allow printf -v var "" to act like var="" */
if (vflag && list->word->word && list->word->word[0] == '\0')
{
bind_printf_variable (vname, "", 0);
SHELL_VAR *v;
v = bind_printf_variable (vname, "", 0);
stupidly_hack_special_variables (vname);
return (EXECUTION_SUCCESS);
return ((v == 0 || readonly_p (v) || noassign_p (v)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
}
if (list->word->word == 0 || list->word->word[0] == '\0')
@@ -577,7 +581,7 @@ printf_builtin (list)
else if (ansic_shouldquote (p))
xp = ansic_quote (p, 0, (int *)0);
else
xp = sh_backslash_quote (p, 0, 1);
xp = sh_backslash_quote (p, 0, 3);
if (xp)
{
/* Use printstr to get fieldwidth and precision right. */
@@ -711,8 +715,8 @@ printstr (fmt, string, len, fieldwidth, precision)
int fw, pr; /* fieldwidth and precision */
intmax_t mfw, mpr;
if (string == 0 || len == 0)
return 0;
if (string == 0)
string = "";
#if 0
s = fmt;
@@ -955,7 +959,9 @@ bexpand (string, len, sawc, lenp)
*sawc = 0;
if (lenp)
*lenp = 0;
return ((char *)NULL);
ret = (char *)xmalloc (1);
ret[0] = '\0';
return (ret);
}
ret = (char *)xmalloc (len + 1);
@@ -1239,18 +1245,17 @@ asciicode ()
register intmax_t ch;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t mblength, slen;
size_t slen;
int mblength;
#endif
DECLARE_MBSTATE;
#if defined (HANDLE_MULTIBYTE)
slen = strlen (garglist->word->word+1);
mblength = MBLEN (garglist->word->word+1, slen);
if (mblength > 1)
{
mblength = mbtowc (&wc, garglist->word->word+1, slen);
ch = wc; /* XXX */
}
wc = 0;
mblength = mbtowc (&wc, garglist->word->word+1, slen);
if (mblength > 0)
ch = wc; /* XXX */
else
#endif
ch = (unsigned char)garglist->word->word[1];
@@ -1268,10 +1273,10 @@ bind_printf_variable (name, value, flags)
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, 0) == 0)
if (valid_array_reference (name, assoc_expand_once) == 0)
v = bind_variable (name, value, flags);
else
v = assign_array_element (name, value, flags);
v = assign_array_element (name, value, flags | (assoc_expand_once ? ASS_NOEXPAND : 0));
#else /* !ARRAY_VARS */
v = bind_variable (name, value, flags);
#endif /* !ARRAY_VARS */
+1 -1
View File
@@ -678,7 +678,7 @@ get_directory_stack (flags)
d = ".";
else
{
t = polite_directory_format (d);
t = (flags&1) ? polite_directory_format (d) : d;
/* polite_directory_format sometimes returns its argument unchanged.
If it does not, we can free d right away. If it does, we need to
mark d to be deleted later. */
+79 -49
View File
@@ -1,7 +1,7 @@
This file is read.def, from which is created read.c.
It implements the builtin "read" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -39,7 +39,7 @@ Options:
variable ARRAY, starting at zero
-d delim continue until the first character of DELIM is read, rather
than newline
-e use Readline to obtain the line in an interactive shell
-e use Readline to obtain the line
-i text use TEXT as the initial text for Readline
-n nchars return after reading NCHARS characters rather than waiting
for a newline, but honor a delimiter if fewer than
@@ -93,6 +93,7 @@ $END
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
#include "trap.h"
#include <shtty.h>
@@ -111,15 +112,10 @@ $END
extern int errno;
#endif
extern void run_pending_traps __P((void));
extern int posixly_correct;
extern int trapped_signal_received;
struct ttsave
{
int fd;
TTYSTRUCT *attrs;
TTYSTRUCT attrs;
};
#if defined (READLINE)
@@ -152,9 +148,8 @@ static struct ttsave termsave;
avoids problems with the semi-tricky stuff we do with the xfree of
input_string at the top of the unwind-protect list (see below). */
/* Set a flag that CHECK_ALRM can check. This relies on zread calling
trap.c:check_signals_and_traps(), which knows about sigalrm_seen and
alrmbuf. */
/* Set a flag that CHECK_ALRM can check. This relies on zread or read_builtin
calling trap.c:check_signals(), which knows about sigalrm_seen and alrmbuf. */
static sighandler
sigalrm (s)
int s;
@@ -181,10 +176,11 @@ read_builtin (list)
WORD_LIST *list;
{
register char *varname;
int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2;
int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag;
volatile int i;
int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
int raw, edit, nchars, silent, have_timeout, ignore_delim, fd, lastsig, t_errno;
int mb_cur_max;
unsigned int tmsec, tmusec;
long ival, uval;
intmax_t intval;
@@ -239,10 +235,11 @@ read_builtin (list)
rlind = 0;
#endif
mb_cur_max = MB_CUR_MAX;
tmsec = tmusec = 0; /* no timeout */
nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0;
delim = '\n'; /* read until newline */
ignore_delim = 0;
ignore_delim = nflag = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:N:")) != -1)
@@ -291,6 +288,7 @@ read_builtin (list)
ignore_delim = 1;
delim = -1;
case 'n':
nflag = 1;
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
@@ -338,7 +336,7 @@ read_builtin (list)
/* Convenience: check early whether or not the first of possibly several
variable names is a valid identifier, and bail early if so. */
#if defined (ARRAY_VARS)
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, assoc_expand_once) == 0)
#else
if (list && legal_identifier (list->word->word) == 0)
#endif
@@ -364,6 +362,14 @@ read_builtin (list)
input_string = (char *)xmalloc (size = 112); /* XXX was 128 */
input_string[0] = '\0';
/* More input and options validation */
if (nflag == 1 && nchars == 0)
{
retval = read (fd, &c, 0);
retval = (retval >= 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE;
goto assign_vars; /* bail early if asked to read 0 chars */
}
/* $TMOUT, if set, is the default timeout for read. */
if (have_timeout == 0 && (e = get_string_value ("TMOUT")))
{
@@ -384,7 +390,11 @@ read_builtin (list)
sync_buffered_stream (default_buffered_input);
#endif
#if 1
input_is_tty = isatty (fd);
#else
input_is_tty = 1;
#endif
if (input_is_tty == 0)
#ifndef __CYGWIN__
input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
@@ -484,7 +494,7 @@ read_builtin (list)
/* ttsave() */
termsave.fd = fd;
ttgetattr (fd, &ttattrs);
termsave.attrs = &ttattrs;
termsave.attrs = ttattrs;
ttset = ttattrs;
i = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset);
@@ -501,7 +511,7 @@ read_builtin (list)
/* ttsave (); */
termsave.fd = fd;
ttgetattr (fd, &ttattrs);
termsave.attrs = &ttattrs;
termsave.attrs = ttattrs;
ttset = ttattrs;
i = ttfd_noecho (fd, &ttset); /* ttnoecho (); */
@@ -544,7 +554,7 @@ read_builtin (list)
{
if (rlbuf && rlbuf[rlind] == '\0')
{
xfree (rlbuf);
free (rlbuf);
rlbuf = (char *)0;
}
if (rlbuf == 0)
@@ -574,11 +584,8 @@ read_builtin (list)
print_ps2 = 0;
}
#if 0
if (posixly_correct == 0)
interrupt_immediately++;
#endif
reading = 1;
CHECK_ALRM;
if (unbuffered_read == 2)
retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr);
else if (unbuffered_read)
@@ -586,15 +593,12 @@ read_builtin (list)
else
retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c);
reading = 0;
#if 0
if (posixly_correct == 0)
interrupt_immediately--;
#endif
if (retval <= 0)
{
if (retval < 0 && errno == EINTR)
{
check_signals (); /* in case we didn't call zread via zreadc */
lastsig = LASTSIG();
if (lastsig == 0)
lastsig = trapped_signal_received;
@@ -609,14 +613,16 @@ read_builtin (list)
break;
}
CHECK_ALRM;
QUIT; /* in case we didn't call check_signals() */
#if defined (READLINE)
}
#endif
CHECK_ALRM;
if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */
if (retval <= 0) /* XXX shouldn't happen */
CHECK_ALRM;
/* XXX -- use i + mb_cur_max (at least 4) for multibyte/read_mbchar */
if (i + (mb_cur_max > 4 ? mb_cur_max : 4) >= size)
{
char *t;
t = (char *)xrealloc (input_string, size += 128);
@@ -637,7 +643,8 @@ read_builtin (list)
pass_next = 0;
if (c == '\n')
{
i--; /* back up over the CTLESC */
if (skip_ctlesc == 0 && i > 0)
i--; /* back up over the CTLESC */
if (interactive && input_is_tty && raw == 0)
print_ps2 = 1;
}
@@ -675,10 +682,30 @@ add_char:
CHECK_ALRM;
#if defined (HANDLE_MULTIBYTE)
if (nchars > 0 && MB_CUR_MAX > 1 && is_basic (c) == 0)
/* XXX - what if C == 127? Can DEL introduce a multibyte sequence? */
if (mb_cur_max > 1 && is_basic (c) == 0)
{
input_string[i] = '\0'; /* for simplicity and debugging */
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
/* If we got input from readline, grab the next multibyte char from
rlbuf. */
# if defined (READLINE)
if (edit)
{
size_t clen;
clen = mbrlen (rlbuf + rlind - 1, mb_cur_max, (mbstate_t *)NULL);
/* We only deal with valid multibyte sequences longer than one
byte. If we get anything else, we leave the one character
copied and move on to the next. */
if ((int)clen > 1)
{
memcpy (input_string+i, rlbuf+rlind, clen-1);
i += clen - 1;
rlind += clen - 1;
}
}
else
# endif
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
}
#endif
@@ -742,20 +769,20 @@ assign_vars:
if (legal_identifier (arrayname) == 0)
{
sh_invalidid (arrayname);
xfree (input_string);
free (input_string);
return (EXECUTION_FAILURE);
}
var = find_or_make_array_variable (arrayname, 1);
if (var == 0)
{
xfree (input_string);
free (input_string);
return EXECUTION_FAILURE; /* readonly or noassign */
}
if (assoc_p (var))
{
builtin_error (_("%s: cannot convert associative to indexed array"), arrayname);
xfree (input_string);
free (input_string);
return EXECUTION_FAILURE; /* existing associative array */
}
else if (invisible_p (var))
@@ -772,7 +799,7 @@ assign_vars:
assign_array_var_from_word_list (var, alist, 0);
dispose_words (alist);
}
xfree (input_string);
free (input_string);
return (retval);
}
#endif /* ARRAY_VARS */
@@ -808,7 +835,7 @@ assign_vars:
else
VUNSETATTR (var, att_invisible);
xfree (input_string);
free (input_string);
return (retval);
}
@@ -825,13 +852,13 @@ assign_vars:
{
varname = list->word->word;
#if defined (ARRAY_VARS)
if (legal_identifier (varname) == 0 && valid_array_reference (varname, 0) == 0)
if (legal_identifier (varname) == 0 && valid_array_reference (varname, assoc_expand_once) == 0)
#else
if (legal_identifier (varname) == 0)
#endif
{
sh_invalidid (varname);
xfree (orig_input_string);
free (orig_input_string);
return (EXECUTION_FAILURE);
}
@@ -849,7 +876,7 @@ assign_vars:
{
t1 = dequote_string (t);
var = bind_read_variable (varname, t1);
xfree (t1);
free (t1);
}
else
var = bind_read_variable (varname, t ? t : "");
@@ -863,7 +890,7 @@ assign_vars:
FREE (t);
if (var == 0)
{
xfree (orig_input_string);
free (orig_input_string);
return (EXECUTION_FAILURE);
}
@@ -873,13 +900,13 @@ assign_vars:
/* Now assign the rest of the line to the last variable argument. */
#if defined (ARRAY_VARS)
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0)
if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, assoc_expand_once) == 0)
#else
if (legal_identifier (list->word->word) == 0)
#endif
{
sh_invalidid (list->word->word);
xfree (orig_input_string);
free (orig_input_string);
return (EXECUTION_FAILURE);
}
@@ -910,7 +937,7 @@ assign_vars:
{
t = dequote_string (input_string);
var = bind_read_variable (list->word->word, t);
xfree (t);
free (t);
}
else
var = bind_read_variable (list->word->word, input_string ? input_string : "");
@@ -924,7 +951,7 @@ assign_vars:
retval = EXECUTION_FAILURE;
FREE (tofree);
xfree (orig_input_string);
free (orig_input_string);
return (retval);
}
@@ -936,10 +963,10 @@ bind_read_variable (name, value)
SHELL_VAR *v;
#if defined (ARRAY_VARS)
if (valid_array_reference (name, 0) == 0)
if (valid_array_reference (name, assoc_expand_once) == 0)
v = bind_variable (name, value, 0);
else
v = assign_array_element (name, value, 0);
v = assign_array_element (name, value, assoc_expand_once ? ASS_NOEXPAND : 0);
#else /* !ARRAY_VARS */
v = bind_variable (name, value, 0);
#endif /* !ARRAY_VARS */
@@ -973,12 +1000,15 @@ read_mbchar (fd, string, ind, ch, unbuffered)
if (ret == (size_t)-2)
{
ps = ps_back;
/* We don't want to be interrupted during a multibyte char read */
if (unbuffered)
if (unbuffered == 2)
r = zreadn (fd, &c, 1);
else if (unbuffered)
r = zread (fd, &c, 1);
else
r = zreadc (fd, &c);
if (r < 0)
if (r <= 0)
goto mbchar_return;
mbchar[i++] = c;
continue;
@@ -1001,7 +1031,7 @@ static void
ttyrestore (ttp)
struct ttsave *ttp;
{
ttsetattr (ttp->fd, ttp->attrs);
ttsetattr (ttp->fd, &(ttp->attrs));
tty_modified = 0;
}
+1 -4
View File
@@ -46,13 +46,10 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "common.h"
#include "bashgetopt.h"
extern int last_command_exit_value;
extern int subshell_environment;
extern int return_catch_flag, return_catch_value;
/* If we are executing a user-defined function then exit with the value
specified as an argument. if no argument is given, then the last
exit status is used. */
+5 -12
View File
@@ -35,6 +35,7 @@ $PRODUCES set.c
#include "../bashintl.h"
#include "../shell.h"
#include "../parser.h"
#include "../flags.h"
#include "common.h"
#include "bashgetopt.h"
@@ -49,14 +50,6 @@ $PRODUCES set.c
# include "../bashhist.h"
#endif
extern int posixly_correct, ignoreeof, eof_encountered_limit;
#if defined (HISTORY)
extern int dont_save_function_defs;
#endif
#if defined (READLINE)
extern int no_line_editing;
#endif /* READLINE */
$BUILTIN set
$FUNCTION set_builtin
$SHORT_DOC set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
@@ -859,7 +852,7 @@ unset_builtin (list)
#if defined (ARRAY_VARS)
unset_array = 0;
if (!unset_function && nameref == 0 && valid_array_reference (name, 0))
if (!unset_function && nameref == 0 && valid_array_reference (name, assoc_expand_once)) /* XXX valid array reference second arg was 0 */
{
t = strchr (name, '[');
*t++ = '\0';
@@ -916,7 +909,7 @@ unset_builtin (list)
if (var && unset_array)
{
/* Let unbind_array_element decide what to do with non-array vars */
tem = unbind_array_element (var, t);
tem = unbind_array_element (var, t, assoc_expand_once); /* XXX new third arg */
if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0)
{
builtin_error (_("%s: not an array variable"), var->name);
@@ -938,8 +931,8 @@ unset_builtin (list)
if (valid_array_reference (nameref_cell (var), 0))
{
tname = savestring (nameref_cell (var));
if (var = array_variable_part (tname, &t, 0))
tem = unbind_array_element (var, t);
if (var = array_variable_part (tname, 0, &t, (int *)0))
tem = unbind_array_element (var, t, assoc_expand_once); /* XXX new third arg */
free (tname);
}
else
+2 -4
View File
@@ -34,13 +34,11 @@ $PRODUCES setattr.c
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../flags.h"
#include "common.h"
#include "bashgetopt.h"
extern int posixly_correct;
extern int array_needs_making;
extern char *this_command_name;
extern sh_builtin_func_t *this_shell_builtin;
#ifdef ARRAY_VARS
@@ -539,7 +537,7 @@ set_var_attribute (name, attribute, undo)
int attribute, undo;
{
SHELL_VAR *var, *tv, *v, *refvar;
char *tvalue, *refname;
char *tvalue;
if (undo)
var = find_variable (name);
+50 -7
View File
@@ -26,8 +26,8 @@ $SHORT_DOC shopt [-pqsu] [-o] [optname ...]
Set and unset shell options.
Change the setting of each shell option OPTNAME. Without any option
arguments, list all shell options with an indication of whether or not each
is set.
arguments, list each supplied OPTNAME, or all shell options if no
OPTNAMEs are given, with an indication of whether or not each is set.
Options:
-o restrict OPTNAMEs to those defined for use with `set -o'
@@ -91,6 +91,8 @@ extern int glob_star;
extern int glob_asciirange;
extern int lastpipe_opt;
extern int inherit_errexit;
extern int localvar_inherit;
extern int localvar_unset;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -110,18 +112,22 @@ extern int enable_hostname_completion __P((int));
extern int prog_completion_enabled;
#endif
#if defined (RESTRICTED_SHELL)
extern char *shell_name;
#endif
#if defined (DEBUGGER)
extern int debugging_mode;
#endif
#if defined (ARRAY_VARS)
extern int assoc_expand_once;
extern int array_expand_once;
#endif
#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
extern int syslog_history;
#endif
static void shopt_error __P((char *));
static int set_shellopts_after_change __P((char *, int));
static int shopt_enable_hostname_completion __P((char *, int));
static int set_compatibility_level __P((char *, int));
#if defined (RESTRICTED_SHELL)
@@ -129,6 +135,7 @@ static int set_restricted_shell __P((char *, int));
#endif
#if defined (READLINE)
static int shopt_enable_hostname_completion __P((char *, int));
static int shopt_set_complete_direxpand __P((char *, int));
#endif
@@ -141,6 +148,7 @@ static int shopt_compat40;
static int shopt_compat41;
static int shopt_compat42;
static int shopt_compat43;
static int shopt_compat44;
typedef int shopt_set_func_t __P((char *, int));
@@ -153,6 +161,9 @@ static struct {
shopt_set_func_t *set_func;
} shopt_vars[] = {
{ "autocd", &autocd, (shopt_set_func_t *)NULL },
#if defined (ARRAY_VARS)
{ "assoc_expand_once", &assoc_expand_once, (shopt_set_func_t *)NULL },
#endif
{ "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
{ "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
{ "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
@@ -169,6 +180,7 @@ static struct {
{ "compat41", &shopt_compat41, set_compatibility_level },
{ "compat42", &shopt_compat42, set_compatibility_level },
{ "compat43", &shopt_compat43, set_compatibility_level },
{ "compat44", &shopt_compat44, set_compatibility_level },
#if defined (READLINE)
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
@@ -205,6 +217,10 @@ static struct {
{ "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "lithist", &literal_history, (shopt_set_func_t *)NULL },
#endif
{ "localvar_inherit", &localvar_inherit, (shopt_set_func_t *)NULL },
#if 0
{ "localvar_unset", &localvar_unset, (shopt_set_func_t *)NULL },
#endif
{ "login_shell", &shopt_login_shell, set_login_shell },
{ "mailwarn", &mail_warning, (shopt_set_func_t *)NULL },
@@ -223,6 +239,9 @@ static struct {
#endif
{ "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
{ "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT)
{ "syslog_history", &syslog_history, (shopt_set_func_t *)NULL },
#endif
{ "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
{ (char *)0, (int *)0, (shopt_set_func_t *)NULL }
};
@@ -345,6 +364,14 @@ reset_shopt_options ()
command_oriented_history = 1;
#endif
#if defined (SYSLOG_HISTORY)
# if defined (SYSLOG_SHOPT)
syslog_history = SYSLOG_SHOPT;
# else
syslog_history = 1;
# endif /* SYSLOG_SHOPT */
#endif
#if defined (READLINE)
complete_fullquote = 1;
force_fignore = 1;
@@ -572,10 +599,13 @@ shopt_set_debug_mode (option_name, mode)
#if defined (DEBUGGER)
error_trace_mode = function_trace_mode = debugging_mode;
set_shellopts ();
if (debugging_mode)
init_bash_argv ();
#endif
return (0);
}
#if defined (READLINE)
static int
shopt_enable_hostname_completion (option_name, mode)
char *option_name;
@@ -583,6 +613,7 @@ shopt_enable_hostname_completion (option_name, mode)
{
return (enable_hostname_completion (mode));
}
#endif
static int
set_compatibility_level (option_name, mode)
@@ -590,6 +621,7 @@ set_compatibility_level (option_name, mode)
int mode;
{
int ind;
char *rhs;
/* If we're setting something, redo some of the work we did above in
toggle_shopt(). Unset everything and reset the appropriate option
@@ -598,6 +630,7 @@ set_compatibility_level (option_name, mode)
{
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
shopt_compat44 = 0;
ind = find_shopt (option_name);
*shopt_vars[ind].value = mode;
}
@@ -615,9 +648,16 @@ set_compatibility_level (option_name, mode)
shell_compatibility_level = 42;
else if (shopt_compat43)
shell_compatibility_level = 43;
else if (shopt_compat44)
shell_compatibility_level = 44;
else
shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
/* Make sure the current compatibility level is reflected in BASH_COMPAT */
rhs = itos (shell_compatibility_level);
bind_variable ("BASH_COMPAT", rhs, 0);
free (rhs);
return 0;
}
@@ -628,10 +668,13 @@ set_compatibility_opts ()
{
shopt_compat31 = shopt_compat32 = 0;
shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0;
shopt_compat44 = 0;
switch (shell_compatibility_level)
{
case DEFAULT_COMPAT_LEVEL:
break;
case 44:
shopt_compat44 = 1; break;
case 43:
shopt_compat43 = 1; break;
case 42:
+4 -5
View File
@@ -69,6 +69,7 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../flags.h"
#include "../findcmd.h"
#include "common.h"
@@ -79,10 +80,6 @@ $END
extern int errno;
#endif /* !errno */
extern int posixly_correct;
extern int last_command_exit_value;
extern int executing_command_builtin;
static void maybe_pop_dollar_vars __P((void));
/* If non-zero, `.' uses $PATH to look up the script to be sourced. */
@@ -169,12 +166,14 @@ source_builtin (list)
}
begin_unwind_frame ("source");
add_unwind_protect ((Function *)xfree, filename);
add_unwind_protect (xfree, filename);
if (list->next)
{
push_dollar_vars ();
add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL);
if (debugging_mode || shell_compatibility_level <= 44)
init_bash_argv (); /* Initialize BASH_ARGV and BASH_ARGC */
remember_args (list->next, 1);
if (debugging_mode)
push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */
+1 -2
View File
@@ -125,11 +125,10 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../test.h"
#include "common.h"
extern char *this_command_name;
/* TEST/[ builtin. */
int
test_builtin (list)
+3 -2
View File
@@ -97,8 +97,6 @@ static int display_traps __P((WORD_LIST *));
#define REVERT 1 /* Revert to this signals original value. */
#define IGNORE 2 /* Ignore this signal. */
extern int posixly_correct, subshell_environment;
int
trap_builtin (list)
WORD_LIST *list;
@@ -212,6 +210,9 @@ trap_builtin (list)
was SIG_IGN? */
if (interactive)
set_signal_handler (SIGINT, sigint_sighandler);
/* special cases for interactive == 0 */
else if (interactive_shell && (sourcelevel||running_trap))
set_signal_handler (SIGINT, sigint_sighandler);
else
set_signal_handler (SIGINT, termsig_sighandler);
break;
+2 -3
View File
@@ -64,6 +64,8 @@ $END
#include "../bashintl.h"
#include "../shell.h"
#include "../parser.h"
#include "../execute_cmd.h"
#include "../findcmd.h"
#include "../hashcmd.h"
@@ -76,9 +78,6 @@ $END
extern int find_reserved_word __P((char *));
extern char *this_command_name;
extern int expand_aliases, posixly_correct;
/* For each word in LIST, find out what the shell is going to do with
it as a simple command. i.e., which file would this shell use to
execve, or if it is a builtin command, or an alias. Possible flag
-2
View File
@@ -203,8 +203,6 @@ extern int errno;
#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));
+16 -10
View File
@@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -22,18 +22,21 @@ $BUILTIN wait
$FUNCTION wait_builtin
$DEPENDS_ON JOB_CONTROL
$PRODUCES wait.c
$SHORT_DOC wait [-n] [id ...]
$SHORT_DOC wait [-fn] [id ...]
Wait for job completion and return exit status.
Waits for each process identified by an ID, which may be a process ID or a
job specification, and reports its termination status. If ID is not
given, waits for all currently active child processes, and the return
status is zero. If ID is a a job specification, waits for all processes
status is zero. If ID is a job specification, waits for all processes
in that job's pipeline.
If the -n option is supplied, waits for the next job to terminate and
returns its exit status.
If the -f option is supplied, and job control is enabled, waits for the
specified ID to terminate, instead of waiting for it to change status.
Exit Status:
Returns the status of the last ID; fails if ID is invalid or an invalid
option is given.
@@ -68,12 +71,12 @@ $END
#include "../bashansi.h"
#include "../shell.h"
#include "../execute_cmd.h"
#include "../jobs.h"
#include "common.h"
#include "bashgetopt.h"
extern int wait_signal_received;
extern int last_command_exit_signal;
procenv_t wait_intr_buf;
int wait_intr_flag;
@@ -97,14 +100,14 @@ int
wait_builtin (list)
WORD_LIST *list;
{
int status, code, opt, nflag;
int status, code, opt, nflag, wflags;
volatile int old_interrupt_immediately;
USE_VAR(list);
nflag = 0;
nflag = wflags = 0;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "n")) != -1)
while ((opt = internal_getopt (list, "nf")) != -1)
{
switch (opt)
{
@@ -112,6 +115,9 @@ wait_builtin (list)
case 'n':
nflag = 1;
break;
case 'f':
wflags |= JWAIT_FORCE;
break;
#endif
CASE_HELPOPT;
default:
@@ -151,7 +157,7 @@ wait_builtin (list)
#if defined (JOB_CONTROL)
if (nflag)
{
status = wait_for_any_job ();
status = wait_for_any_job (wflags);
if (status < 0)
status = 127;
WAIT_RETURN (status);
@@ -179,7 +185,7 @@ wait_builtin (list)
if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value)
{
pid = (pid_t)pid_value;
status = wait_for_single_pid (pid, 1);
status = wait_for_single_pid (pid, wflags|JWAIT_PERROR);
}
else
{
@@ -209,7 +215,7 @@ wait_builtin (list)
/* Job spec used. Wait for the last pid in the pipeline. */
UNBLOCK_CHILD (oset);
status = wait_for_job (job);
status = wait_for_job (job, wflags);
}
#endif /* JOB_CONTROL */
else
+3
View File
@@ -101,6 +101,8 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define W_ASSNGLOBAL 0x2000000 /* word is a global assignment to declare (declare/typeset -g) */
#define W_NOBRACE 0x4000000 /* Don't perform brace expansion */
#define W_COMPLETE 0x8000000 /* word is being expanded for completion */
#define W_CHKLOCAL 0x10000000 /* check for local vars on assignment */
#define W_NOASSNTILDE 0x20000000 /* don't do tilde expansion like an assignment statement */
/* Flags for the `pflags' argument to param_expand() and various
parameter_brace_expand_xxx functions; also used for string_list_dollar_at */
@@ -352,6 +354,7 @@ typedef struct group_com {
typedef struct subshell_com {
int flags;
int line;
COMMAND *command;
} SUBSHELL_COM;
+18 -2
View File
@@ -53,7 +53,7 @@
/* Define DONT_REPORT_SIGTERM if you don't want to see `Terminates' message
when a job exits due to SIGTERM, since that's the default signal sent
by the kill builtin. */
/* #define DONT_REPORT_SIGTERM */
#define DONT_REPORT_SIGTERM
/* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins
like `echo' and `printf' to report errors when output does not succeed
@@ -66,6 +66,10 @@
"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:."
#endif
/* If you want to unconditionally set a value for PATH in every restricted
shell, set this. */
/* #define RBASH_STATIC_PATH_VALUE "/rbin:/usr/rbin" */
/* The value for PATH when invoking `command -p'. This is only used when
the Posix.2 confstr () function, or CS_PATH define are not present. */
#ifndef STANDARD_UTILS_PATH
@@ -120,10 +124,18 @@
# define OPENLOG_OPTS LOG_PID
#endif
/* Define if you want syslogging history to be controllable at runtime via a
shell option; if defined, the value is the default for the syslog_history
shopt option */
#if defined (SYSLOG_HISTORY)
/* #define SYSLOG_SHOPT 1 */
#endif
/* Define if you want to include code in shell.c to support wordexp(3) */
/* #define WORDEXP_OPTION */
/* Define as 1 if you want to enable code that implements multiple coprocs */
/* Define as 1 if you want to enable code that implements multiple coprocs
executing simultaneously */
#ifndef MULTIPLE_COPROCS
# define MULTIPLE_COPROCS 0
#endif
@@ -160,3 +172,7 @@
/* Define to use libc mktemp/mkstemp instead of replacements in lib/sh/tmpfile.c */
#define USE_MKTEMP
#define USE_MKSTEMP
/* Define to force the value of OLDPWD inherited from the environment to be a
directory */
#define OLDPWD_CHECK_DIRECTORY 1
+9
View File
@@ -242,6 +242,9 @@
/* The number of bytes in a `long long', if we have one. */
#undef SIZEOF_LONG_LONG
/* The number of bytes in a `wchar_t', if supported */
#undef SIZEOF_WCHAR_T
/* System paths */
#define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail"
@@ -449,6 +452,7 @@
#undef SYS_TIME_H_DEFINES_STRUCT_TIMESPEC
#undef PTHREAD_H_DEFINES_STRUCT_TIMESPEC
#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
#undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
#undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
#undef HAVE_STRUCT_STAT_ST_ATIMENSEC
@@ -605,6 +609,9 @@
/* Define if you have the fcntl function. */
#undef HAVE_FCNTL
/* Define if you have the fnmatch function. */
#undef HAVE_FNMATCH
/* Define if you have the fpurge/__fpurge function. */
#undef HAVE_FPURGE
#undef HAVE___FPURGE
@@ -1126,6 +1133,8 @@
#undef GETCWD_BROKEN
#undef DEV_FD_STAT_BROKEN
/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */
/* Define if you have the <argz.h> header file. */
Vendored
+159 -48
View File
@@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac for Bash 4.4, version 4.082.
# From configure.ac for Bash 5.0, version 4.091.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bash 4.4-release.
# Generated by GNU Autoconf 2.69 for bash 5.0-alpha.
#
# Report bugs to <bug-bash@gnu.org>.
#
@@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bash'
PACKAGE_TARNAME='bash'
PACKAGE_VERSION='4.4-release'
PACKAGE_STRING='bash 4.4-release'
PACKAGE_VERSION='5.0-alpha'
PACKAGE_STRING='bash 5.0-alpha'
PACKAGE_BUGREPORT='bug-bash@gnu.org'
PACKAGE_URL=''
@@ -802,6 +802,7 @@ enable_cond_command
enable_cond_regexp
enable_coprocesses
enable_debugger
enable_dev_fd_stat_broken
enable_direxpand_default
enable_directory_stack
enable_disabled_builtins
@@ -1393,7 +1394,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bash 4.4-release to adapt to many kinds of systems.
\`configure' configures bash 5.0-alpha to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1458,7 +1459,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bash 4.4-release:";;
short | recursive ) echo "Configuration of bash 5.0-alpha:";;
esac
cat <<\_ACEOF
@@ -1486,6 +1487,9 @@ Optional Features:
--enable-coprocesses enable coprocess support and the coproc reserved
word
--enable-debugger enable support for bash debugger
--enable-dev-fd-stat-broken
enable this option if stat on /dev/fd/N and fstat on
file descriptor N don't return the same results
--enable-direxpand-default
enable the direxpand shell option by default
--enable-directory-stack
@@ -1562,7 +1566,7 @@ Some influential environment variables:
CC_FOR_BUILD
C compiler used when compiling binaries used only at build time
CFLAGS_FOR_BUILD
Compliation options (CFLAGS) used when compiling binaries used
Compilation options (CFLAGS) used when compiling binaries used
only at build time
LDFLAGS_FOR_BUILD
Linker options (LDFLAGS) used when compiling binaries used only
@@ -1651,7 +1655,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bash configure 4.4-release
bash configure 5.0-alpha
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2360,7 +2364,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bash $as_me 4.4-release, which was
It was created by bash $as_me 5.0-alpha, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2645,6 +2649,7 @@ as_fn_append ac_header_list " unistd.h"
as_fn_append ac_header_list " sys/param.h"
as_fn_append ac_header_list " sys/time.h"
as_fn_append ac_func_list " alarm"
as_fn_append ac_func_list " sbrk"
as_fn_append ac_func_list " fpurge"
as_fn_append ac_func_list " __fpurge"
as_fn_append ac_func_list " snprintf"
@@ -2753,8 +2758,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
ac_config_headers="$ac_config_headers config.h"
BASHVERS=4.4
RELSTATUS=release
BASHVERS=5.0
RELSTATUS=alpha
case "$RELSTATUS" in
alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
@@ -2861,7 +2866,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X)
*-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X)
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX 6.x
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x
*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
@@ -2978,6 +2983,7 @@ opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_function_import=yes
opt_dev_fd_stat_broken=no
opt_static_link=no
opt_profiling=no
@@ -3061,6 +3067,11 @@ if test "${enable_debugger+set}" = set; then :
enableval=$enable_debugger; opt_debugger=$enableval
fi
# Check whether --enable-dev-fd-stat-broken was given.
if test "${enable_dev_fd_stat_broken+set}" = set; then :
enableval=$enable_dev_fd_stat_broken; opt_dev_fd_stat_broken=$enableval
fi
# Check whether --enable-direxpand-default was given.
if test "${enable_direxpand_default+set}" = set; then :
enableval=$enable_direxpand_default; opt_dircomplete_expand_default=$enableval
@@ -3326,6 +3337,10 @@ fi
if test $opt_function_import = yes; then
$as_echo "#define FUNCTION_IMPORT 1" >>confdefs.h
fi
if test $opt_dev_fd_stat_broken = yes; then
$as_echo "#define DEV_FD_STAT_BROKEN 1" >>confdefs.h
fi
if test $opt_memscramble = yes; then
@@ -4896,6 +4911,9 @@ if test "x$cross_compiling" = "xyes"; then
i[3456]86-*-beos*)
cross_cache=${srcdir}/cross-build/x86-beos.cache
;;
*-qnx*)
cross_cache=${srcdir}/cross-build/qnx.cache
;;
*) echo "configure: cross-compiling for $host is not supported" >&2
;;
esac
@@ -4924,7 +4942,7 @@ fi
if test "$opt_profiling" = "yes"; then
PROFILE_FLAGS=-pg
case "$host_os" in
solaris2*) ;;
solaris2*|linux*) ;;
*) opt_static_link=yes ;;
esac
DEBUG= MALLOC_DEBUG=
@@ -4940,7 +4958,7 @@ if test "$opt_static_link" = yes; then
if test -n "$GCC" || test "$ac_cv_c_compiler_gnu" = "yes"; then
STATIC_LD="-static"
case "$host_os" in
solaris2*) ;;
solaris2*|linux*) ;;
*) LDFLAGS="$LDFLAGS -static" ;; # XXX experimental
esac
fi
@@ -4952,7 +4970,11 @@ fi
if test "X$cross_compiling" = "Xno"; then
CC_FOR_BUILD=${CC_FOR_BUILD-'$(CC)'}
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"} # XXX - should it be '$(CPPFLAGS)'
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
if test X"$opt_profiling" = Xyes; then
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(BASE_LDFLAGS)'}
else
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
fi
# CFLAGS set above to default value if not passed in environment
CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'}
@@ -5268,7 +5290,7 @@ if ${ac_cv_rl_version+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
ac_cv_rl_version='6.3'
ac_cv_rl_version='7.0'
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -5382,7 +5404,7 @@ fi
case "$ac_cv_rl_version" in
5*|6*|7*|8*|9*) ;;
7*|8*|9*) ;;
*) opt_with_installed_readline=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: installed readline library is too old to be linked with bash" >&5
$as_echo "$as_me: WARNING: installed readline library is too old to be linked with bash" >&2;}
@@ -9804,7 +9826,7 @@ fi
for ac_func in dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat pselect readlink sbrk select setdtablesize \
kill killpg lstat pselect readlink select setdtablesize \
setitimer tcgetpgrp uname ulimit waitpid
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -10265,7 +10287,7 @@ else
int
main ()
{
int main() { long double r; char *foo, bar; r = strtold(foo, &bar);}
long double r; char *foo, bar; r = strtold(foo, &bar);
;
return 0;
}
@@ -11445,6 +11467,40 @@ done
LIBS="$OLDLIBS"
fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5
$as_echo_n "checking size of wchar_t... " >&6; }
if ${ac_cv_sizeof_wchar_t+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default"; then :
else
if test "$ac_cv_type_wchar_t" = 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 77 "cannot compute sizeof (wchar_t)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_wchar_t=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5
$as_echo "$ac_cv_sizeof_wchar_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t
_ACEOF
if test "$opt_static_link" != yes; then
@@ -14408,6 +14464,61 @@ fi
if test X$ac_cv_func_sbrk = Xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working sbrk" >&5
$as_echo_n "checking for working sbrk... " >&6; }
if ${bash_cv_func_sbrk+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check working sbrk if cross-compiling" >&5
$as_echo "$as_me: WARNING: cannot check working sbrk if cross-compiling" >&2;}
bash_cv_func_sbrk=yes
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <unistd.h>
int
main(int c, char **v)
{
void *x;
x = sbrk (4096);
exit ((x == (void *)-1) ? 1 : 0);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
bash_cv_func_sbrk=yes
else
bash_cv_func_snprintf=sbrk
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_sbrk" >&5
$as_echo "$bash_cv_func_sbrk" >&6; }
if test $bash_cv_func_sbrk = no; then
ac_cv_func_sbrk=no
fi
fi
if test $ac_cv_func_sbrk = no; then
$as_echo "#define HAVE_SBRK 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the existence of strsignal" >&5
$as_echo_n "checking for the existence of strsignal... " >&6; }
if ${bash_cv_have_strsignal+:} false; then :
@@ -15201,12 +15312,6 @@ fi
$as_echo_n "checking for presence of necessary job control definitions... " >&6; }
if ${bash_cv_job_control_missing+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check job control if cross-compiling -- defaulting to missing" >&5
$as_echo "$as_me: WARNING: cannot check job control if cross-compiling -- defaulting to missing" >&2;}
bash_cv_job_control_missing=missing
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -15220,51 +15325,54 @@ else
#endif
#include <signal.h>
/* Add more tests in here as appropriate. */
main()
{
/* add more tests in here as appropriate */
/* signal type */
#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
exit(1);
#error
#endif
/* signals and tty control. */
#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
exit (1);
#error
#endif
/* process control */
#if !defined (WNOHANG) || !defined (WUNTRACED)
exit(1);
#error
#endif
/* Posix systems have tcgetpgrp and waitpid. */
#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
exit(1);
#error
#endif
#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
exit(1);
#error
#endif
/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
exit(1);
#error
#endif
exit(0);
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
if ac_fn_c_try_compile "$LINENO"; then :
bash_cv_job_control_missing=present
else
bash_cv_job_control_missing=missing
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_job_control_missing" >&5
$as_echo "$bash_cv_job_control_missing" >&6; }
@@ -15976,9 +16084,7 @@ $as_echo_n "checking whether /dev/stdin stdout stderr are available... " >&6; }
if ${bash_cv_dev_stdin+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
if (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
else
bash_cv_dev_stdin=absent
@@ -16065,10 +16171,11 @@ solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
2.[456789]*|[34]*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
1.*|2.[0123]*) : ;;
*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
*qnx[67]*) LOCAL_LIBS="-lncurses" ;;
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
powerux*) LOCAL_LIBS="-lgen" ;;
cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
@@ -16124,6 +16231,9 @@ $as_echo_n "checking shared object configuration for loadable builtins... " >&6;
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHOBJ_STATUS" >&5
$as_echo "$SHOBJ_STATUS" >&6; }
else
SHOBJ_STATUS=unsupported
fi
# try to create a directory tree if the source is elsewhere
@@ -16194,7 +16304,7 @@ fi
#AC_SUBST(ALLOCA_SOURCE)
#AC_SUBST(ALLOCA_OBJECT)
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/perl/Makefile support/bash.pc"
ac_config_files="$ac_config_files Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile lib/intl/Makefile lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in examples/loadables/Makefile examples/loadables/Makefile.inc examples/loadables/perl/Makefile support/bash.pc support/bashbug.sh"
ac_config_commands="$ac_config_commands default"
@@ -16705,7 +16815,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bash $as_me 4.4-release, which was
This file was extended by bash $as_me 5.0-alpha, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16771,7 +16881,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
bash config.status 4.4-release
bash config.status 5.0-alpha
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -16922,6 +17032,7 @@ do
"examples/loadables/Makefile.inc") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.inc" ;;
"examples/loadables/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;;
"support/bash.pc") CONFIG_FILES="$CONFIG_FILES support/bash.pc" ;;
"support/bashbug.sh") CONFIG_FILES="$CONFIG_FILES support/bashbug.sh" ;;
"default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+34 -15
View File
@@ -1,5 +1,5 @@
dnl
dnl Configure script for bash-4.4
dnl Configure script for bash-5.0
dnl
dnl report bugs to chet@po.cwru.edu
dnl
@@ -21,10 +21,10 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Bash 4.4, version 4.082])dnl
AC_REVISION([for Bash 5.0, version 4.091])dnl
define(bashvers, 4.4)
define(relstatus, release)
define(bashvers, 5.0)
define(relstatus, alpha)
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
@@ -82,7 +82,7 @@ sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody (MacOS X)
*-darwin*) opt_bash_malloc=no ;; # Apple Darwin (MacOS X)
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX 6.x
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x
*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
@@ -179,6 +179,7 @@ opt_extglob_default=no
opt_dircomplete_expand_default=no
opt_globascii_default=no
opt_function_import=yes
opt_dev_fd_stat_broken=no
dnl options that affect how bash is compiled and linked
opt_static_link=no
@@ -214,6 +215,7 @@ AC_ARG_ENABLE(cond-command, AC_HELP_STRING([--enable-cond-command], [enable the
AC_ARG_ENABLE(cond-regexp, AC_HELP_STRING([--enable-cond-regexp], [enable extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval)
AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval)
AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval)
AC_ARG_ENABLE(dev-fd-stat-broken, AC_HELP_STRING([--enable-dev-fd-stat-broken], [enable this option if stat on /dev/fd/N and fstat on file descriptor N don't return the same results]), opt_dev_fd_stat_broken=$enableval)
AC_ARG_ENABLE(direxpand-default, AC_HELP_STRING([--enable-direxpand-default], [enable the direxpand shell option by default]), opt_dircomplete_expand_default=$enableval)
AC_ARG_ENABLE(directory-stack, AC_HELP_STRING([--enable-directory-stack], [enable builtins pushd/popd/dirs]), opt_dirstack=$enableval)
AC_ARG_ENABLE(disabled-builtins, AC_HELP_STRING([--enable-disabled-builtins], [allow disabled builtins to still be invoked]), opt_disabled_builtins=$enableval)
@@ -246,7 +248,7 @@ AC_ARG_ENABLE(static-link, AC_HELP_STRING([--enable-static-link], [link bash sta
dnl So-called `precious' variables
AC_ARG_VAR([CC_FOR_BUILD], [C compiler used when compiling binaries used only at build time])
AC_ARG_VAR([CFLAGS_FOR_BUILD], [Compliation options (CFLAGS) used when compiling binaries used only at build time])
AC_ARG_VAR([CFLAGS_FOR_BUILD], [Compilation options (CFLAGS) used when compiling binaries used only at build time])
AC_ARG_VAR([LDFLAGS_FOR_BUILD], [Linker options (LDFLAGS) used when compiling binaries used only at build time])
AC_ARG_VAR([CPPFLAGS_FOR_BUILD], [C preprocessor options (CPPFLAGS) used when compiling binaries used only at build time])
@@ -347,6 +349,9 @@ fi
if test $opt_function_import = yes; then
AC_DEFINE(FUNCTION_IMPORT)
fi
if test $opt_dev_fd_stat_broken = yes; then
AC_DEFINE(DEV_FD_STAT_BROKEN)
fi
if test $opt_memscramble = yes; then
AC_DEFINE(MEMSCRAMBLE)
@@ -440,6 +445,9 @@ if test "x$cross_compiling" = "xyes"; then
i[[3456]]86-*-beos*)
cross_cache=${srcdir}/cross-build/x86-beos.cache
;;
*-qnx*)
cross_cache=${srcdir}/cross-build/qnx.cache
;;
*) echo "configure: cross-compiling for $host is not supported" >&2
;;
esac
@@ -472,7 +480,7 @@ dnl these must come after the test for cc/gcc
if test "$opt_profiling" = "yes"; then
PROFILE_FLAGS=-pg
case "$host_os" in
solaris2*) ;;
solaris2*|linux*) ;;
*) opt_static_link=yes ;;
esac
DEBUG= MALLOC_DEBUG=
@@ -488,7 +496,7 @@ if test "$opt_static_link" = yes; then
if test -n "$GCC" || test "$ac_cv_prog_gcc" = "yes"; then
STATIC_LD="-static"
case "$host_os" in
solaris2*) ;;
solaris2*|linux*) ;;
*) LDFLAGS="$LDFLAGS -static" ;; # XXX experimental
esac
fi
@@ -500,7 +508,11 @@ fi
if test "X$cross_compiling" = "Xno"; then
CC_FOR_BUILD=${CC_FOR_BUILD-'$(CC)'}
CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"} # XXX - should it be '$(CPPFLAGS)'
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
if test X"$opt_profiling" = Xyes; then
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(BASE_LDFLAGS)'}
else
LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'}
fi
# CFLAGS set above to default value if not passed in environment
CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'}
LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'}
@@ -538,7 +550,7 @@ then
RL_LIB_READLINE_VERSION
case "$ac_cv_rl_version" in
5*|6*|7*|8*|9*) ;;
7*|8*|9*) ;;
*) opt_with_installed_readline=no
AC_MSG_WARN([installed readline library is too old to be linked with bash])
AC_MSG_WARN([using private bash version])
@@ -770,7 +782,7 @@ AC_CHECK_FUNC(mkfifo,AC_DEFINE(HAVE_MKFIFO),AC_DEFINE(MKFIFO_MISSING))
dnl checks for system calls
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getgroups gethostname \
getpagesize getpeername getrlimit getrusage gettimeofday \
kill killpg lstat pselect readlink sbrk select setdtablesize \
kill killpg lstat pselect readlink select setdtablesize \
setitimer tcgetpgrp uname ulimit waitpid)
AC_REPLACE_FUNCS(rename)
@@ -808,7 +820,7 @@ AC_CHECK_DECLS([strtold], [
AC_CACHE_VAL(bash_cv_strtold_broken,
[AC_TRY_COMPILE(
[#include <stdlib.h>],
[int main() { long double r; char *foo, bar; r = strtold(foo, &bar);}],
[long double r; char *foo, bar; r = strtold(foo, &bar);],
bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
[AC_MSG_WARN(cannot check for broken strtold if cross-compiling, defaulting to no)])
]
@@ -980,6 +992,9 @@ BASH_STRUCT_WEXITSTATUS_OFFSET
BASH_CHECK_TYPE_STRUCT_TIMESPEC
BASH_STAT_TIME
dnl checks for system calls
BASH_FUNC_SBRK
dnl presence and behavior of C library functions
BASH_FUNC_STRSIGNAL
BASH_FUNC_OPENDIR_CHECK
@@ -1093,9 +1108,10 @@ solaris2*) LOCAL_CFLAGS=-DSOLARIS ;;
lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
case "`uname -r`" in
2.[[456789]]*|[[34]]*) AC_DEFINE(PGRP_PIPE) ;;
1.*|2.[[0123]]*) : ;;
*) AC_DEFINE(PGRP_PIPE) ;;
esac ;;
*qnx6*) LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
*qnx[[67]]*) LOCAL_LIBS="-lncurses" ;;
*qnx*) LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
powerux*) LOCAL_LIBS="-lgen" ;;
cygwin*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
@@ -1151,6 +1167,9 @@ then
AC_SUBST(SHOBJ_LIBS)
AC_SUBST(SHOBJ_STATUS)
AC_MSG_RESULT($SHOBJ_STATUS)
else
SHOBJ_STATUS=unsupported
AC_SUBST(SHOBJ_STATUS)
fi
# try to create a directory tree if the source is elsewhere
@@ -1227,7 +1246,7 @@ AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \
examples/loadables/Makefile examples/loadables/Makefile.inc \
examples/loadables/perl/Makefile \
support/bash.pc],
support/bash.pc support/bashbug.sh],
[
# Makefile uses this timestamp file to record whether config.h is up to date.
echo timestamp > stamp-h
-1161
View File
File diff suppressed because it is too large Load Diff
+13 -4
View File
@@ -69,12 +69,20 @@ WORD_LIST *
copy_word_list (list)
WORD_LIST *list;
{
WORD_LIST *new_list;
WORD_LIST *new_list, *tl;
for (new_list = (WORD_LIST *)NULL; list; list = list->next)
new_list = make_word_list (copy_word (list->word), new_list);
for (new_list = tl = (WORD_LIST *)NULL; list; list = list->next)
{
if (new_list == 0)
new_list = tl = make_word_list (copy_word (list->word), new_list);
else
{
tl->next = make_word_list (copy_word (list->word), (WORD_LIST *)NULL);
tl = tl->next;
}
}
return (REVERSE_LIST (new_list, WORD_LIST *));
return (new_list);
}
static PATTERN_LIST *
@@ -221,6 +229,7 @@ copy_subshell_command (com)
new_subshell = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM));
new_subshell->command = copy_command (com->command);
new_subshell->flags = com->flags;
new_subshell->line = com->line;
return (new_subshell);
}
+66
View File
@@ -0,0 +1,66 @@
bash_cv_decl_strtoimax=${bash_cv_decl_strtoimax=yes}
bash_cv_decl_strtol=${bash_cv_decl_strtol=yes}
bash_cv_decl_strtoll=${bash_cv_decl_strtoll=yes}
bash_cv_decl_strtoul=${bash_cv_decl_strtoul=yes}
bash_cv_decl_strtoull=${bash_cv_decl_strtoull=yes}
bash_cv_decl_strtoumax=${bash_cv_decl_strtoumax=yes}
bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist=no}
bash_cv_dev_fd=${bash_cv_dev_fd=absent}
bash_cv_dev_stdin=${bash_cv_dev_stdin=present}
bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno=no}
bash_cv_dirent_has_d_namlen=${bash_cv_dirent_has_d_namlen=no}
bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino=yes}
bash_cv_dup2_broken=${bash_cv_dup2_broken=no}
bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl=yes}
bash_cv_func_ctype_nonascii=${bash_cv_func_ctype_nonascii=no}
bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp=present}
bash_cv_func_snprintf=${bash_cv_func_snprintf=yes}
bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken=no}
bash_cv_func_vsnprintf=${bash_cv_func_vsnprintf=yes}
bash_cv_getcwd_malloc=${bash_cv_getcwd_malloc=yes}
bash_cv_getenv_redef=${bash_cv_getenv_redef=yes}
bash_cv_getpw_declared=${bash_cv_getpw_declared=yes}
bash_cv_have_gethostbyname=${bash_cv_have_gethostbyname=no}
bash_cv_have_socklib=${bash_cv_have_socklib=no}
bash_cv_have_strsignal=${bash_cv_have_strsignal=yes}
bash_cv_job_control_missing=${bash_cv_job_control_missing=present}
bash_cv_langinfo_codeset=${bash_cv_langinfo_codeset=no}
bash_cv_mail_dir=${bash_cv_mail_dir=unknown}
bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers=no}
bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust=no}
bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe=no}
bash_cv_printf_a_format=${bash_cv_printf_a_format=yes}
bash_cv_signal_vintage=${bash_cv_signal_vintage=posix}
bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types=no}
bash_cv_std_putenv=${bash_cv_std_putenv=yes}
bash_cv_std_unsetenv=${bash_cv_std_unsetenv=yes}
bash_cv_strtold_broken=${bash_cv_strtold_broken=no}
bash_cv_struct_timeval=${bash_cv_struct_timeval=yes}
bash_cv_struct_timezone=${bash_cv_struct_timezone=yes}
bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header=ioctl_h}
bash_cv_sys_errlist=${bash_cv_sys_errlist=no}
bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes=present}
bash_cv_sys_siglist=${bash_cv_sys_siglist=yes}
bash_cv_sys_struct_timespec_in_time_h=${bash_cv_sys_struct_timespec_in_time_h=yes}
bash_cv_termcap_lib=${bash_cv_termcap_lib=libtermcap}
bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl=no}
bash_cv_type_clock_t=${bash_cv_type_clock_t=yes}
bash_cv_type_intmax_t=${bash_cv_type_intmax_t=yes}
bash_cv_type_long_long=${bash_cv_type_long_long='long long'}
bash_cv_type_quad_t=${bash_cv_type_quad_t=no}
bash_cv_type_rlimit=${bash_cv_type_rlimit=rlim_t}
bash_cv_type_sig_atomic_t=${bash_cv_type_sig_atomic_t=yes}
bash_cv_type_sigset_t=${bash_cv_type_sigset_t=yes}
bash_cv_type_socklen_t=${bash_cv_type_socklen_t=yes}
bash_cv_type_uintmax_t=${bash_cv_type_uintmax_t=yes}
bash_cv_type_unsigned_long_long=${bash_cv_type_unsigned_long_long='unsigned long long'}
bash_cv_type_wchar_t=${bash_cv_type_wchar_t=yes}
bash_cv_type_wctype_t=${bash_cv_type_wctype_t=yes}
bash_cv_type_wint_t=${bash_cv_type_wint_t=yes}
bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds=no}
bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist=no}
bash_cv_unusable_rtsigs=${bash_cv_unusable_rtsigs=no}
bash_cv_void_sighandler=${bash_cv_void_sighandler=yes}
bash_cv_wcontinued_broken=${bash_cv_wcontinued_broken=no}
bash_cv_wcwidth_broken=${bash_cv_wcwidth_broken=no}
bash_cv_wexitstatus_offset=${bash_cv_wexitstatus_offset=8}
+5 -13
View File
@@ -1,7 +1,5 @@
This is the Bash FAQ, version 4.14, for Bash version 4.4.
[THIS FAQ IS NO LONGER MAINTAINED]
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
interpreter with advanced features for both interactive use and shell
@@ -962,7 +960,7 @@ o `complete' and `compgen' now take a `-o value' option, which controls some
directory names and suppress trailing spaces
o A new loadable builtin, realpath, which canonicalizes and expands symlinks
in pathname arguments.
o When `set' is called without options, it prints function defintions in a
o When `set' is called without options, it prints function definitions in a
way that allows them to be reused as input. This affects `declare' and
`declare -p' as well. This only happens when the shell is not in POSIX
mode, since POSIX.2 forbids this behavior.
@@ -2171,17 +2169,11 @@ You may also need
Finally, you need to tell readline that you will be inputting and
displaying eight-bit characters. You use readline variables to do
this. convert-meta says what to do if you read a character with its
eighth bit set. input-meta says whether to permit characters with the
eighth bit at all. output-meta determines how to display characters
with the eighth bit set: if on, they are output directly; if it is off,
such characters are displayed as a meta-prefixed escape sequence.
These variables can be set in your .inputrc or using the bash
this. These variables can be set in your .inputrc or using the bash
`bind' builtin. Here's an example using `bind':
bash$ bind 'set convert-meta off'
bash$ bind 'set input-meta on'
bash$ bind 'set meta-flag on'
bash$ bind 'set output-meta on'
The `set' commands between the single quotes may also be placed
@@ -2287,7 +2279,7 @@ The \w expansion gives the full pathname of the current directory, with
a tilde (`~') substituted for the current value of $HOME. The \W
expansion gives the basename of the current directory. To put the full
pathname of the current directory into the path without any tilde
subsitution, use $PWD. Here are some examples:
substitution, use $PWD. Here are some examples:
PS1='\w$ ' # current directory with tilde
PS1='\W$ ' # basename of current directory
@@ -2404,7 +2396,7 @@ a bash programmer's guide with a chapter on creating loadable builtins
a better loadable interface to perl with access to the shell builtins and
variables (contributions gratefully accepted)
ksh93-like `xx.yy' variables (including some of the .sh.* variables) and
associated disipline functions
associated discipline functions
Some of the new ksh93 pattern matching operators, like backreferencing
H5) When will the next release appear?
+1903 -1722
View File
File diff suppressed because it is too large Load Diff
+365 -91
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Aug 26 09:45:10 EDT 2016
.\" Last Change: Thu Mar 15 11:30:03 EDT 2018
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2016 August 26" "GNU Bash 4.4"
.TH BASH 1 "2018 March 15" "GNU Bash 5.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -50,8 +50,8 @@ bash \- GNU Bourne-Again SHell
[options]
[command_string | file]
.SH COPYRIGHT
.if n Bash is Copyright (C) 1989-2016 by the Free Software Foundation, Inc.
.if t Bash is Copyright \(co 1989-2016 by the Free Software Foundation, Inc.
.if n Bash is Copyright (C) 1989-2018 by the Free Software Foundation, Inc.
.if t Bash is Copyright \(co 1989-2018 by the Free Software Foundation, Inc.
.SH DESCRIPTION
.B Bash
is an \fBsh\fR-compatible command language interpreter that
@@ -68,8 +68,8 @@ Shell and Utilities portion of the IEEE POSIX specification
can be configured to be POSIX-conformant by default.
.SH OPTIONS
All of the single-character shell options documented in the
description of the \fBset\fR builtin command can be used as options
when the shell is invoked.
description of the \fBset\fR builtin command, including \fB\-o\fP,
can be used as options when the shell is invoked.
In addition, \fBbash\fR
interprets the following options when it is invoked:
.PP
@@ -119,7 +119,8 @@ If the
option is present, or if no arguments remain after option
processing, then commands are read from the standard input.
This option allows the positional parameters to be set
when invoking an interactive shell.
when invoking an interactive shell or when reading input
through a pipe.
.TP
.B \-D
A list of all double-quoted strings preceded by \fB$\fP
@@ -590,6 +591,13 @@ the time information.
.PP
Each command in a pipeline is executed as a separate process (i.e., in a
subshell).
See
.SM
\fBCOMMAND EXECUTION ENVIRONMENT\fP
for a description of a subshell environment.
If the \fBlastpipe\fP option is enabled using the \fBshopt\fP builtin
(see the description of \fBshopt\fP below),
the last element of a pipeline may be run by the shell process.
.SS Lists
.PP
A \fIlist\fP is a sequence of one or more pipelines separated by one
@@ -640,7 +648,7 @@ An AND list has the form
.I command2
is executed if, and only if,
.I command1
returns an exit status of zero.
returns an exit status of zero (success).
.PP
An OR list has the form
.RS
@@ -650,7 +658,7 @@ An OR list has the form
.RE
.PP
.I command2
is executed if and only if
is executed if, and only if,
.I command1
returns a non-zero exit status.
The return status of
@@ -861,10 +869,10 @@ or zero if no commands were executed.
\fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
... ) \fIlist\fP ;; ] ... \fBesac\fP
A \fBcase\fP command first expands \fIword\fP, and tries to match
it against each \fIpattern\fP in turn, using the same matching rules
as for pathname expansion (see
.B Pathname Expansion
below).
it against each \fIpattern\fP in turn, using the matching rules
described under
.B Pattern Matching
below.
The \fIword\fP is expanded using tilde
expansion, parameter and variable expansion, arithmetic expansion,
command substitution, process substitution and quote removal.
@@ -955,7 +963,8 @@ command (see
below).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
The file descriptors are not available in subshells.
Other than those created to execute command and process substitutions,
the file descriptors are not available in subshells.
The process ID of the shell spawned to execute the coprocess is
available as the value of the variable \fINAME\fP_PID.
The \fBwait\fP
@@ -1142,7 +1151,7 @@ question mark
.TP
.B \e\fInnn\fP
the eight-bit character whose value is the octal value \fInnn\fP
(one to three digits)
(one to three octal digits)
.TP
.B \ex\fIHH\fP
the eight-bit character whose value is the hexadecimal value \fIHH\fP
@@ -1453,6 +1462,14 @@ This variable is read-only.
Expands to the process ID of the current \fBbash\fP process.
This differs from \fB$$\fP under certain circumstances, such as subshells
that do not require \fBbash\fP to be re-initialized.
Assignments to
.SM
.B BASHPID
have no effect.
If
.B BASHPID
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
.B BASH_ALIASES
An associative array variable whose members correspond to the internal
@@ -1481,7 +1498,9 @@ only when in extended debugging mode (see the description of the
.B extdebug
option to the
.B shopt
builtin below)
builtin below).
Setting \fBextdebug\fP after the shell has started to execute a script
may result in inconsistent values.
.TP
.B BASH_ARGV
An array variable containing all of the parameters in the current \fBbash\fP
@@ -1499,7 +1518,22 @@ only when in extended debugging mode
.B extdebug
option to the
.B shopt
builtin below)
builtin below).
Setting \fBextdebug\fP after the shell has started to execute a script
may result in inconsistent values.
.TP
.B BASH_ARGV0
When referenced, this variable expands to the name of the shell or shell
script (identical to
.BR $0 ;
see the description of special parameter 0 above).
Assignment to
.B BASH_ARGV0
causes the value assigned to also be assigned to \fB$0\fP.
If
.B BASH_ARGV0
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
.B BASH_CMDS
An associative array variable whose members correspond to the internal
@@ -1687,6 +1721,33 @@ If
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
.B EPOCHREALTIME
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch (see \fItime\fP\fR(3)\fP) as a floating point value
with micro-second granularity.
Assignments to
.SM
.B EPOCHREALTIME
are ignored.
If
.SM
.B EPOCHREALTIME
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
.B EPOCHSECONDS
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch (see \fItime\fP\fR(3)\fP).
Assignments to
.SM
.B EPOCHSECONDS
are ignored.
If
.SM
.B EPOCHSECONDS
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
.B EUID
Expands to the effective user ID of the current user, initialized at
shell startup. This variable is readonly.
@@ -2053,9 +2114,9 @@ nesting level. Function invocations that exceed this nesting level
will cause the current command to abort.
.TP
.B GLOBIGNORE
A colon-separated list of patterns defining the set of filenames to
A colon-separated list of patterns defining the set of file names to
be ignored by pathname expansion.
If a filename matched by a pathname expansion pattern also matches one
If a file name matched by a pathname expansion pattern also matches one
of the patterns in
.SM
.BR GLOBIGNORE ,
@@ -2076,7 +2137,7 @@ A value of
.I ignoreboth
is shorthand for \fIignorespace\fP and \fIignoredups\fP.
A value of
.IR erasedups
.I erasedups
causes all previous lines matching the current line to be removed from
the history list before that line is saved.
Any value not in the above list is ignored.
@@ -2388,6 +2449,7 @@ The value of this parameter is expanded as with
and the value is printed before each command
.B bash
displays during an execution trace. The first character of
the expanded value of
.SM
.B PS4
is replicated multiple times, as necessary, to indicate multiple
@@ -2624,14 +2686,19 @@ special parameters \fI@\fP and \fI*\fP within double quotes.
The
.B unset
builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
destroys the array element at index \fIsubscript\fP.
destroys the array element at index \fIsubscript\fP,
for both indexed and associative arrays.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by pathname
expansion.
Unsetting the last element of an array variable does not unset the variable.
\fBunset\fP \fIname\fP, where \fIname\fP is an array, or
\fBunset\fP \fIname\fP[\fIsubscript\fP], where
\fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
.PP
When using a variable name with a subscript as an argument to a command,
such as with \fBunset\fP, without using the word expansion syntax
described above, the argument is subject to pathname expansion.
If pathname expansion is not desired, the argument should be quoted.
.PP
The
.BR declare ,
.BR local ,
@@ -2686,10 +2753,11 @@ original word are removed unless they have been quoted themselves
(\fIquote removal\fP).
.PP
Only brace expansion, word splitting, and pathname expansion
can change the number of words of the expansion; other expansions
can increase the number of words of the expansion; other expansions
expand a single word to a single word.
The only exceptions to this are the expansions of
"\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
"\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP",
and, in most cases, \fB$*\fP and \fB${\fP\fIname\fP\fB[*]}\fP
as explained above (see
.SM
.BR PARAMETERS ).
@@ -2730,7 +2798,7 @@ lexicographically between \fIx\fP and \fIy\fP, inclusive,
using the default C locale.
Note that both \fIx\fP and \fIy\fP must be of the same type.
When the increment is supplied, it is used as the difference between
each term. The default increment is 1 or -1 as appropriate.
each term. The default increment is 1 or \-1 as appropriate.
.PP
Brace expansion is performed before any other expansions,
and any characters special to other expansions are preserved
@@ -2746,7 +2814,8 @@ Any incorrectly formed brace expansion is left unchanged.
A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
being considered part of a brace expression.
To avoid conflicts with parameter expansion, the string \fB${\fP
is not considered eligible for brace expansion.
is not considered eligible for brace expansion, and inhibits brace
expansion until the closing \fB}\fP.
.PP
This construct is typically used as shorthand when the common
prefix of the strings to be generated is longer than in the
@@ -2882,6 +2951,8 @@ it introduces a level of variable indirection.
expanded and that value is used in the rest of the substitution, rather
than the value of \fIparameter\fP itself.
This is known as \fIindirect expansion\fP.
The value is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
If \fIparameter\fP is a nameref, this expands to the name of the
variable referenced by \fIparameter\fP instead of performing the
complete indirect expansion.
@@ -2975,7 +3046,7 @@ one space to avoid being confused with the \fB:-\fP expansion.
If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
parameters beginning at \fIoffset\fP.
A negative \fIoffset\fP is taken relative to one greater than the greatest
positional parameter, so an offset of -1 evaluates to the last positional
positional parameter, so an offset of \-1 evaluates to the last positional
parameter.
It is an expansion error if \fIlength\fP evaluates to a number less than
zero.
@@ -3056,7 +3127,12 @@ ${\fIparameter\fP\fB##\fP\fIword\fP}
The
.I word
is expanded to produce a pattern just as in pathname
expansion. If the pattern matches the beginning of
expansion, and matched against the expanded value of
.I parameter
using the rules described under
.B Pattern Matching
below.
If the pattern matches the beginning of
the value of
.IR parameter ,
then the result of the expansion is the expanded value of
@@ -3087,7 +3163,11 @@ ${\fIparameter\fP\fB%%\fP\fIword\fP}
.PD
\fBRemove matching suffix pattern\fP.
The \fIword\fP is expanded to produce a pattern just as in
pathname expansion.
pathname expansion, and matched against the expanded value of
.I parameter
using the rules described under
.B Pattern Matching
below.
If the pattern matches a trailing portion of the expanded value of
.IR parameter ,
then the result of the expansion is the expanded value of
@@ -3114,9 +3194,12 @@ array in turn, and the expansion is the resultant list.
${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
\fBPattern substitution\fP.
The \fIpattern\fP is expanded to produce a pattern just as in
pathname expansion.
pathname expansion,
\fIParameter\fP is expanded and the longest match of \fIpattern\fP
against its value is replaced with \fIstring\fP.
The match is performed using the rules described under
.B Pattern Matching
below.
If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are
replaced with \fIstring\fP. Normally only the first match is replaced.
If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
@@ -3202,7 +3285,7 @@ format that can be reused as input.
.TP
.B E
The expansion is a string that is the value of \fIparameter\fP with backslash
escape sequences expanded as with the \fB$'...'\fP quoting mechansim.
escape sequences expanded as with the \fB$'...'\fP quoting mechanism.
.TP
.B P
The expansion is a string that is the result of expanding the value of
@@ -3232,7 +3315,7 @@ is an array variable subscripted with
.B @
or
.BR * ,
the case modification operation is applied to each member of the
the operation is applied to each member of the
array in turn, and the expansion is the resultant list.
.sp 1
The result of the expansion is subject to word splitting and pathname
@@ -3372,7 +3455,7 @@ are ignored at the beginning and end of the
word, as long as the whitespace character is in the
value of
.SM
.BR IFS
.B IFS
(an
.SM
.B IFS
@@ -3455,11 +3538,22 @@ at the start of a name or immediately following a slash
must be matched explicitly, unless the shell option
.B dotglob
is set.
When matching a pathname, the slash character must always be
matched explicitly.
The filenames
.B ``.''
and
.B ``..''
must always be matched explicitly, even if
.B dotglob
is set.
In other cases, the
.B ``.''
character is not treated specially.
When matching a pathname, the slash character must always be
matched explicitly by a slash in the pattern, but in other matching
contexts it can be matched by a special pattern character as described
below under
.SM
.BR "Pattern Matching" .
See the description of
.B shopt
below under
@@ -3476,12 +3570,12 @@ shell options.
The
.SM
.B GLOBIGNORE
shell variable may be used to restrict the set of filenames matching a
shell variable may be used to restrict the set of file names matching a
.IR pattern .
If
.SM
.B GLOBIGNORE
is set, each matching filename that also matches one of the patterns in
is set, each matching file name that also matches one of the patterns in
.SM
.B GLOBIGNORE
is removed from the list of matches.
@@ -3654,6 +3748,12 @@ Matches one of the given patterns
Matches anything except one of the given patterns
.RE
.PD
.PP
Complicated extended pattern matching against long strings is slow,
especially when the patterns contain alternations and the strings
contain multiple matches.
Using separate matches against shorter strings, or using arrays of
strings instead of a single long string, may be faster.
.SS Quote Removal
.PP
After the preceding expansions, all unquoted occurrences of the
@@ -3689,6 +3789,9 @@ than or equal to 10 and assign it to \fIvarname\fP.
If >&- or <&- is preceded
by {\fIvarname\fP}, the value of \fIvarname\fP defines the file
descriptor to close.
If {\fIvarname\fP} is supplied, the redirection persists beyond
the scope of the command, allowing the shell programmer to manage
the file descriptor himself.
.PP
In the following descriptions, if the file descriptor number is
omitted, and the first character of the redirection operator is
@@ -3952,7 +4055,7 @@ A variant of here documents, the format is:
.RE
.PP
The \fIword\fP undergoes
brace expansion, tilde expansion, parameter and variable expansion,
tilde expansion, parameter and variable expansion,
command substitution, arithmetic expansion, and quote removal.
Pathname expansion and word splitting are not performed.
The result is supplied as a single string, with a newline appended,
@@ -4178,6 +4281,44 @@ Variables local to the function may be declared with the
.B local
builtin command. Ordinarily, variables and their values
are shared between the function and its caller.
If a variable is declared \fBlocal\fP, the variable's visible scope
is restricted to that function and its children (including the functions
it calls).
Local variables "shadow" variables with the same name declared at
previous scopes.
For instance, a local variable declared in a function
hides a global variable of the same name: references and assignments
refer to the local variable, leaving the global variable unmodified.
When the function returns, the global variable is once again visible.
.PP
The shell uses \fIdynamic scoping\fP to control a variable's visibility
within functions.
With dynamic scoping, visible variables and their values
are a result of the sequence of function calls that caused execution
to reach the current function.
The value of a variable that a function sees depends
on its value within its caller, if any, whether that caller is
the "global" scope or another shell function.
This is also the value that a local variable
declaration "shadows", and the value that is restored when the function
returns.
.PP
For example, if a variable \fIvar\fP is declared as local in function
\fIfunc1\fP, and \fIfunc1\fP calls another function \fIfunc2\fP,
references to \fIvar\fP made from within \fIfunc2\fP will resolve to the
local variable \fIvar\fP from \fIfunc1\fP, shadowing any global variable
named \fIvar\fP.
.PP
The \fBunset\fP builtin also acts using the same dynamic scope: if a
variable is local to the current scope, \fBunset\fP will unset it;
otherwise the unset will refer to the variable found in any calling scope
as described above.
If a variable at the current local scope is unset, it will remain so
until it is reset in that scope or until the function returns.
Once the function returns, any instance of the variable at a previous
scope will become visible.
If the unset acts on a variable at a previous scope, any instance of a
variable with that name that had been shadowed will become visible.
.PP
The \fBFUNCNEST\fP variable, if set to a numeric value greater
than 0, defines a maximum function nesting level. Function
@@ -4222,10 +4363,6 @@ A function definition may be deleted using the \fB\-f\fP option to
the
.B unset
builtin.
Note that shell functions and variables with the same name may result
in multiple identically-named entries in the environment passed to the
shell's children.
Care should be taken in cases where this may cause a problem.
.PP
Functions may be recursive.
The \fBFUNCNEST\fP variable may be used to limit the depth of the
@@ -4308,7 +4445,7 @@ A shell variable that is null or unset evaluates to 0 when referenced
by name without using the parameter expansion syntax.
The value of a variable is evaluated as an arithmetic expression
when it is referenced, or when a variable which has been given the
\fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
\fIinteger\fP attribute using \fBdeclare \-i\fP is assigned a value.
A null value evaluates to 0.
A shell variable need not have its \fIinteger\fP attribute
turned on to be used in an expression.
@@ -4501,6 +4638,14 @@ greater than, or greater than or equal to \fIarg2\fP, respectively.
and
.I arg2
may be positive or negative integers.
When used with the \fB[[\fP command,
.I Arg1
and
.I Arg2
are evaluated as arithmetic expressions (see
.SM
.B "ARITHMETIC EVALUATION"
above).
.PD
.SH "SIMPLE COMMAND EXPANSION"
When a simple command is executed, the shell performs the following
@@ -4573,9 +4718,10 @@ A full search of the directories in
is performed only if the command is not found in the hash table.
If the search is unsuccessful, the shell searches for a defined shell
function named \fBcommand_not_found_handle\fP.
If that function exists, it is invoked with the original command and
If that function exists, it is invoked in a separate execution environment
with the original command and
the original command's arguments as its arguments, and the function's
exit status becomes the exit status of the shell.
exit status becomes the exit status of that subshell.
If that function is not defined, the shell prints an error
message and returns an exit status of 127.
.PP
@@ -5030,6 +5176,11 @@ command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
the shell does not print another warning, and any stopped
jobs are terminated.
.PP
When the shell is waiting for a job or process using the \fBwait\fP
builtin, and job control is enabled, \fBwait\fP will return when the
job changes state. The \fB\-f\fP option will force \fBwait\fP to wait
until the job or process terminates before returning.
.SH PROMPTING
When executing interactively,
.B bash
@@ -5042,9 +5193,16 @@ when it is ready to read a command, and the secondary prompt
when it needs more input to complete a command.
.B Bash
displays
.SM
.B PS0
after it reads a command but before executing it.
.B Bash
displays
.SM
.B PS4
as described above
before tracing each command when the \fB\-x\fP option is enabled.
.B Bash
allows these prompt strings to be customized by inserting a number of
backslash-escaped special characters that are decoded as follows:
.RS
@@ -5497,13 +5655,13 @@ in emacs mode and to
.B #
in vi command mode.
.TP
.B completion\-display\-width (-1)
.B completion\-display\-width (\-1)
The number of screen columns used to display possible matches
when performing completion.
The value is ignored if it is less than 0 or greater than the terminal
screen width.
A value of 0 will cause matches to be displayed one per line.
The default value is -1.
The default value is \-1.
.TP
.B completion\-ignore\-case (Off)
If set to \fBOn\fP, readline performs filename matching and completion
@@ -5557,6 +5715,16 @@ can be set to either
or
.BR vi .
.TP
.B emacs\-mode\-string (@)
If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \e1 and \e2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B enable\-bracketed\-paste (Off)
When set to \fBOn\fP, readline will configure the terminal in a way
that will enable it to insert each paste into the editing buffer as a
@@ -5626,15 +5794,6 @@ the value of
.B editing\-mode
also affects the default keymap.
.TP
.B emacs\-mode\-string (@)
This string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \e1 and \e2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B keyseq\-timeout (500)
Specifies the duration \fIreadline\fP will wait for a character when reading an
ambiguous key sequence (one that can form a complete key sequence using
@@ -5712,9 +5871,9 @@ a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
.TP
.B show\-mode\-in\-prompt (Off)
If set to \fBOn\fP, add a character to the beginning of the prompt
indicating the editing mode: emacs (@), vi command (:) or vi
insertion (+).
If set to \fBOn\fP, add a string to the beginning of the prompt
indicating the editing mode: emacs, vi command, or vi insertion.
The mode strings are user-settable (e.g., \fIemacs\-mode\-string\fP).
.TP
.B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when
@@ -5725,7 +5884,8 @@ after point in the word being completed, so portions of the word
following the cursor are not duplicated.
.TP
.B vi\-cmd\-mode\-string ((cmd))
This string is displayed immediately before the last line of the primary
If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in command mode.
The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
@@ -5735,7 +5895,8 @@ non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B vi\-ins\-mode\-string ((ins))
This string is displayed immediately before the last line of the primary
If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in insertion mode.
The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
@@ -5760,8 +5921,9 @@ The
.B $if
construct allows bindings to be made based on the
editing mode, the terminal being used, or the application using
readline. The text of the test extends to the end of the line;
no characters are required to isolate it.
readline. The text of the test, after any comparison operator,
extends to the end of the line;
unless otherwise noted, no characters are required to isolate it.
.RS
.IP \fBmode\fP
The \fBmode=\fP form of the \fB$if\fP directive is used to test
@@ -5783,6 +5945,26 @@ to match both
and
.IR sun\-cmd ,
for instance.
.IP \fBversion\fP
The \fBversion\fP test may be used to perform comparisons against
specific readline versions.
The \fBversion\fP expands to the current readline version.
The set of comparison operators includes
.BR = ,
(and
.BR == ),
.BR != ,
.BR <= ,
.BR >= ,
.BR < ,
and
.BR > .
The version number supplied on the right side of the operator consists
of a major version number, an optional decimal point, and an optional
minor version (e.g., \fB7.1\fP). If the minor version is omitted, it
is assumed to be \fB0\fP.
The operator may be separated from the string \fBversion\fP
and from the version number argument by whitespace.
.IP \fBapplication\fP
The \fBapplication\fP construct is used to include
application-specific settings. Each program using the readline
@@ -5800,6 +5982,15 @@ key sequence that quotes the current or previous word in \fBbash\fP:
\fB$endif\fP
.fi
.RE
.IP \fIvariable\fP
The \fIvariable\fP construct provides simple equality tests for readline
variables and values.
The permitted comparison operators are \fI=\fP, \fI==\fP, and \fI!=\fP.
The variable name must be separated from the comparison operator by
whitespace; the operator may be separated from the value on the right hand
side by whitespace.
Both string and boolean variables may be tested. Boolean variables must be
tested against the values \fIon\fP and \fIoff\fP.
.RE
.IP \fB$endif\fP
This command, as seen in the previous example, terminates an
@@ -5901,6 +6092,19 @@ Words are delimited by non-quoted shell metacharacters.
Move back to the start of the current or previous word.
Words are delimited by non-quoted shell metacharacters.
.TP
.B previous\-screen\-line
Attempt to move point to the same physical screen column on the previous
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if point is not
greater than the length of the prompt plus the screen width.
.TP
.B next\-screen\-line
Attempt to move point to the same physical screen column on the next
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
.TP
.B clear\-screen (C\-l)
Clear the screen leaving the current line at the top of the screen.
With an argument, refresh the current line without clearing the
@@ -5962,6 +6166,19 @@ Search backward through the history for the string of characters
between the start of the current line and the point.
This is a non-incremental search.
.TP
.B history\-substring\-search\-backward
Search backward through the history for the string of characters
between the start of the current line and the current cursor
position (the \fIpoint\fP).
The search string may match anywhere in a history line.
This is a non-incremental search.
.TP
.B history\-substring\-search\-forward
Search forward through the history for the string of characters
between the start of the current line and the point.
The search string may match anywhere in a history line.
This is a non-incremental search.
.TP
.B yank\-nth\-arg (M\-C\-y)
Insert the first argument to the previous command (usually
the second word on the previous line) at point.
@@ -6024,10 +6241,11 @@ A synonym for \fByank\-last\-arg\fP.
.TP
.B operate\-and\-get\-next (C\-o)
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing. Any
argument is ignored.
relative to the current line from the history for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.TP
.B edit\-and\-execute\-command (C\-xC\-e)
.B edit\-and\-execute\-command (C\-x C\-e)
Invoke an editor on the current command line, and execute the result as shell
commands.
\fBBash\fP attempts to invoke
@@ -6342,9 +6560,10 @@ Abort the current editing command and
ring the terminal's bell (subject to the setting of
.BR bell\-style ).
.TP
.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
If the metafied character \fIx\fP is lowercase, run the command
that is bound to the corresponding uppercase character.
.B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, ...)
If the metafied character \fIx\fP is uppercase, run the command
that is bound to the corresponding metafied lowercase character.
The behavior is undefined if \fIx\fP is already lowercase.
.TP
.B prefix\-meta (ESC)
Metafy the next character typed.
@@ -6608,7 +6827,7 @@ of the setting of the \fBmark-symlinked\-directories\fP readline variable.
.PP
There is some support for dynamically modifying completions. This is
most useful when used in combination with a default completion specified
with \fBcomplete -D\fP.
with \fBcomplete \-D\fP.
It's possible for shell functions executed as completion
handlers to indicate that completion should be retried by returning an
exit status of 124. If a shell function returns 124, and changes
@@ -6679,7 +6898,7 @@ If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value,
or a numeric value less than zero, the history file is not truncated.
When the history file is read,
lines beginning with the history comment character followed immediately
by a digit are interpreted as timestamps for the preceding history line.
by a digit are interpreted as timestamps for the following history line.
These timestamps are optionally displayed depending on the value of the
.SM
.B HISTTIMEFORMAT
@@ -6765,7 +6984,7 @@ for information on setting and unsetting shell options.
.PP
The shell supports a history expansion feature that
is similar to the history expansion in
.BR csh.
.BR csh .
This section describes what syntax features are available. This
feature is enabled by default for interactive shells, and can be
disabled using the
@@ -6784,7 +7003,9 @@ arguments to a previous command into the current input line, or
fix errors in previous commands quickly.
.PP
History expansion is performed immediately after a complete line
is read, before the shell breaks it into words.
is read, before the shell breaks it into words, and is performed
on each line individually without taking quoting on previous lines into
account.
It takes place in two parts.
The first is to determine which line from the history list
to use during substitution.
@@ -7045,7 +7266,7 @@ section as accepting options preceded by
accepts
.B \-\-
to signify the end of the options.
The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP/\fB[\fP builtins
do not accept options and do not treat \fB\-\-\fP specially.
The \fBexit\fP, \fBlogout\fP, \fBreturn\fP,
\fBbreak\fP, \fBcontinue\fP, \fBlet\fP,
@@ -7609,6 +7830,12 @@ The \fIwordlist\fP is split using the characters in the
.SM
.B IFS
special variable as delimiters, and each resultant word is expanded.
Shell quoting is honored within \fIwordlist\fP,
in order to provide a
mechanism for the words to contain shell metacharacters or characters
in the value of
.SM
.BR IFS .
The possible completions are the members of the resultant list which
match the word being completed.
.TP 8
@@ -8020,6 +8247,7 @@ unless the
shell option
is enabled. In that case, it returns failure.
An interactive shell returns failure if the file cannot be executed.
A subshell exits unconditionally if \fBexec\fP fails.
If
.I command
is not specified, any redirections take effect in the current shell,
@@ -8089,7 +8317,7 @@ with that string) or as a number (an index into the history list,
where a negative number is used as an offset from the current
command number). If
.I last
is not specified it is set to
is not specified, it is set to
the current command for listing (so that
.if n ``fc \-l \-10''
.if t \f(CWfc \-l \-10\fP
@@ -8098,7 +8326,7 @@ prints the last 10 commands) and to
otherwise.
If
.I first
is not specified it is set to the previous
is not specified, it is set to the previous
command for editing and \-16 for listing.
.sp 1
The
@@ -8134,7 +8362,7 @@ echoed and executed.
.sp 1
In the second form, \fIcommand\fP is re-executed after each instance
of \fIpat\fP is replaced by \fIrep\fP.
\fICommand\fP is intepreted the same as \fIfirst\fP above.
\fICommand\fP is interpreted the same as \fIfirst\fP above.
A useful alias to use with this is
.if n ``r="fc -s"'',
.if t \f(CWr='fc \-s'\fP,
@@ -8353,6 +8581,8 @@ The return status is 0 unless no command matches
.TP
\fBhistory \-d\fP \fIoffset\fP
.TP
\fBhistory \-d\fP \fIstart\fP\-\fIend\fP
.TP
\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
.TP
\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
@@ -8389,6 +8619,15 @@ Clear the history list by deleting all the entries.
.TP
\fB\-d\fP \fIoffset\fP
Delete the history entry at position \fIoffset\fP.
If \fIoffset\fP is negative, it is interpreted as relative to one greater
than the last history position, so negative indices count back from the
end of the history, and an index of \-1 refers to the current
\fBhistory -d\fP command.
.TP
\fB\-d\fP \fIstart\fP\-\fIend\fP
Delete the history entries between positions \fIstart\fP and \fIend\fP,
inclusive. Positive and negative values for \fIstart\fP and \fIend\fP
are interpreted as described above.
.TP
.B \-a
Append the ``new'' history lines to the history file.
@@ -8591,7 +8830,7 @@ Exit a login shell.
Read lines from the standard input into the indexed array variable
.IR array ,
or from file descriptor
.IR fd
.I fd
if the
.B \-u
option is supplied.
@@ -8606,6 +8845,8 @@ Options, if supplied, have the following meanings:
.B \-d
The first character of \fIdelim\fP is used to terminate each input line,
rather than newline.
If \fIdelim\fP is the empty string, \fBmapfile\fP will terminate a line
when it reads a NUL character.
.TP
.B \-n
Copy at most
@@ -8738,9 +8979,9 @@ causes \fBprintf\fP to output the date-time string resulting from using
\fIdatefmt\fP as a format string for \fIstrftime\fP(3).
The corresponding \fIargument\fP is an integer representing the number of
seconds since the epoch.
Two special argument values may be used: -1 represents the current
time, and -2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if -1 had been given.
Two special argument values may be used: \-1 represents the current
time, and \-2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if \-1 had been given.
This is an exception to the usual \fBprintf\fP behavior.
.PD
.PP
@@ -8865,6 +9106,8 @@ Other \fIname\fP arguments are ignored.
.B \-d \fIdelim\fP
The first character of \fIdelim\fP is used to terminate the input line,
rather than newline.
If \fIdelim\fP is the empty string, \fBread\fP will terminate a line
when it reads a NUL character.
.TP
.B \-e
If the standard input
@@ -8875,7 +9118,7 @@ is coming from a terminal,
.B READLINE
above) is used to obtain the line.
Readline uses the current (or default, if line editing was not previously
active) editing settings.
active) editing settings, but uses Readline's default filename completion.
.TP
.B \-i \fItext\fP
If
@@ -8996,7 +9239,7 @@ is omitted, the return status is that of the last command
executed in the function body.
If \fBreturn\fP is executed by a trap handler, the last command used to
determine the status is the last command executed before the trap handler.
if \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command
If \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command
used to determine the status is the last command executed by the trap
handler before \fBreturn\fP was invoked.
If
@@ -9426,7 +9669,8 @@ option to the \fBset\fP builtin command.
With no options, or with the
.B \-p
option, a list of all settable options is displayed, with
an indication of whether or not each is set.
an indication of whether or not each is set;
if \fIoptnames\fP are supplied, the output is restricted to those options.
The \fB\-p\fP option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@@ -9475,6 +9719,11 @@ The list of \fBshopt\fP options is:
.if n .sp 1v
.PD 0
.TP 8
.B assoc_expand_once
If set, the shell suppresses multiple evaluation of associative array
subscripts during arithmetic expression evaluation and while executing
builtins that can perform variable assignments.
.TP 8
.B autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the \fBcd\fP command.
@@ -9513,8 +9762,8 @@ above). The shell always
postpones exiting if any jobs are stopped.
.TP 8
.B checkwinsize
If set, \fBbash\fP checks the window size after each command
and, if necessary, updates the values of
If set, \fBbash\fP checks the window size after each external (non-builtin)
command and, if necessary, updates the values of
.SM
.B LINES
and
@@ -9527,6 +9776,10 @@ If set,
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
This option is enabled by default, but only has an effect if command
history is enabled, as described above under
.SM
.BR HISTORY .
.TP 8
.B compat31
If set,
@@ -9588,6 +9841,12 @@ and does not reset the
loop state when a shell function is executed (this allows \fBbreak\fP or
\fBcontinue\fP in a shell function to affect loops in the caller's context).
.TP 8
.B compat44
If set,
.B bash
saves the positional parameters to BASH_ARGV and BASH_ARGC before they are
used, regardless of whether or not extended debugging mode is enabled.
.TP 8
.B complete_fullquote
If set,
.B bash
@@ -9628,6 +9887,13 @@ If set,
.B bash
includes filenames beginning with a `.' in the results of pathname
expansion.
The filenames
.B ``.''
and
.B ``..''
must always be matched explicitly, even if
.B dotglob
is set.
.TP 8
.B execfail
If set, a non-interactive shell will not exit if
@@ -9797,6 +10063,11 @@ If set, and the
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
.TP 8
.B localvar_inherit
If set, local variables inherit the value and attributes of a variable of
the same name that exists at a previous scope before any new value is
assigned. The nameref attribute is not inherited.
.TP 8
.B login_shell
The shell sets this option if it is started as a login shell (see
.SM
@@ -10410,20 +10681,23 @@ subsequently reset. The exit status is true unless a
.I name
is readonly.
.TP
\fBwait\fP [\fB\-n\fP] [\fIn ...\fP]
\fBwait\fP [\fB\-fn\fP] [\fIid ...\fP]
Wait for each specified child process and return its termination status.
Each
.I n
.I id
may be a process
ID or a job specification; if a job spec is given, all processes
in that job's pipeline are waited for. If
.I n
.I id
is not given, all currently active child processes
are waited for, and the return status is zero.
If the \fB\-n\fP option is supplied, \fBwait\fP waits for any job to
terminate and returns its exit status.
If the \fB\-f\fP option is supplied, and job control is enabled,
\fBwait\fP forces \fIid\fP to terminate before returning its status,
instead of returning when it changes status.
If
.I n
.I id
specifies a non-existent process or job, the return status is
127. Otherwise, the return status is the exit status of the last
process or job waited for.
+404 -81
View File
@@ -3,7 +3,7 @@
</HEAD>
<BODY><TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2016 August 26<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>BASH(1)<TH ALIGN=CENTER width=33%>2018 March 15<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<BR><A HREF="#index">Index</A>
@@ -42,7 +42,7 @@ bash - GNU Bourne-Again SHell
<H3>COPYRIGHT</H3>
Bash is Copyright &#169; 1989-2016 by the Free Software Foundation, Inc.
Bash is Copyright &#169; 1989-2018 by the Free Software Foundation, Inc.
<A NAME="lbAE">&nbsp;</A>
<H3>DESCRIPTION</H3>
@@ -68,8 +68,8 @@ can be configured to be POSIX-conformant by default.
<H3>OPTIONS</H3>
All of the single-character shell options documented in the
description of the <B>set</B> builtin command can be used as options
when the shell is invoked.
description of the <B>set</B> builtin command, including <B>-o</B>,
can be used as options when the shell is invoked.
In addition, <B>bash</B>
interprets the following options when it is invoked:
<P>
@@ -139,7 +139,8 @@ If the
option is present, or if no arguments remain after option
processing, then commands are read from the standard input.
This option allows the positional parameters to be set
when invoking an interactive shell.
when invoking an interactive shell or when reading input
through a pipe.
<DT><B>-D</B>
<DD>
@@ -780,6 +781,12 @@ the time information.
Each command in a pipeline is executed as a separate process (i.e., in a
subshell).
See
<FONT SIZE=-1><B>COMMAND EXECUTION ENVIRONMENT</B></FONT>
for a description of a subshell environment.
If the <B>lastpipe</B> option is enabled using the <B>shopt</B> builtin
(see the description of <B>shopt</B> below),
the last element of a pipeline may be run by the shell process.
<A NAME="lbAN">&nbsp;</A>
<H4>Lists</H4>
@@ -855,7 +862,7 @@ An AND list has the form
is executed if, and only if,
<I>command1</I>
returns an exit status of zero.
returns an exit status of zero (success).
<P>
An OR list has the form
@@ -871,7 +878,7 @@ An OR list has the form
<I>command2</I>
is executed if and only if
is executed if, and only if,
<I>command1</I>
returns a non-zero exit status.
@@ -1110,11 +1117,11 @@ or zero if no commands were executed.
<DT><B>case</B> <I>word</I> <B>in</B> [ [(] <I>pattern</I> [ <B>|</B> <I>pattern</I> ]
<DD>
A <B>case</B> command first expands <I>word</I>, and tries to match
it against each <I>pattern</I> in turn, using the same matching rules
as for pathname expansion (see
<B>Pathname Expansion</B>
it against each <I>pattern</I> in turn, using the matching rules
described under
<B>Pattern Matching</B>
below).
below.
The <I>word</I> is expanded using tilde
expansion, parameter and variable expansion, arithmetic expansion,
command substitution, process substitution and quote removal.
@@ -1217,7 +1224,8 @@ command (see
below).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
The file descriptors are not available in subshells.
Other than those created to execute command and process substitutions,
the file descriptors are not available in subshells.
The process ID of the shell spawned to execute the coprocess is
available as the value of the variable <I>NAME</I>_PID.
The <B>wait</B>
@@ -1463,7 +1471,7 @@ question mark
<DD>
the eight-bit character whose value is the octal value <I>nnn</I>
(one to three digits)
(one to three octal digits)
<DT><B>\x</B><I>HH</I>
<DD>
@@ -1868,6 +1876,16 @@ This variable is read-only.
Expands to the process ID of the current <B>bash</B> process.
This differs from <B>$$</B> under certain circumstances, such as subshells
that do not require <B>bash</B> to be re-initialized.
Assignments to
<FONT SIZE=-1><B>BASHPID</B>
</FONT>
have no effect.
If
<B>BASHPID</B>
is unset, it loses its special properties, even if it is
subsequently reset.
<DT><B>BASH_ALIASES</B>
<DD>
@@ -1903,7 +1921,9 @@ only when in extended debugging mode (see the description of the
option to the
<B>shopt</B>
builtin below)
builtin below).
Setting <B>extdebug</B> after the shell has started to execute a script
may result in inconsistent values.
<DT><B>BASH_ARGV</B>
<DD>
@@ -1926,7 +1946,26 @@ only when in extended debugging mode
option to the
<B>shopt</B>
builtin below)
builtin below).
Setting <B>extdebug</B> after the shell has started to execute a script
may result in inconsistent values.
<DT><B>BASH_ARGV0</B>
<DD>
When referenced, this variable expands to the name of the shell or shell
script (identical to
<B>$0</B>;
see the description of special parameter 0 above).
Assignment to
<B>BASH_ARGV0</B>
causes the value assigned to also be assigned to <B>$0</B>.
If
<B>BASH_ARGV0</B>
is unset, it loses its special properties, even if it is
subsequently reset.
<DT><B>BASH_CMDS</B>
<DD>
@@ -2152,6 +2191,39 @@ Assignment to this variable will not change the current directory.
If
<FONT SIZE=-1><B>DIRSTACK</B>
</FONT>
is unset, it loses its special properties, even if it is
subsequently reset.
<DT><B>EPOCHREALTIME</B>
<DD>
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch (see <I>time</I>(3)) as a floating point value
with micro-second granularity.
Assignments to
<FONT SIZE=-1><B>EPOCHREALTIME</B>
</FONT>
are ignored.
If
<FONT SIZE=-1><B>EPOCHREALTIME</B>
</FONT>
is unset, it loses its special properties, even if it is
subsequently reset.
<DT><B>EPOCHSECONDS</B>
<DD>
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch (see <I>time</I>(3)).
Assignments to
<FONT SIZE=-1><B>EPOCHSECONDS</B>
</FONT>
are ignored.
If
<FONT SIZE=-1><B>EPOCHSECONDS</B>
</FONT>
is unset, it loses its special properties, even if it is
subsequently reset.
@@ -2612,9 +2684,9 @@ will cause the current command to abort.
<DT><B>GLOBIGNORE</B>
<DD>
A colon-separated list of patterns defining the set of filenames to
A colon-separated list of patterns defining the set of file names to
be ignored by pathname expansion.
If a filename matched by a pathname expansion pattern also matches one
If a file name matched by a pathname expansion pattern also matches one
of the patterns in
<FONT SIZE=-1><B>GLOBIGNORE</B>,
@@ -3035,6 +3107,7 @@ and the value is printed before each command
<B>bash</B>
displays during an execution trace. The first character of
the expanded value of
<FONT SIZE=-1><B>PS4</B>
</FONT>
@@ -3327,15 +3400,21 @@ The
<B>unset</B>
builtin is used to destroy arrays. <B>unset</B> <I>name</I>[<I>subscript</I>]
destroys the array element at index <I>subscript</I>.
destroys the array element at index <I>subscript</I>,
for both indexed and associative arrays.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by pathname
expansion.
Unsetting the last element of an array variable does not unset the variable.
<B>unset</B> <I>name</I>, where <I>name</I> is an array, or
<B>unset</B> <I>name</I>[<I>subscript</I>], where
<I>subscript</I> is <B>*</B> or <B>@</B>, removes the entire array.
<P>
When using a variable name with a subscript as an argument to a command,
such as with <B>unset</B>, without using the word expansion syntax
described above, the argument is subject to pathname expansion.
If pathname expansion is not desired, the argument should be quoted.
<P>
The
<B>declare</B>,
@@ -3413,10 +3492,11 @@ original word are removed unless they have been quoted themselves
<P>
Only brace expansion, word splitting, and pathname expansion
can change the number of words of the expansion; other expansions
can increase the number of words of the expansion; other expansions
expand a single word to a single word.
The only exceptions to this are the expansions of
&quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;
&quot;<B>$@</B>&quot; and &quot;<B>${</B><I>name</I><B>[@]}</B>&quot;,
and, in most cases, <B>$*</B> and <B>${</B><I>name</I><B>[*]}</B>
as explained above (see
<FONT SIZE=-1><B>PARAMETERS</B>).
@@ -3485,7 +3565,8 @@ Any incorrectly formed brace expansion is left unchanged.
A <B>{</B> or <B>,</B> may be quoted with a backslash to prevent its
being considered part of a brace expression.
To avoid conflicts with parameter expansion, the string <B>${</B>
is not considered eligible for brace expansion.
is not considered eligible for brace expansion, and inhibits brace
expansion until the closing <B>}</B>.
<P>
This construct is typically used as shorthand when the common
@@ -3663,6 +3744,8 @@ it introduces a level of variable indirection.
expanded and that value is used in the rest of the substitution, rather
than the value of <I>parameter</I> itself.
This is known as <I>indirect expansion</I>.
The value is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
If <I>parameter</I> is a nameref, this expands to the name of the
variable referenced by <I>parameter</I> instead of performing the
complete indirect expansion.
@@ -3848,7 +3931,14 @@ The
<I>word</I>
is expanded to produce a pattern just as in pathname
expansion. If the pattern matches the beginning of
expansion, and matched against the expanded value of
<I>parameter</I>
using the rules described under
<B>Pattern Matching</B>
below.
If the pattern matches the beginning of
the value of
<I>parameter</I>,
@@ -3885,7 +3975,13 @@ array in turn, and the expansion is the resultant list.
<B>Remove matching suffix pattern</B>.
The <I>word</I> is expanded to produce a pattern just as in
pathname expansion.
pathname expansion, and matched against the expanded value of
<I>parameter</I>
using the rules described under
<B>Pattern Matching</B>
below.
If the pattern matches a trailing portion of the expanded value of
<I>parameter</I>,
@@ -3919,9 +4015,13 @@ array in turn, and the expansion is the resultant list.
<DT>${<I>parameter</I><B>/</B><I>pattern</I><B>/</B><I>string</I>}<DD>
<B>Pattern substitution</B>.
The <I>pattern</I> is expanded to produce a pattern just as in
pathname expansion.
pathname expansion,
<I>Parameter</I> is expanded and the longest match of <I>pattern</I>
against its value is replaced with <I>string</I>.
The match is performed using the rules described under
<B>Pattern Matching</B>
below.
If <I>pattern</I> begins with <B>/</B>, all matches of <I>pattern</I> are
replaced with <I>string</I>. Normally only the first match is replaced.
If <I>pattern</I> begins with <B>#</B>, it must match at the beginning
@@ -4018,7 +4118,7 @@ format that can be reused as input.
<DD>
The expansion is a string that is the value of <I>parameter</I> with backslash
escape sequences expanded as with the <B>$'...'</B> quoting mechansim.
escape sequences expanded as with the <B>$'...'</B> quoting mechanism.
<DT><B>P</B>
<DD>
@@ -4059,7 +4159,7 @@ is an array variable subscripted with
or
<B>*</B>,
the case modification operation is applied to each member of the
the operation is applied to each member of the
array in turn, and the expansion is the resultant list.
<P>
The result of the expansion is subject to word splitting and pathname
@@ -4354,12 +4454,27 @@ must be matched explicitly, unless the shell option
<B>dotglob</B>
is set.
When matching a pathname, the slash character must always be
matched explicitly.
The filenames
<B>``.''</B>
and
<B>``..''</B>
must always be matched explicitly, even if
<B>dotglob</B>
is set.
In other cases, the
<B>``.''</B>
character is not treated specially.
When matching a pathname, the slash character must always be
matched explicitly by a slash in the pattern, but in other matching
contexts it can be matched by a special pattern character as described
below under
<FONT SIZE=-1><B>Pattern Matching</B>.
</FONT>
See the description of
<B>shopt</B>
@@ -4384,14 +4499,14 @@ The
<FONT SIZE=-1><B>GLOBIGNORE</B>
</FONT>
shell variable may be used to restrict the set of filenames matching a
shell variable may be used to restrict the set of file names matching a
<I>pattern</I>.
If
<FONT SIZE=-1><B>GLOBIGNORE</B>
</FONT>
is set, each matching filename that also matches one of the patterns in
is set, each matching file name that also matches one of the patterns in
<FONT SIZE=-1><B>GLOBIGNORE</B>
</FONT>
@@ -4613,6 +4728,13 @@ Matches anything except one of the given patterns
</DL></DL>
<P>
Complicated extended pattern matching against long strings is slow,
especially when the patterns contain alternations and the strings
contain multiple matches.
Using separate matches against shorter strings, or using arrays of
strings instead of a single long string, may be faster.
<A NAME="lbBH">&nbsp;</A>
<H4>Quote Removal</H4>
@@ -4659,6 +4781,9 @@ than or equal to 10 and assign it to <I>varname</I>.
If &gt;&amp;- or &lt;&amp;- is preceded
by {<I>varname</I>}, the value of <I>varname</I> defines the file
descriptor to close.
If {<I>varname</I>} is supplied, the redirection persists beyond
the scope of the command, allowing the shell programmer to manage
the file descriptor himself.
<P>
In the following descriptions, if the file descriptor number is
@@ -5035,7 +5160,7 @@ A variant of here documents, the format is:
<P>
The <I>word</I> undergoes
brace expansion, tilde expansion, parameter and variable expansion,
tilde expansion, parameter and variable expansion,
command substitution, arithmetic expansion, and quote removal.
Pathname expansion and word splitting are not performed.
The result is supplied as a single string, with a newline appended,
@@ -5339,6 +5464,47 @@ Variables local to the function may be declared with the
builtin command. Ordinarily, variables and their values
are shared between the function and its caller.
If a variable is declared <B>local</B>, the variable's visible scope
is restricted to that function and its children (including the functions
it calls).
Local variables &quot;shadow&quot; variables with the same name declared at
previous scopes.
For instance, a local variable declared in a function
hides a global variable of the same name: references and assignments
refer to the local variable, leaving the global variable unmodified.
When the function returns, the global variable is once again visible.
<P>
The shell uses <I>dynamic scoping</I> to control a variable's visibility
within functions.
With dynamic scoping, visible variables and their values
are a result of the sequence of function calls that caused execution
to reach the current function.
The value of a variable that a function sees depends
on its value within its caller, if any, whether that caller is
the &quot;global&quot; scope or another shell function.
This is also the value that a local variable
declaration &quot;shadows&quot;, and the value that is restored when the function
returns.
<P>
For example, if a variable <I>var</I> is declared as local in function
<I>func1</I>, and <I>func1</I> calls another function <I>func2</I>,
references to <I>var</I> made from within <I>func2</I> will resolve to the
local variable <I>var</I> from <I>func1</I>, shadowing any global variable
named <I>var</I>.
<P>
The <B>unset</B> builtin also acts using the same dynamic scope: if a
variable is local to the current scope, <B>unset</B> will unset it;
otherwise the unset will refer to the variable found in any calling scope
as described above.
If a variable at the current local scope is unset, it will remain so
until it is reset in that scope or until the function returns.
Once the function returns, any instance of the variable at a previous
scope will become visible.
If the unset acts on a variable at a previous scope, any instance of a
variable with that name that had been shadowed will become visible.
<P>
The <B>FUNCNEST</B> variable, if set to a numeric value greater
@@ -5397,10 +5563,6 @@ the
<B>unset</B>
builtin.
Note that shell functions and variables with the same name may result
in multiple identically-named entries in the environment passed to the
shell's children.
Care should be taken in cases where this may cause a problem.
<P>
Functions may be recursive.
@@ -5742,6 +5904,17 @@ and
<I>arg2</I>
may be positive or negative integers.
When used with the <B>[[</B> command,
<I>Arg1</I>
and
<I>Arg2</I>
are evaluated as arithmetic expressions (see
<FONT SIZE=-1><B>ARITHMETIC EVALUATION</B>
</FONT>
above).
</DL>
<A NAME="lbBX">&nbsp;</A>
@@ -5834,9 +6007,10 @@ A full search of the directories in
is performed only if the command is not found in the hash table.
If the search is unsuccessful, the shell searches for a defined shell
function named <B>command_not_found_handle</B>.
If that function exists, it is invoked with the original command and
If that function exists, it is invoked in a separate execution environment
with the original command and
the original command's arguments as its arguments, and the function's
exit status becomes the exit status of the shell.
exit status becomes the exit status of that subshell.
If that function is not defined, the shell prints an error
message and returns an exit status of 127.
<P>
@@ -6427,6 +6601,12 @@ command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
the shell does not print another warning, and any stopped
jobs are terminated.
<P>
When the shell is waiting for a job or process using the <B>wait</B>
builtin, and job control is enabled, <B>wait</B> will return when the
job changes state. The <B>-f</B> option will force <B>wait</B> to wait
until the job or process terminates before returning.
<A NAME="lbCE">&nbsp;</A>
<H3>PROMPTING</H3>
@@ -6445,11 +6625,20 @@ when it needs more input to complete a command.
<B>Bash</B>
displays
<B>PS0</B>
<FONT SIZE=-1><B>PS0</B>
</FONT>
after it reads a command but before executing it.
<B>Bash</B>
displays
<FONT SIZE=-1><B>PS4</B>
</FONT>
as described above
before tracing each command when the <B>-x</B> option is enabled.
<B>Bash</B>
allows these prompt strings to be customized by inserting a number of
backslash-escaped special characters that are decoded as follows:
<DL COMPACT><DT><DD>
@@ -7134,6 +7323,17 @@ can be set to either
or
<B>vi</B>.
<DT><B>emacs-mode-string (@)</B>
<DD>
If the <I>show-mode-in-prompt</I> variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \1 and \2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
<DT><B>enable-bracketed-paste (Off)</B>
<DD>
@@ -7217,16 +7417,6 @@ the value of
<B>editing-mode</B>
also affects the default keymap.
<DT><B>emacs-mode-string (@)</B>
<DD>
This string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \1 and \2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
<DT><B>keyseq-timeout (500)</B>
<DD>
@@ -7320,9 +7510,9 @@ of ringing the bell.
<DT><B>show-mode-in-prompt (Off)</B>
<DD>
If set to <B>On</B>, add a character to the beginning of the prompt
indicating the editing mode: emacs (@), vi command (:) or vi
insertion (+).
If set to <B>On</B>, add a string to the beginning of the prompt
indicating the editing mode: emacs, vi command, or vi insertion.
The mode strings are user-settable (e.g., <I>emacs-mode-string</I>).
<DT><B>skip-completed-text (Off)</B>
<DD>
@@ -7335,7 +7525,8 @@ following the cursor are not duplicated.
<DT><B>vi-cmd-mode-string ((cmd))</B>
<DD>
This string is displayed immediately before the last line of the primary
If the <I>show-mode-in-prompt</I> variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in command mode.
The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
@@ -7346,7 +7537,8 @@ sequence into the mode string.
<DT><B>vi-ins-mode-string ((ins))</B>
<DD>
This string is displayed immediately before the last line of the primary
If the <I>show-mode-in-prompt</I> variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in insertion mode.
The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
@@ -7378,8 +7570,9 @@ The
construct allows bindings to be made based on the
editing mode, the terminal being used, or the application using
readline. The text of the test extends to the end of the line;
no characters are required to isolate it.
readline. The text of the test, after any comparison operator,
<BR>&nbsp;extends&nbsp;to&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;line;
unless otherwise noted, no characters are required to isolate it.
<DL COMPACT><DT><DD>
<DL COMPACT>
<DT><B>mode</B><DD>
@@ -7406,6 +7599,33 @@ and
<I>sun-cmd</I>,
for instance.
<DT><B>version</B><DD>
The <B>version</B> test may be used to perform comparisons against
specific readline versions.
The <B>version</B> expands to the current readline version.
The set of comparison operators includes
<B>=</B>,
(and
<B>==</B>),
<B>!=</B>,
<B>&lt;=</B>,
<B>&gt;=</B>,
<B>&lt;</B>,
and
<B>&gt;</B>.
The version number supplied on the right side of the operator consists
of a major version number, an optional decimal point, and an optional
minor version (e.g., <B>7.1</B>). If the minor version is omitted, it
is assumed to be <B>0</B>.
The operator may be separated from the string <B>version</B>
and from the version number argument by whitespace.
<DT><B>application</B><DD>
The <B>application</B> construct is used to include
application-specific settings. Each program using the readline
@@ -7425,6 +7645,15 @@ key sequence that quotes the current or previous word in <B>bash</B>:
</DL>
<DT><I>variable</I><DD>
The <I>variable</I> construct provides simple equality tests for readline
variables and values.
The permitted comparison operators are <I>=</I>, <I>==</I>, and <I>!=</I>.
The variable name must be separated from the comparison operator by
whitespace; the operator may be separated from the value on the right hand
side by whitespace.
Both string and boolean variables may be tested. Boolean variables must be
tested against the values <I>on</I> and <I>off</I>.
</DL></DL>
<DT><B>$endif</B><DD>
@@ -7554,6 +7783,21 @@ Words are delimited by non-quoted shell metacharacters.
<DD>
Move back to the start of the current or previous word.
Words are delimited by non-quoted shell metacharacters.
<DT><B>previous-screen-line</B>
<DD>
Attempt to move point to the same physical screen column on the previous
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if point is not
greater than the length of the prompt plus the screen width.
<DT><B>next-screen-line</B>
<DD>
Attempt to move point to the same physical screen column on the next
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
<DT><B>clear-screen (C-l)</B>
<DD>
@@ -7634,6 +7878,21 @@ This is a non-incremental search.
Search backward through the history for the string of characters
between the start of the current line and the point.
This is a non-incremental search.
<DT><B>history-substring-search-backward</B>
<DD>
Search backward through the history for the string of characters
between the start of the current line and the current cursor
position (the <I>point</I>).
The search string may match anywhere in a history line.
This is a non-incremental search.
<DT><B>history-substring-search-forward</B>
<DD>
Search forward through the history for the string of characters
between the start of the current line and the point.
The search string may match anywhere in a history line.
This is a non-incremental search.
<DT><B>yank-nth-arg (M-C-y)</B>
<DD>
@@ -7710,9 +7969,10 @@ A synonym for <B>yank-last-arg</B>.
<DD>
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing. Any
argument is ignored.
<DT><B>edit-and-execute-command (C-xC-e)</B>
relative to the current line from the history for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
<DT><B>edit-and-execute-command (C-x C-e)</B>
<DD>
Invoke an editor on the current command line, and execute the result as shell
@@ -8124,11 +8384,12 @@ Abort the current editing command and
ring the terminal's bell (subject to the setting of
<B>bell-style</B>).
<DT><B>do-uppercase-version (M-a, M-b, M-</B><I>x</I>, ...)
<DT><B>do-lowercase-version (M-A, M-B, M-</B><I>x</I>, ...)
<DD>
If the metafied character <I>x</I> is lowercase, run the command
that is bound to the corresponding uppercase character.
If the metafied character <I>x</I> is uppercase, run the command
that is bound to the corresponding metafied lowercase character.
The behavior is undefined if <I>x</I> is already lowercase.
<DT><B>prefix-meta (ESC)</B>
<DD>
@@ -8542,7 +8803,7 @@ If <B>HISTFILESIZE</B> is unset, or set to null, a non-numeric value,
or a numeric value less than zero, the history file is not truncated.
When the history file is read,
lines beginning with the history comment character followed immediately
by a digit are interpreted as timestamps for the preceding history line.
by a digit are interpreted as timestamps for the following history line.
These timestamps are optionally displayed depending on the value of the
<FONT SIZE=-1><B>HISTTIMEFORMAT</B>
@@ -8652,7 +8913,7 @@ for information on setting and unsetting shell options.
The shell supports a history expansion feature that
is similar to the history expansion in
<B>csh.</B>
<B>csh</B>.
This section describes what syntax features are available. This
feature is enabled by default for interactive shells, and can be
@@ -8677,7 +8938,9 @@ fix errors in previous commands quickly.
<P>
History expansion is performed immediately after a complete line
is read, before the shell breaks it into words.
is read, before the shell breaks it into words, and is performed
on each line individually without taking quoting on previous lines into
account.
It takes place in two parts.
The first is to determine which line from the history list
to use during substitution.
@@ -9035,7 +9298,7 @@ accepts
<B>--</B>
to signify the end of the options.
The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B> builtins
The <B>:</B>, <B>true</B>, <B>false</B>, and <B>test</B>/<B>[</B> builtins
do not accept options and do not treat <B>--</B> specially.
The <B>exit</B>, <B>logout</B>, <B>return</B>,
<B>break</B>, <B>continue</B>, <B>let</B>,
@@ -9705,6 +9968,13 @@ The <I>wordlist</I> is split using the characters in the
</FONT>
special variable as delimiters, and each resultant word is expanded.
Shell quoting is honored within <I>wordlist</I>,
in order to provide a
mechanism for the words to contain shell metacharacters or characters
in the value of
<FONT SIZE=-1><B>IFS</B>.
</FONT>
The possible completions are the members of the resultant list which
match the word being completed.
<DT><B>-X</B> <I>filterpat</I><DD>
@@ -10209,6 +10479,7 @@ unless the
shell option
is enabled. In that case, it returns failure.
An interactive shell returns failure if the file cannot be executed.
A subshell exits unconditionally if <B>exec</B> fails.
If
<I>command</I>
@@ -10292,7 +10563,7 @@ where a negative number is used as an offset from the current
command number). If
<I>last</I>
is not specified it is set to
is not specified, it is set to
the current command for listing (so that
<TT>fc -l -10</TT>
@@ -10303,7 +10574,7 @@ otherwise.
If
<I>first</I>
is not specified it is set to the previous
is not specified, it is set to the previous
command for editing and -16 for listing.
<P>
The
@@ -10349,7 +10620,7 @@ echoed and executed.
<P>
In the second form, <I>command</I> is re-executed after each instance
of <I>pat</I> is replaced by <I>rep</I>.
<I>Command</I> is intepreted the same as <I>first</I> above.
<I>Command</I> is interpreted the same as <I>first</I> above.
A useful alias to use with this is
<TT>r='fc -s'</TT>,
@@ -10621,6 +10892,7 @@ The return status is 0 unless no command matches
<DT><B>history</B> <B>-c</B><DD>
<DT><B>history -d</B> <I>offset</I><DD>
<DT><B>history -d</B> <I>start</I>-<I>end</I><DD>
<DT><B>history</B> <B>-anrw</B> [<I>filename</I>]<DD>
<DT><B>history</B> <B>-p</B> <I>arg</I> [<I>arg ...</I>]<DD>
<DT><B>history</B> <B>-s</B> <I>arg</I> [<I>arg ...</I>]<DD>
@@ -10661,6 +10933,14 @@ is used. Options, if supplied, have the following meanings:
Clear the history list by deleting all the entries.
<DT><B>-d</B> <I>offset</I><DD>
Delete the history entry at position <I>offset</I>.
If <I>offset</I> is negative, it is interpreted as relative to one greater
than the last history position, so negative indices count back from the
end of the history, and an index of -1 refers to the current
<B>history -d</B> command.
<DT><B>-d</B> <I>start</I>-<I>end</I><DD>
Delete the history entries between positions <I>start</I> and <I>end</I>,
inclusive. Positive and negative values for <I>start</I> and <I>end</I>
are interpreted as described above.
<DT><B>-a</B>
<DD>
@@ -10935,6 +11215,8 @@ Options, if supplied, have the following meanings:
<DD>
The first character of <I>delim</I> is used to terminate each input line,
rather than newline.
If <I>delim</I> is the empty string, <B>mapfile</B> will terminate a line
when it reads a NUL character.
<DT><B>-n</B>
<DD>
@@ -11250,6 +11532,8 @@ Other <I>name</I> arguments are ignored.
<DD>
The first character of <I>delim</I> is used to terminate the input line,
rather than newline.
If <I>delim</I> is the empty string, <B>read</B> will terminate a line
when it reads a NUL character.
<DT><B>-e</B>
<DD>
@@ -11263,7 +11547,7 @@ is coming from a terminal,
</FONT>
above) is used to obtain the line.
Readline uses the current (or default, if line editing was not previously
active) editing settings.
active) editing settings, but uses Readline's default filename completion.
<DT><B>-i </B><I>text</I>
<DD>
@@ -11409,7 +11693,7 @@ is omitted, the return status is that of the last command
executed in the function body.
If <B>return</B> is executed by a trap handler, the last command used to
determine the status is the last command executed before the trap handler.
if <B>return</B> is executed during a <B>DEBUG</B> trap, the last command
If <B>return</B> is executed during a <B>DEBUG</B> trap, the last command
used to determine the status is the last command executed by the trap
handler before <B>return</B> was invoked.
If
@@ -11970,7 +12254,8 @@ With no options, or with the
<B>-p</B>
option, a list of all settable options is displayed, with
an indication of whether or not each is set.
an indication of whether or not each is set;
if <I>optnames</I> are supplied, the output is restricted to those options.
The <B>-p</B> option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@@ -12035,6 +12320,12 @@ The list of <B>shopt</B> options is:
<DL COMPACT>
<DT><B>assoc_expand_once</B>
<DD>
If set, the shell suppresses multiple evaluation of associative array
subscripts during arithmetic expression evaluation and while executing
builtins that can perform variable assignments.
<DT><B>autocd</B>
<DD>
@@ -12083,8 +12374,8 @@ postpones exiting if any jobs are stopped.
<DT><B>checkwinsize</B>
<DD>
If set, <B>bash</B> checks the window size after each command
and, if necessary, updates the values of
If set, <B>bash</B> checks the window size after each external (non-builtin)
command and, if necessary, updates the values of
<FONT SIZE=-1><B>LINES</B>
</FONT>
@@ -12101,6 +12392,11 @@ If set,
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
This option is enabled by default, but only has an effect if command
history is enabled, as described above under
<FONT SIZE=-1><B>HISTORY</B>.
</FONT>
<DT><B>compat31</B>
<DD>
@@ -12175,6 +12471,14 @@ to make them fatal errors that cause the shell to exit),
and does not reset the
loop state when a shell function is executed (this allows <B>break</B> or
<B>continue</B> in a shell function to affect loops in the caller's context).
<DT><B>compat44</B>
<DD>
If set,
<B>bash</B>
saves the positional parameters to BASH_ARGV and BASH_ARGC before they are
used, regardless of whether or not extended debugging mode is enabled.
<DT><B>complete_fullquote</B>
<DD>
@@ -12226,6 +12530,16 @@ If set,
includes filenames beginning with a `.' in the results of pathname
expansion.
The filenames
<B>``.''</B>
and
<B>``..''</B>
must always be matched explicitly, even if
<B>dotglob</B>
is set.
<DT><B>execfail</B>
<DD>
@@ -12441,6 +12755,12 @@ If set, and the
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
<DT><B>localvar_inherit</B>
<DD>
If set, local variables inherit the value and attributes of a variable of
the same name that exists at a previous scope before any new value is
assigned. The nameref attribute is not inherited.
<DT><B>login_shell</B>
<DD>
@@ -13221,22 +13541,25 @@ subsequently reset. The exit status is true unless a
<I>name</I>
is readonly.
<DT><B>wait</B> [<B>-n</B>] [<I>n ...</I>]<DD>
<DT><B>wait</B> [<B>-fn</B>] [<I>id ...</I>]<DD>
Wait for each specified child process and return its termination status.
Each
<I>n</I>
<I>id</I>
may be a process
ID or a job specification; if a job spec is given, all processes
in that job's pipeline are waited for. If
<I>n</I>
<I>id</I>
is not given, all currently active child processes
are waited for, and the return status is zero.
If the <B>-n</B> option is supplied, <B>wait</B> waits for any job to
terminate and returns its exit status.
If the <B>-f</B> option is supplied, and job control is enabled,
<B>wait</B> forces <I>id</I> to terminate before returning its status,
instead of returning when it changes status.
If
<I>n</I>
<I>id</I>
specifies a non-existent process or job, the return status is
127. Otherwise, the return status is the exit status of the last
@@ -13529,7 +13852,7 @@ There may be only one active coprocess at a time.
<HR>
<TABLE WIDTH=100%>
<TR>
<TH ALIGN=LEFT width=33%>GNU Bash 4.4<TH ALIGN=CENTER width=33%>2016 August 26<TH ALIGN=RIGHT width=33%>BASH(1)
<TH ALIGN=LEFT width=33%>GNU Bash 5.0<TH ALIGN=CENTER width=33%>2018 March 15<TH ALIGN=RIGHT width=33%>BASH(1)
</TR>
</TABLE>
<HR>
@@ -13635,6 +13958,6 @@ There may be only one active coprocess at a time.
</DL>
<HR>
This document was created by man2html from bash.1.<BR>
Time: 31 August 2016 10:24:30 EDT
Time: 19 March 2018 09:43:32 EDT
</BODY>
</HTML>
+745 -512
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+8137 -7849
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+392 -101
View File
File diff suppressed because it is too large Load Diff
+745 -512
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+7759 -7433
View File
File diff suppressed because it is too large Load Diff
+255 -62
View File
@@ -14,7 +14,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Bash Reference Manual},
for @code{Bash}, Version @value{VERSION}.
Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2018 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@@ -508,7 +508,7 @@ double quote
question mark
@item \@var{nnn}
the eight-bit character whose value is the octal value @var{nnn}
(one to three digits)
(one to three octal digits)
@item \x@var{HH}
the eight-bit character whose value is the hexadecimal value @var{HH}
(one or two hex digits)
@@ -659,8 +659,13 @@ the time information.
If the pipeline is not executed asynchronously (@pxref{Lists}), the
shell waits for all commands in the pipeline to complete.
Each command in a pipeline is executed in its own subshell
(@pxref{Command Execution Environment}). The exit
Each command in a pipeline is executed in its own subshell, which is a
separate process (@pxref{Command Execution Environment}).
If the @code{lastpipe} option is enabled using the @code{shopt} builtin
(@pxref{The Shopt Builtin}),
the last element of a pipeline may be run by the shell process.
The exit
status of a pipeline is the exit status of the last command in the
pipeline, unless the @code{pipefail} option is enabled
(@pxref{The Set Builtin}).
@@ -714,7 +719,7 @@ An @sc{and} list has the form
@noindent
@var{command2} is executed if, and only if, @var{command1}
returns an exit status of zero.
returns an exit status of zero (success).
An @sc{or} list has the form
@example
@@ -739,7 +744,7 @@ executed in the list.
* Command Grouping:: Ways to group commands.
@end menu
Compound commands are the shell programming constructs.
Compound commands are the shell programming language constructs.
Each construct begins with a reserved word or control operator and is
terminated by a corresponding reserved word or operator.
Any redirections (@pxref{Redirections}) associated with a compound command
@@ -798,12 +803,14 @@ The syntax of the @code{for} command is:
for @var{name} [ [in [@var{words} @dots{}] ] ; ] do @var{commands}; done
@end example
Expand @var{words}, and execute @var{commands} once for each member
Expand @var{words} (@pxref{Shell Expansions}), and execute @var{commands}
once for each member
in the resultant list, with @var{name} bound to the current member.
If @samp{in @var{words}} is not present, the @code{for} command
executes the @var{commands} once for each positional parameter that is
set, as if @samp{in "$@@"} had been specified
(@pxref{Special Parameters}).
The return status is the exit status of the last command that executes.
If there are no items in the expansion of @var{words}, no commands are
executed, and the return status is zero.
@@ -874,6 +881,8 @@ case @var{word} in [ [(] @var{pattern} [| @var{pattern}]@dots{}) @var{command-li
@code{case} will selectively execute the @var{command-list} corresponding to
the first @var{pattern} that matches @var{word}.
The match is performed according
to the rules described below in @ref{Pattern Matching}.
If the @code{nocasematch} shell option
(see the description of @code{shopt} in @ref{The Shopt Builtin})
is enabled, the match is performed without regard to the case
@@ -885,7 +894,9 @@ as a @var{clause}.
Each clause must be terminated with @samp{;;}, @samp{;&}, or @samp{;;&}.
The @var{word} undergoes tilde expansion, parameter expansion, command
substitution, arithmetic expansion, and quote removal before matching is
substitution, arithmetic expansion, and quote removal
(@pxref{Shell Parameter Expansion})
before matching is
attempted. Each @var{pattern} undergoes tilde expansion, parameter
expansion, command substitution, and arithmetic expansion.
@@ -1010,7 +1021,7 @@ If the @code{nocasematch} shell option
is enabled, the match is performed without regard to the case
of alphabetic characters.
The return value is 0 if the string matches (@samp{==}) or does not
match (@samp{!=})the pattern, and 1 otherwise.
match (@samp{!=}) the pattern, and 1 otherwise.
Any part of the pattern may be quoted to force the quoted portion
to be matched as a string.
@@ -1045,7 +1056,7 @@ if there is a sequence of characters in the value consisting of
any number, including zero, of
space characters, zero or one instances of @samp{a}, then a @samp{b}:
@example
[[ $line =~ [[:space:]]*(a)?b ]]
[[ $line =~ [[:space:]]*?(a)b ]]
@end example
@noindent
@@ -1061,7 +1072,7 @@ expressions while paying attention to the shell's quote removal.
Using a shell variable to store the pattern decreases these problems.
For example, the following is equivalent to the above:
@example
pattern='[[:space:]]*(a)?b'
pattern='[[:space:]]*?(a)b'
[[ $line =~ $pattern ]]
@end example
@@ -1197,7 +1208,8 @@ This pipe is established before any redirections specified by the
command (@pxref{Redirections}).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
The file descriptors are not available in subshells.
Other than those created to execute command and process substitutions,
the file descriptors are not available in subshells.
The process ID of the shell spawned to execute the coprocess is
available as the value of the variable @env{NAME}_PID.
@@ -1308,7 +1320,7 @@ will ensure that the output of @code{traceroute foss.org.my} is displayed first.
Finally, Parallel can be used to run a sequence of shell commands in parallel,
similar to @samp{cat file | bash}.
It is not uncommon to take a list of filenames, create a series of shell
commands to operate on them, and feed that list of commnds to a shell.
commands to operate on them, and feed that list of commands to a shell.
Parallel can speed this up. Assuming that @file{file} contains a list of
shell commands, one per line,
@@ -1424,7 +1436,66 @@ before the @code{return}.
Variables local to the function may be declared with the
@code{local} builtin. These variables are visible only to
the function and the commands it invokes.
the function and the commands it invokes. This is particularly
important when a shell function calls other functions.
Local variables "shadow" variables with the same name declared at
previous scopes. For instance, a local variable declared in a function
hides a global variable of the same name: references and assignments
refer to the local variable, leaving the global variable unmodified.
When the function returns, the global variable is once again visible.
The shell uses @var{dynamic scoping} to control a variable's visibility
within functions.
With dynamic scoping, visible variables and their values
are a result of the sequence of function calls that caused execution
to reach the current function.
The value of a variable that a function sees depends
on its value within its caller, if any, whether that caller is
the "global" scope or another shell function.
This is also the value that a local variable
declaration "shadows", and the value that is restored when the function
returns.
For example, if a variable @var{var} is declared as local in function
@var{func1}, and @var{func1} calls another function @var{func2},
references to @var{var} made from within @var{func2} will resolve to the
local variable @var{var} from @var{func1}, shadowing any global variable
named @var{var}.
The following script demonstrates this behavior.
When executed, the script displays
@example
In func2, var = func1 local
@end example
@example
func1()
@{
local var='func1 local'
func2
@}
func2()
@{
echo "In func2, var = $var"
@}
var=global
func1
@end example
The @code{unset} builtin also acts using the same dynamic scope: if a
variable is local to the current scope, @code{unset} will unset it;
otherwise the unset will refer to the variable found in any calling scope
as described above.
If a variable at the current local scope is unset, it will remain so
until it is reset in that scope or until the function returns.
Once the function returns, any instance of the variable at a previous
scope will become visible.
If the unset acts on a variable at a previous scope, any instance of a
variable with that name that had been shadowed will become visible.
Function names and definitions may be listed with the
@option{-f} option to the @code{declare} (@code{typeset})
@@ -1437,10 +1508,6 @@ Functions may be exported so that subshells
automatically have them defined with the
@option{-f} option to the @code{export} builtin
(@pxref{Bourne Shell Builtins}).
Note that shell functions and variables with the same name may result
in multiple identically-named entries in the environment passed to the
shell's children.
Care should be taken in cases where this may cause a problem.
Functions may be recursive.
The @code{FUNCNEST} variable may be used to limit the depth of the
@@ -1708,10 +1775,11 @@ original word are removed unless they have been quoted themselves
(@var{quote removal}).
Only brace expansion, word splitting, and filename expansion
can change the number of words of the expansion; other expansions
can increase the number of words of the expansion; other expansions
expand a single word to a single word.
The only exceptions to this are the expansions of
@code{"$@@"} (@pxref{Special Parameters}) and @code{"$@{@var{name}[@@]@}"}
@code{"$@@"} and @code{$*} (@pxref{Special Parameters}), and
@code{"$@{@var{name}[@@]@}"} and @code{$@{@var{name}[*]@}}
(@pxref{Arrays}).
After all expansions, @code{quote removal} (@pxref{Quote Removal})
@@ -1765,8 +1833,6 @@ and any characters special to other expansions are preserved
in the result. It is strictly textual. Bash
does not apply any syntactic interpretation to the context of the
expansion or the text between the braces.
To avoid conflicts with parameter expansion, the string @samp{$@{}
is not considered eligible for brace expansion.
A correctly-formed brace expansion must contain unquoted opening
and closing braces, and at least one unquoted comma or a valid
@@ -1776,7 +1842,8 @@ Any incorrectly formed brace expansion is left unchanged.
A @{ or @samp{,} may be quoted with a backslash to prevent its
being considered part of a brace expression.
To avoid conflicts with parameter expansion, the string @samp{$@{}
is not considered eligible for brace expansion.
is not considered eligible for brace expansion,
and inhibits brace expansion until the closing @samp{@}}..
This construct is typically used as shorthand when the common
prefix of the strings to be generated is longer than in the
@@ -1893,6 +1960,8 @@ Bash uses the value of the variable formed from the rest of
expanded and that value is used in the rest of the substitution, rather
than the value of @var{parameter} itself.
This is known as @code{indirect expansion}.
The value is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
If @var{parameter} is a nameref, this expands to the name of the
variable referenced by @var{parameter} instead of performing the
complete indirect expansion.
@@ -2120,8 +2189,8 @@ array, and an index of -1 references the last element.
@item $@{@var{parameter}#@var{word}@}
@itemx $@{@var{parameter}##@var{word}@}
The @var{word}
is expanded to produce a pattern just as in filename
expansion (@pxref{Filename Expansion}). If the pattern matches
is expanded to produce a pattern and matched according to the rules
described below (@pxref{Pattern Matching}). If the pattern matches
the beginning of the expanded value of @var{parameter},
then the result of the expansion is the expanded value of @var{parameter}
with the shortest matching pattern (the @samp{#} case) or the
@@ -2136,8 +2205,9 @@ array in turn, and the expansion is the resultant list.
@item $@{@var{parameter}%@var{word}@}
@itemx $@{@var{parameter}%%@var{word}@}
The @var{word} is expanded to produce a pattern just as in
filename expansion.
The @var{word}
is expanded to produce a pattern and matched according to the rules
described below (@pxref{Pattern Matching}). If the pattern matches
If the pattern matches a trailing portion of the expanded value of
@var{parameter}, then the result of the expansion is the value of
@var{parameter} with the shortest matching pattern (the @samp{%} case)
@@ -2156,6 +2226,8 @@ The @var{pattern} is expanded to produce a pattern just as in
filename expansion.
@var{Parameter} is expanded and the longest match of @var{pattern}
against its value is replaced with @var{string}.
The match is performed according to the rules described below
(@pxref{Pattern Matching}).
If @var{pattern} begins with @samp{/}, all matches of @var{pattern} are
replaced with @var{string}. Normally only the first match is replaced.
If @var{pattern} begins with @samp{#}, it must match at the beginning
@@ -2213,7 +2285,7 @@ The expansion is a string that is the value of @var{parameter} quoted in a
format that can be reused as input.
@item E
The expansion is a string that is the value of @var{parameter} with backslash
escape sequences expanded as with the @code{$'@dots{}'} quoting mechansim.
escape sequences expanded as with the @code{$'@dots{}'} quoting mechanism.
@item P
The expansion is a string that is the result of expanding the value of
@var{parameter} as if it were a prompt string (@pxref{Controlling the Prompt}).
@@ -2410,18 +2482,23 @@ without regard to the case of alphabetic characters.
When a pattern is used for filename expansion, the character @samp{.}
at the start of a filename or immediately following a slash
must be matched explicitly, unless the shell option @code{dotglob} is set.
When matching a filename, the slash character must always be
matched explicitly.
The filenames @samp{.} and @samp{..} must always be matched explicitly,
even if @code{dotglob} is set.
In other cases, the @samp{.} character is not treated specially.
When matching a filename, the slash character must always be
matched explicitly by a slash in the pattern, but in other matching
contexts it can be matched by a special pattern character as described
below (@pxref{Pattern Matching}).
See the description of @code{shopt} in @ref{The Shopt Builtin},
for a description of the @code{nocaseglob}, @code{nullglob},
@code{failglob}, and @code{dotglob} options.
The @env{GLOBIGNORE}
shell variable may be used to restrict the set of filenames matching a
shell variable may be used to restrict the set of file names matching a
pattern. If @env{GLOBIGNORE}
is set, each matching filename that also matches one of the patterns in
is set, each matching file name that also matches one of the patterns in
@env{GLOBIGNORE} is removed from the list of matches.
If the @code{nocaseglob} option is set, the matching against the patterns in
@env{GLOBIGNORE} is performed without regard to case.
@@ -2533,6 +2610,12 @@ Matches one of the given patterns.
Matches anything except one of the given patterns.
@end table
Complicated extended pattern matching against long strings is slow,
especially when the patterns contain alternations and the strings
contain multiple matches.
Using separate matches against shorter strings, or using arrays of
strings instead of a single long string, may be faster.
@node Quote Removal
@subsection Quote Removal
@@ -2565,6 +2648,9 @@ In this case, for each redirection operator except
than 10 and assign it to @{@var{varname}@}. If >&- or <&- is preceded
by @{@var{varname}@}, the value of @var{varname} defines the file
descriptor to close.
If @{@var{varname}@} is supplied, the redirection persists beyond
the scope of the command, allowing the shell programmer to manage
the file descriptor himself.
In the following descriptions, if the file descriptor number is
omitted, and the first character of the redirection operator is
@@ -2761,7 +2847,7 @@ A variant of here documents, the format is:
@end example
The @var{word} undergoes
brace expansion, tilde expansion, parameter and variable expansion,
tilde expansion, parameter and variable expansion,
command substitution, arithmetic expansion, and quote removal.
Pathname expansion and word splitting are not performed.
The result is supplied as a single string,
@@ -2922,9 +3008,10 @@ A full search of the directories in @env{$PATH}
is performed only if the command is not found in the hash table.
If the search is unsuccessful, the shell searches for a defined shell
function named @code{command_not_found_handle}.
If that function exists, it is invoked with the original command and
If that function exists, it is invoked in a separate execution environment
with the original command and
the original command's arguments as its arguments, and the function's
exit status becomes the exit status of the shell.
exit status becomes the exit status of that subshell.
If that function is not defined, the shell prints an error
message and returns an exit status of 127.
@@ -3262,7 +3349,7 @@ Many of the builtins have been extended by @sc{posix} or Bash.
Unless otherwise noted, each builtin command documented as accepting
options preceded by @samp{-} accepts @samp{--}
to signify the end of the options.
The @code{:}, @code{true}, @code{false}, and @code{test}
The @code{:}, @code{true}, @code{false}, and @code{test}/@code{[}
builtins do not accept options and do not treat @samp{--} specially.
The @code{exit}, @code{logout}, @code{return},
@code{break}, @code{continue}, @code{let},
@@ -3417,6 +3504,7 @@ cannot be executed for some reason, a non-interactive shell exits,
unless the @code{execfail} shell option
is enabled. In that case, it returns failure.
An interactive shell returns failure if the file cannot be executed.
A subshell exits unconditionally if @code{exec} fails.
If no @var{command} is specified, redirections may be used to affect
the current shell environment. If there are no redirection errors, the
return status is zero; otherwise the return status is non-zero.
@@ -3525,7 +3613,7 @@ The @option{-d} option causes the shell to forget the remembered location
of each @var{name}.
If the @option{-t} option is supplied, the full pathname to which each
@var{name} corresponds is printed. If multiple @var{name} arguments are
supplied with @option{-t} the @var{name} is printed before the hashed
supplied with @option{-t}, the @var{name} is printed before the hashed
full pathname.
The @option{-l} option causes output to be displayed in a format
that may be reused as input.
@@ -3587,7 +3675,7 @@ If @var{n} is not supplied, the return value is the exit status of the
last command executed in the function.
If @code{return} is executed by a trap handler, the last command used to
determine the status is the last command executed before the trap handler.
if @code{return} is executed during a @code{DEBUG} trap, the last command
If @code{return} is executed during a @code{DEBUG} trap, the last command
used to determine the status is the last command executed by the trap
handler before @code{return} was invoked.
@code{return} may also be used to terminate execution of a script
@@ -3668,7 +3756,7 @@ expressions using a set of rules based on the number of arguments.
The expression is false.
@item 1 argument
The expression is true if and only if the argument is not null.
The expression is true if, and only if, the argument is not null.
@item 2 arguments
If the first argument is @samp{!}, the expression is true if and
@@ -4280,6 +4368,8 @@ Options, if supplied, have the following meanings:
@item -d
The first character of @var{delim} is used to terminate each input line,
rather than newline.
If @var{delim} is the empty string, @code{mapfile} will terminate a line
when it reads a NUL character.
@item -n
Copy at most @var{count} lines. If @var{count} is 0, all lines are copied.
@item -O
@@ -4292,7 +4382,7 @@ Remove a trailing @var{delim} (default newline) from each line read.
@item -u
Read lines from file descriptor @var{fd} instead of the standard input.
@item -C
Evaluate @var{callback} each time @var{quantum}P lines are read.
Evaluate @var{callback} each time @var{quantum} lines are read.
The @option{-c} option specifies @var{quantum}.
@item -c
Specify the number of lines read between each call to @var{callback}.
@@ -4405,11 +4495,13 @@ Other @var{name} arguments are ignored.
@item -d @var{delim}
The first character of @var{delim} is used to terminate the input line,
rather than newline.
If @var{delim} is the empty string, @code{read} will terminate a line
when it reads a NUL character.
@item -e
Readline (@pxref{Command Line Editing}) is used to obtain the line.
Readline uses the current (or default, if line editing was not previously
active) editing settings.
active) editing settings, but uses Readline's default filename completion.
@item -i @var{text}
If Readline is being used to read the line, @var{text} is placed into
@@ -4972,7 +5064,8 @@ The settings can be either those listed below, or, if the
@option{-o} option is used, those available with the @option{-o}
option to the @code{set} builtin command (@pxref{The Set Builtin}).
With no options, or with the @option{-p} option, a list of all settable
options is displayed, with an indication of whether or not each is set.
options is displayed, with an indication of whether or not each is set;
if @var{optnames} are supplied, the output is restricted to those options.
The @option{-p} option causes output to be displayed in a form that
may be reused as input.
Other options have the following meanings:
@@ -5012,6 +5105,11 @@ option.
The list of @code{shopt} options is:
@table @code
@item assoc_expand_once
If set, the shell suppresses multiple evaluation of associative array
subscripts during arithmetic expression evaluation and while executing
builtins that can perform variable assignments.
@item autocd
If set, a command name that is the name of a directory is executed as if
it were the argument to the @code{cd} command.
@@ -5044,8 +5142,8 @@ intervening command (@pxref{Job Control}).
The shell always postpones exiting if any jobs are stopped.
@item checkwinsize
If set, Bash checks the window size after each command
and, if necessary, updates the values of
If set, Bash checks the window size after each external (non-builtin)
command and, if necessary, updates the values of
@env{LINES} and @env{COLUMNS}.
@item cmdhist
@@ -5053,6 +5151,8 @@ If set, Bash
attempts to save all lines of a multiple-line
command in the same history entry. This allows
easy re-editing of multi-line commands.
This option is enabled by default, but only has an effect if command
history is enabled (@pxref{Bash History Facilities}).
@item compat31
If set, Bash
@@ -5106,6 +5206,11 @@ and does not reset the
loop state when a shell function is executed (this allows @code{break} or
@code{continue} in a shell function to affect loops in the caller's context).
@item compat44
If set, Bash
saves the positional parameters to BASH_ARGV and BASH_ARGC before they are
used, regardless of whether or not extended debugging mode is enabled.
@item complete_fullquote
If set, Bash
quotes all shell metacharacters in filenames and directory names when
@@ -5138,6 +5243,8 @@ if the directory name initially supplied does not exist.
@item dotglob
If set, Bash includes filenames beginning with a `.' in
the results of filename expansion.
The filenames @samp{.} and @samp{..} must always be matched explicitly,
even if @code{dotglob} is set.
@item execfail
If this is set, a non-interactive shell will not exit if
@@ -5271,6 +5378,11 @@ If enabled, and the @code{cmdhist}
option is enabled, multi-line commands are saved to the history with
embedded newlines rather than using semicolon separators where possible.
@item localvar_inherit
If set, local variables inherit the value and attributes of a variable of
the same name that exists at a previous scope before any new value is
assigned. The @var{nameref} attribute is not inherited.
@item login_shell
The shell sets this option if it is started as a login shell
(@pxref{Invoking Bash}).
@@ -5444,6 +5556,8 @@ sequences that are expanded before @env{PS1} is displayed.
@item PS2
The secondary prompt string. The default value is @samp{> }.
@env{PS2} is expanded in the same way as @env{PS1} before being
displayed.
@end vtable
@@ -5476,6 +5590,10 @@ reading any startup files. This variable is readonly.
Expands to the process ID of the current Bash process.
This differs from @code{$$} under certain circumstances, such as subshells
that do not require Bash to be re-initialized.
Assignments to @env{BASHPID} have no effect.
If @code{BASHPID}
is unset, it loses its special properties, even if it is
subsequently reset.
@item BASH_ALIASES
An associative array variable whose members correspond to the internal
@@ -5499,6 +5617,8 @@ The shell sets @code{BASH_ARGC} only when in extended debugging mode
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
Setting @code{extdebug} after the shell has started to execute a script
may result in inconsistent values.
@item BASH_ARGV
An array variable containing all of the parameters in the current bash
@@ -5510,6 +5630,18 @@ The shell sets @code{BASH_ARGV} only when in extended debugging mode
(see @ref{The Shopt Builtin}
for a description of the @code{extdebug} option to the @code{shopt}
builtin).
Setting @code{extdebug} after the shell has started to execute a script
may result in inconsistent values.
@item BASH_ARGV0
When referenced, this variable expands to the name of the shell or shell
script (identical to @code{$0}; @xref{Special Parameters},
for the description of special parameter 0).
Assignment to @code{BASH_ARGV0}
causes the value assigned to also be assigned to @code{$0}.
If @code{BASH_ARGV0}
is unset, it loses its special properties, even if it is
subsequently reset.
@item BASH_CMDS
An associative array variable whose members correspond to the internal
@@ -5726,6 +5858,23 @@ Emacs shell buffer and disables line editing.
Similar to @code{BASH_ENV}; used when the shell is invoked in
@sc{posix} Mode (@pxref{Bash POSIX Mode}).
@item EPOCHREALTIME
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch as a floating point value with micro-second granularity
(see the documentation for the C library function @var{time} for the
definition of Epoch).
Assignments to @env{EPOCHREALTIME} are ignored.
If @env{EPOCHREALTIME} is unset, it loses its special properties, even if
it is subsequently reset.
@item EPOCHSECONDS
Each time this parameter is referenced, it expands to the number of seconds
since the Unix Epoch (see the documentation for the C library function
@var{time} for the definition of Epoch).
Assignments to @env{EPOCHSECONDS} are ignored.
If @env{EPOCHSECONDS} is unset, it loses its special properties, even if
it is subsequently reset.
@item EUID
The numeric effective user id of the current user. This variable
is readonly.
@@ -5783,9 +5932,9 @@ nesting level. Function invocations that exceed this nesting level
will cause the current command to abort.
@item GLOBIGNORE
A colon-separated list of patterns defining the set of filenames to
A colon-separated list of patterns defining the set of file names to
be ignored by filename expansion.
If a filename matched by a filename expansion pattern also matches one
If a file name matched by a filename expansion pattern also matches one
of the patterns in @env{GLOBIGNORE}, it is removed from the list
of matches.
The pattern matching honors the setting of the @code{extglob} shell
@@ -5916,7 +6065,7 @@ as the sole input. If set, the value denotes the number
of consecutive @code{EOF} characters that can be read as the
first character on an input line
before the shell will exit. If the variable exists but does not
have a numeric value (or has no value) then the default is 10.
have a numeric value, or has no value, then the default is 10.
If the variable does not exist, then @code{EOF} signifies the end of
input to the shell. This is only in effect for interactive shells.
@@ -6034,10 +6183,11 @@ The value of this variable is used as the prompt for the
@code{select} command prompts with @samp{#? }
@item PS4
The value is the prompt printed before the command line is echoed
when the @option{-x} option is set (@pxref{The Set Builtin}).
The first character of @env{PS4} is replicated multiple times, as
necessary, to indicate multiple levels of indirection.
The value of this parameter is expanded like @var{PS1}
and the expanded value is the prompt printed before the command line
is echoed when the @option{-x} option is set (@pxref{The Set Builtin}).
The first character of the expanded value is replicated multiple times,
as necessary, to indicate multiple levels of indirection.
The default is @samp{+ }.
@item PWD
@@ -6286,7 +6436,8 @@ Make the shell a restricted shell (@pxref{The Restricted Shell}).
If this option is present, or if no arguments remain after option
processing, then commands are read from the standard input.
This option allows the positional parameters to be set
when invoking an interactive shell.
when invoking an interactive shell or when reading input
through a pipe.
@item -D
A list of all double-quoted strings preceded by @samp{$}
@@ -6526,7 +6677,10 @@ signals @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
Bash expands and displays @env{PS1} before reading the first line
of a command, and expands and displays @env{PS2} before reading the
second and subsequent lines of a multi-line command.
Bash displays @env{PS0} after it reads a command but before executing it.
Bash expands and displays @env{PS0} after it reads a command but before
executing it.
See @ref{Controlling the Prompt}, for a complete list of prompt
string escape sequences.
@item
Bash executes the value of the @env{PROMPT_COMMAND} variable as a command
@@ -6558,7 +6712,7 @@ In the absence of any traps, Bash ignores @code{SIGTERM}
@item
In the absence of any traps, @code{SIGINT} is caught and handled
((@pxref{Signals}).
(@pxref{Signals}).
@code{SIGINT} will interrupt some shell builtins.
@item
@@ -6758,6 +6912,8 @@ is equal to, not equal to, less than, less than or equal to,
greater than, or greater than or equal to @var{arg2},
respectively. @var{Arg1} and @var{arg2}
may be positive or negative integers.
When used with the @code{[[} command, @var{Arg1} and @var{Arg2}
are evaluated as arithmetic expressions (@pxref{Shell Arithmetic}).
@end table
@node Shell Arithmetic
@@ -7047,12 +7203,16 @@ The @code{unset} builtin is used to destroy arrays.
@code{unset @var{name}[@var{subscript}]}
destroys the array element at index @var{subscript}.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by filename
expansion.
Unsetting the last element of an array variable does not unset the variable.
@code{unset @var{name}}, where @var{name} is an array, removes the
entire array. A subscript of @samp{*} or @samp{@@} also removes the
entire array.
When using a variable name with a subscript as an argument to a command,
such as with @code{unset}, without using the word expansion syntax
described above, the argument is subject to the shell's filename expansion.
If filename expansion is not desired, the argument should be quoted.
The @code{declare}, @code{local}, and @code{readonly}
builtins each accept a @option{-a} option to specify an indexed
array and a @option{-A} option to specify an associative array.
@@ -7186,7 +7346,8 @@ has a non-null value, then the
value is executed just as if it had been typed on the command line.
In addition, the following table describes the special characters which
can appear in the prompt variables @env{PS1} to @env{PS4}:
can appear in the prompt variables @env{PS0}, @env{PS1}, @env{PS2}, and
@env{PS4}:
@table @code
@item \a
@@ -7738,6 +7899,11 @@ The @code{jobs} command may then be used to inspect their status.
If a second attempt to exit is made without an intervening command,
Bash does not print another warning, and any stopped jobs are terminated.
When the shell is waiting for a job or process using the @code{wait}
builtin, and job control is enabled, @code{wait} will return when the
job changes state. The @option{-f} option will force @code{wait} to wait
until the job or process terminates before returning.
@node Job Control Builtins
@section Job Control Builtins
@@ -7834,7 +8000,7 @@ or non-zero if an error occurs or an invalid option is encountered.
@item wait
@btindex wait
@example
wait [-n] [@var{jobspec} or @var{pid} @dots{}]
wait [-fn] [@var{jobspec} or @var{pid} @dots{}]
@end example
Wait until the child process specified by each process @sc{id} @var{pid}
@@ -7845,6 +8011,9 @@ If no arguments are given, all currently active child processes are
waited for, and the return status is zero.
If the @option{-n} option is supplied, @code{wait} waits for any job to
terminate and returns its exit status.
If the @option{-f} option is supplied, and job control is enabled,
@code{wait} forces each @var{pid} or @var{jobspec} to terminate before
returning its status, intead of returning when it changes status.
If neither @var{jobspec} nor @var{pid} specifies an active child process
of the shell, the return status is 127.
@@ -7997,12 +8166,28 @@ To find out more about the options and arguments that the
@code{configure} script understands, type
@example
bash-2.04$ ./configure --help
bash-4.2$ ./configure --help
@end example
@noindent
at the Bash prompt in your Bash source directory.
If you want to build Bash in a directory separate from the source
directory -- to build for multiple architectures, for example --
just use the full path to the configure script. The following commands
will build bash in a directory under @file{/usr/local/build} from
the source code in @file{/usr/local/src/bash-4.4}:
@example
mkdir /usr/local/build/bash-4.4
cd /usr/local/build/bash-4.4
bash /usr/local/src/bash-4.4/configure
make
@end example
See @ref{Compiling For Multiple Architectures} for more information
about building in a directory separate from the source.
If you need to do unusual things to compile Bash, please
try to figure out how @code{configure} could check whether or not
to do them, and mail diffs or instructions to
@@ -8052,7 +8237,9 @@ own directory. To do this, you must use a version of @code{make} that
supports the @code{VPATH} variable, such as GNU @code{make}.
@code{cd} to the
directory where you want the object files and executables to go and run
the @code{configure} script from the source directory. You may need to
the @code{configure} script from the source directory
(@pxref{Basic Installation}).
You may need to
supply the @option{--srcdir=PATH} argument to tell @code{configure} where the
source files are. @code{configure} automatically checks for the
source code in the directory that @code{configure} is in and in `..'.
@@ -8224,7 +8411,7 @@ compiled and linked, rather than changing run-time features.
@table @code
@item --enable-largefile
Enable support for @uref{http://www.sas.com/standards/large_file/x_open.20Mar96.html,
Enable support for @uref{http://www.unix.org/version2/whatsnew/lfs20mar.html,
large files} if the operating system requires special compiler options
to build programs which can access large files. This is enabled by
default, if the operating system provides large file support.
@@ -8301,6 +8488,12 @@ Include support for coprocesses and the @code{coproc} reserved word
@item --enable-debugger
Include support for the bash debugger (distributed separately).
@item --enable-dev-fd-stat-broken
If calling @code{stat} on /dev/fd/@var{N} returns different results than
calling @code{fstat} on file descriptor @var{N}, supply this option to
enable a workaround.
This has implications for conditional commands that test file attributes.
@item --enable-direxpand-default
Cause the @code{direxpand} shell option (@pxref{The Shopt Builtin})
to be enabled by default when the shell starts.
@@ -8373,7 +8566,7 @@ If Readline is not enabled, this option has no effect.
@item --enable-prompt-string-decoding
Turn on the interpretation of a number of backslash-escaped characters
in the @env{$PS1}, @env{$PS2}, @env{$PS3}, and @env{$PS4} prompt
in the @env{$PS0}, @env{$PS1}, @env{$PS2}, and @env{$PS4} prompt
strings. See @ref{Controlling the Prompt}, for a complete list of prompt
string escape sequences.
+395 -356
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -7,7 +7,7 @@
.de FN
\fI\|\\$1\|\fP
..
.TH BASH_BUILTINS 1 "2004 Apr 20" "GNU Bash-4.2"
.TH BASH_BUILTINS 1 "2004 Apr 20" "GNU Bash 5.0"
.SH NAME
bash, :, ., [, alias, bg, bind, break, builtin, caller,
cd, command, compgen, complete,
+1764 -1688
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.3
%%CreationDate: Wed Aug 31 10:24:00 2016
%%CreationDate: Mon Mar 19 09:43:23 2018
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.22 3
+6 -6
View File
@@ -1,11 +1,11 @@
@ignore
Copyright (C) 1988-2016 Free Software Foundation, Inc.
Copyright (C) 1988-2018 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Sep 7 17:12:22 EDT 2016
@set LASTCHANGE Thu Mar 15 11:29:49 EDT 2018
@set EDITION 4.4
@set VERSION 4.4
@set EDITION 5.0
@set VERSION 5.0
@set UPDATED 7 September 2016
@set UPDATED-MONTH September 2016
@set UPDATED 15 March 2018
@set UPDATED-MONTH March 2018
+1 -2
View File
@@ -44,6 +44,7 @@ extern int errno;
#include "bashintl.h"
#include "shell.h"
#include "execute_cmd.h"
#include "flags.h"
#include "input.h"
@@ -53,8 +54,6 @@ extern int errno;
extern int executing_line_number __P((void));
extern int last_command_exit_value;
extern char *shell_name;
#if defined (JOB_CONTROL)
extern pid_t shell_pgrp;
extern int give_terminal_to __P((pid_t, int));
+58 -19
View File
@@ -35,6 +35,7 @@
#include "bashintl.h"
#include "shell.h"
#include "parser.h"
#include "flags.h"
#include "trap.h"
@@ -47,16 +48,6 @@
# include "bashhist.h"
#endif
extern int EOF_reached;
extern int indirection_level;
extern int posixly_correct;
extern int subshell_environment, running_under_emacs;
extern int last_command_exit_value, stdin_redir;
extern int need_here_doc;
extern int current_command_number, current_command_line_count, line_number;
extern int expand_aliases;
extern char *ps0_prompt;
#if defined (HAVE_POSIX_SIGNALS)
extern sigset_t top_level_mask;
#endif
@@ -90,7 +81,7 @@ reader_loop ()
/* XXX - why do we set this every time through the loop? And why do
it if SIGINT is trapped in an interactive shell? */
if (interactive_shell && signal_is_ignored (SIGINT) == 0)
if (interactive_shell && signal_is_ignored (SIGINT) == 0 && signal_is_trapped (SIGINT) == 0)
set_signal_handler (SIGINT, sigint_sighandler);
if (code != NOT_JUMPED)
@@ -157,10 +148,6 @@ reader_loop ()
else if (current_command = global_command)
{
global_command = (COMMAND *)NULL;
current_command_number++;
executing = 1;
stdin_redir = 0;
/* If the shell is interactive, expand and display $PS0 after reading a
command (possibly a list or pipeline) and before executing it. */
@@ -177,6 +164,11 @@ reader_loop ()
free (ps0_string);
}
current_command_number++;
executing = 1;
stdin_redir = 0;
execute_command (current_command);
exec_done:
@@ -202,6 +194,47 @@ reader_loop ()
return (last_command_exit_value);
}
/* Pretty print shell scripts */
int
pretty_print_loop ()
{
COMMAND *current_command;
char *command_to_print;
int code;
int global_posix_mode, last_was_newline;
global_posix_mode = posixly_correct;
last_was_newline = 0;
while (EOF_Reached == 0)
{
code = setjmp_nosigs (top_level);
if (code)
return (EXECUTION_FAILURE);
if (read_command() == 0)
{
current_command = global_command;
global_command = 0;
posixly_correct = 1; /* print posix-conformant */
if (current_command && (command_to_print = make_command_string (current_command)))
{
printf ("%s\n", command_to_print); /* for now */
last_was_newline = 0;
}
else if (last_was_newline == 0)
{
printf ("\n");
last_was_newline = 1;
}
posixly_correct = global_posix_mode;
dispose_command (current_command);
}
else
return (EXECUTION_FAILURE);
}
return (EXECUTION_SUCCESS);
}
static sighandler
alrm_catcher(i)
int i;
@@ -228,6 +261,15 @@ send_pwd_to_eterm ()
free (f);
}
static void
execute_prompt_command ()
{
char *command_to_execute;
command_to_execute = get_string_value ("PROMPT_COMMAND");
if (command_to_execute)
execute_variable_command (command_to_execute, "PROMPT_COMMAND");
}
/* Call the YACC-generated parser and return the status of the parse.
Input is read from the current input stream (bash_input). yyparse
leaves the parsed command in the global variable GLOBAL_COMMAND.
@@ -236,7 +278,6 @@ int
parse_command ()
{
int r;
char *command_to_execute;
need_here_doc = 0;
run_pending_traps ();
@@ -249,9 +290,7 @@ parse_command ()
actually printed. */
if (interactive && bash_input.type != st_string && parser_expanding_alias() == 0)
{
command_to_execute = get_string_value ("PROMPT_COMMAND");
if (command_to_execute)
execute_variable_command (command_to_execute, "PROMPT_COMMAND");
execute_prompt_command ();
if (running_under_emacs == 2)
send_pwd_to_eterm (); /* Yuck */
+31 -433
View File
@@ -43,45 +43,29 @@
<td>A more ksh-compatible 'autoload' (with lazy load).</td>
<td>ksh</td>
</tr>
<tr>
<td>./functions/autoload.v3</td>
<td>An updated ksh-compatible 'autoload'.</td>
<td>ksh</td>
</tr>
<tr>
<td>./functions/basename</td>
<td>A replacement for basename(1).</td>
<td>basename</td>
</tr>
<tr>
<td>./functions/basename2</td>
<td>Fast basename(1) and dirname(1) functions for BASH/SH.</td>
<td>basename, dirname</td>
</tr>
<tr>
<td>./functions/coproc.bash</td>
<td>Start, control, and end coprocesses.</td>
</tr>
<tr>
<td>./functions/coshell.bash</td>
<td>Control shell coprocesses (see coprocess.bash).</td>
</tr>
<tr>
<td>./functions/coshell.README</td>
<td>README for coshell and coproc.</td>
</tr>
<tr>
<td>./functions/csh-compat</td>
<td>A C-shell compatibility package.</td>
<td>csh</td>
</tr>
<tr>
<td>./functions/dirfuncs</td>
<td>Directory manipulation functions from the book 'The Korn Shell'.</td>
</tr>
<tr>
<td>./functions/dirname</td>
<td>A replacement for dirname(1).</td>
<td>dirname</td>
</tr>
<tr>
<td>./functions/emptydir</td>
<td>Find out if a directory is empty.</td>
<td>./functions/dirstack</td>
<td>Directory stack functions.</td>
</tr>
<tr>
<td>./functions/exitstat</td>
@@ -100,18 +84,6 @@
<td>Front end to sync TERM changes to both stty(1) and readline 'bind'.</td>
<td>stty.bash</td>
</tr>
<tr>
<td>./functions/func</td>
<td>Print out definitions for functions named by arguments.</td>
</tr>
<tr>
<td>./functions/gethtml</td>
<td>Get a web page from a remote server (wget(1) in bash!).</td>
</tr>
<tr>
<td>./functions/getoptx.bash</td>
<td>getopt function that parses long-named options.</td>
</tr>
<tr>
<td>./functions/inetaddr</td>
<td>Internet address conversion (inet2hex & hex2inet).</td>
@@ -121,10 +93,6 @@
<td>Return zero if the argument is in the path and executable.</td>
<td>inpath</td>
</tr>
<tr>
<td>./functions/isnum.bash</td>
<td>Test user input on numeric or character value.</td>
</tr>
<tr>
<td>./functions/isnum2</td>
<td>Test user input on numeric values, with floating point.</td>
@@ -133,18 +101,6 @@
<td>./functions/isvalidip</td>
<td>Test user input for valid IP Addresses.</td>
</tr>
<tr>
<td>./functions/jdate.bash</td>
<td>Julian date conversion.</td>
</tr>
<tr>
<td>./functions/jj.bash</td>
<td>Look for running jobs.</td>
</tr>
<tr>
<td>./functions/keep</td>
<td>Try to keep some programs in the foreground and running.</td>
</tr>
<tr>
<td>./functions/ksh-cd</td>
<td>ksh-like 'cd': cd [-LP] [dir [change]].</td>
@@ -164,47 +120,14 @@
<td>./functions/login</td>
<td>Replace the 'login' and 'newgrp' builtins in old Bourne shells.</td>
</tr>
<tr>
<td>./functions/lowercase</td>
<td>Rename files to lower case.</td>
<td>rename lower</td>
</tr>
<tr>
<td>./functions/manpage</td>
<td>Find and print a manual page.</td>
<td>fman</td>
</tr>
<tr>
<td>./functions/mhfold</td>
<td>Print MH folders, useful only because folders(1) doesn't print mod date/times.</td>
</tr>
<tr>
<td>./functions/notify.bash</td>
<td>Notify when jobs change status.</td>
</tr>
<tr>
<td>./functions/pathfuncs</td>
<td>Path related functions (no_path, add_path, pre-path, del_path).</td>
<td>path</td>
</tr>
<tr>
<td>./functions/README</td>
<td>README</td>
</tr>
<tr>
<td>./functions/recurse</td>
<td>Recursive directory traverser.</td>
</tr>
<tr>
<td>./functions/repeat2</td>
<td>A clone of C shell builtin 'repeat'.</td>
<td>repeat, csh</td>
</tr>
<tr>
<td>./functions/repeat3</td>
<td>A clone of C shell builtin 'repeat'.</td>
<td>repeat, csh</td>
</tr>
<tr>
<td>./functions/seq</td>
<td>Generate a sequence from m to n, m defaults to 1.</td>
@@ -237,10 +160,6 @@
<td>A function to emulate the ancient ksh builtin.</td>
<td>ksh</td>
</tr>
<tr>
<td>./functions/term</td>
<td>A shell function to set the terminal type interactively or not.</td>
</tr>
<tr>
<td>./functions/whatis</td>
<td>An implementation of the 10th Edition Unix sh builtin 'whatis(1)' command.</td>
@@ -253,17 +172,6 @@
<td>./functions/which</td>
<td>An emulation of 'which(1)' as it appears in FreeBSD.</td>
</tr>
<tr>
<td>./functions/xalias.bash</td>
<td>Convert csh alias commands to bash functions.</td>
<td>csh, aliasconv</td>
</tr>
<tr>
<td>./functions/xfind.bash</td>
<td>A 'find(1)' clone.</td>
</tr>
<tr>
</tr>
<tr>
<td>./loadables/</td>
<td>Example loadable replacements</td>
@@ -278,27 +186,19 @@
<td>cat(1) replacement with no options - the way cat was intended.</td>
<td>cat, readline pager</td>
</tr>
<tr>
<td>./loadables/cut.c</td>
<td>cut(1) replacement.</td>
</tr>
<tr>
<td>./loadables/dirname.c</td>
<td>Return directory portion of pathname.</td>
<td>dirname</td>
</tr>
<tr>
<td>./loadables/fdflags.c</td>
<td>Display or modify file descriptor flags</td>
</tr>
<tr>
<td>./loadables/finfo.c</td>
<td>Print file info.</td>
</tr>
<tr>
<td>./loadables/getconf.c</td>
<td>POSIX.2 getconf utility.</td>
</tr>
<tr>
<td>./loadables/getconf.h</td>
<td>Replacement definitions for ones the system doesn't provide.</td>
</tr>
<tr>
<td>./loadables/head.c</td>
<td>Copy first part of files.</td>
@@ -323,10 +223,18 @@
<td>./loadables/Makefile.in</td>
<td>Simple makefile for the sample loadable builtins.</td>
</tr>
<tr>
<td>./loadables/Makefile.inc.in</td>
<td>Sample makefile to use for loadable builtin development.</td>
</tr>
<tr>
<td>./loadables/mkdir.c</td>
<td>Make directories.</td>
</tr>
<tr>
<td>./loadables/mypid.c</td>
<td>Demonstrate how a loadable builtin can create and delete shell variables.</td>
</tr>
<tr>
<td>./loadables/necho.c</td>
<td>echo without options or argument interpretation.</td>
@@ -355,14 +263,26 @@
<td>./loadables/realpath.c</td>
<td>Canonicalize pathnames, resolving symlinks.</td>
</tr>
<tr>
<td>./loadables/rm.c</td>
<td>Remove file.</td>
</tr>
<tr>
<td>./loadables/rmdir.c</td>
<td>Remove directory.</td>
</tr>
<tr>
<td>./loadables/setpgid.c</td>
<td>Set a child process's process group.
</tr>
<tr>
<td>./loadables/sleep.c</td>
<td>sleep for fractions of a second.</td>
</tr>
<tr>
<td>./loadables/stat.c</td>
<td>Load an associative array with stat information about a file.</td>
</tr>
<tr>
<td>./loadables/strftime.c</td>
<td>Loadable builtin interface to strftime(3).</td>
@@ -430,221 +350,12 @@
<td>./misc/README</td>
<td>README</td>
</tr>
<tr>
<td>./misc/suncmd.termcap</td>
<td>SunView TERMCAP string.</td>
</tr>
<tr>
</tr>
<tr>
<td>./scripts.noah</td>
<td>Noah Friedman's collection of scripts (updated to bash v2 syntax by Chet Ramey)</td>
</tr>
<tr>
<td>./scripts.noah/aref.bash</td>
<td>Pseudo-arrays and substring indexing examples.</td>
</tr>
<tr>
<td>./scripts.noah/bash.sub.bash</td>
<td>Library functions used by require.bash.</td>
</tr>
<tr>
<td>./scripts.noah/bash_version.bash</td>
<td>A function to slice up $BASH_VERSION.</td>
</tr>
<tr>
<td>./scripts.noah/meta.bash</td>
<td>Enable and disable eight-bit readline input.</td>
</tr>
<tr>
<td>./scripts.noah/mktmp.bash</td>
<td>Make a temporary file with a unique name.</td>
</tr>
<tr>
<td>./scripts.noah/number.bash</td>
<td>A fun hack to translate numerals into English.</td>
</tr>
<tr>
<td>./scripts.noah/PERMISSION</td>
<td>Permissions to use the scripts in this directory.</td>
</tr>
<tr>
<td>./scripts.noah/prompt.bash</td>
<td>A way to set PS1 to some predefined strings.</td>
</tr>
<tr>
<td>./scripts.noah/README</td>
<td>README</td>
</tr>
<tr>
<td>./scripts.noah/remap_keys.bash</td>
<td>A front end to 'bind' to redo readline bindings.</td>
</tr>
<tr>
<td>./scripts.noah/require.bash</td>
<td>Lisp-like require/provide library functions for bash.</td>
</tr>
<tr>
<td>./scripts.noah/send_mail.bash</td>
<td>Replacement SMTP client written in bash.</td>
</tr>
<tr>
<td>./scripts.noah/shcat.bash</td>
<td>Bash replacement for 'cat(1)'.</td>
<td>cat</td>
</tr>
<tr>
<td>./scripts.noah/source.bash</td>
<td>Replacement for source that uses current directory.</td>
</tr>
<tr>
<td>./scripts.noah/string.bash</td>
<td>The string(3) functions at the shell level.</td>
</tr>
<tr>
<td>./scripts.noah/stty.bash</td>
<td>Front-end to stty(1) that changes readline bindings too.</td>
<td>fstty</td>
</tr>
<tr>
<td>./scripts.noah/y_or_n_p.bash</td>
<td>Prompt for a yes/no/quit answer.</td>
<td>ask</td>
</tr>
<tr>
</tr>
<tr>
<td>./scripts.v2</td>
<td>John DuBois' ksh script collection (converted to bash v2 syntax by Chet Ramey).</td>
</tr>
<tr>
<td>./scripts.v2/arc2tarz</td>
<td>Convert an "arc" archive to a compressed tar archive.</td>
</tr>
<tr>
<td>./scripts.v2/bashrand</td>
<td>Random number generator with upper and lower bounds and optional seed.</td>
<td>random</td>
</tr>
<tr>
<td>./scripts.v2/cal2day.bash</td>
<td>Convert a day number to a name.</td>
</tr>
<tr>
<td>./scripts.v2/cdhist.bash</td>
<td>cd replacement with a directory stack added.</td>
</tr>
<tr>
<td>./scripts.v2/corename</td>
<td>Tell what produced a core file.</td>
</tr>
<tr>
<td>./scripts.v2/fman</td>
<td>Fast man(1) replacement.</td>
<td>manpage</td>
</tr>
<tr>
<td>./scripts.v2/frcp</td>
<td>Copy files using ftp(1) but with rcp-type command line syntax.</td>
</tr>
<tr>
<td>./scripts.v2/lowercase</td>
<td>Change filenames to lower case.</td>
<td>rename lower</td>
</tr>
<tr>
<td>./scripts.v2/ncp</td>
<td>A nicer front end for cp(1) (has -i, etc.).</td>
</tr>
<tr>
<td>./scripts.v2/newext</td>
<td>Change the extension of a group of files.</td>
<td>rename</td>
</tr>
<tr>
<td>./scripts.v2/nmv</td>
<td>A nicer front end for mv(1) (has -i, etc.).</td>
<td>rename</td>
</tr>
<tr>
<td>./scripts.v2/pages</td>
<td>Print specified pages from files.</td>
</tr>
<tr>
<td>./scripts.v2/PERMISSION</td>
<td>Permissions to use the scripts in this directory.</td>
</tr>
<tr>
<td>./scripts.v2/pf</td>
<td>A pager front end that handles compressed files.</td>
</tr>
<tr>
<td>./scripts.v2/pmtop</td>
<td>Poor man's 'top(1)' for SunOS 4.x and BSD/OS.</td>
</tr>
<tr>
<td>./scripts.v2/README</td>
<td>README</td>
</tr>
<tr>
<td>./scripts.v2/ren</td>
<td>Rename files by changing parts of filenames that match a pattern.</td>
<td>rename</td>
</tr>
<tr>
<td>./scripts.v2/rename</td>
<td>Change the names of files that match a pattern.</td>
<td>rename</td>
</tr>
<tr>
<td>./scripts.v2/repeat</td>
<td>Execute a command multiple times.</td>
<td>repeat</td>
</tr>
<tr>
<td>./scripts.v2/shprof</td>
<td>Line profiler for bash scripts.</td>
</tr>
<tr>
<td>./scripts.v2/untar</td>
<td>Unarchive a (possibly compressed) tarfile into a directory.</td>
</tr>
<tr>
<td>./scripts.v2/uudec</td>
<td>Carefully uudecode(1) multiple files.</td>
</tr>
<tr>
<td>./scripts.v2/uuenc</td>
<td>uuencode(1) multiple files.</td>
</tr>
<tr>
<td>./scripts.v2/vtree</td>
<td>Print a visual display of a directory tree.</td>
<td>tree</td>
</tr>
<tr>
<td>./scripts.v2/where</td>
<td>Show where commands that match a pattern are.</td>
</tr>
<tr>
</tr>
<tr>
<td>./scripts</td>
<td>Example scripts</td>
</tr>
<tr>
<td>./scripts/adventure.sh</td>
<td>Text adventure game in bash!</td>
</tr>
<tr>
<td>./scripts/bcsh.sh</td>
<td>Bourne shell cshell-emulator.</td>
<td>csh</td>
</tr>
<tr>
<td>./scripts/bash-hexdump.sh</td>
<td>hexdump(1) in bash</td>
<td>hexdump -C, hd</td>
<tr>
<td>./scripts/cat.sh</td>
<td>Readline-based pager.</td>
@@ -654,65 +365,15 @@
<td>./scripts/center</td>
<td>Center - center a group of lines.</td>
</tr>
<tr>
<td>./scripts/dd-ex.sh</td>
<td>Line editor using only /bin/sh, /bin/dd and /bin/rm.</td>
</tr>
<tr>
<td>./scripts/fixfiles.bash</td>
<td>Recurse a tree and fix files containing various "bad" chars.</td>
</tr>
<tr>
<td>./scripts/hanoi.bash</td>
<td>The inevitable Towers of Hanoi in bash.</td>
</tr>
<tr>
<td>./scripts/inpath</td>
<td>Search $PATH for a file the same name as $1; return TRUE if found.</td>
<td>inpath</td>
</tr>
<tr>
<td>./scripts/krand.bash</td>
<td>Produces a random number within integer limits.</td>
<td>random</td>
</tr>
<tr>
<td>./scripts/line-input.bash</td>
<td>Line input routine for GNU Bourne-Again Shell plus terminal-control primitives.</td>
</tr>
<tr>
<td>./scripts/nohup.bash</td>
<td>bash version of 'nohup' command.</td>
</tr>
<tr>
<td>./scripts/precedence</td>
<td>Test relative precedences for '&&' and '||' operators.</td>
</tr>
<tr>
<td>./scripts/randomcard.bash</td>
<td>Print a random card from a card deck.</td>
<td>random</td>
</tr>
<tr>
<td>./scripts/README</td>
<td>README</td>
</tr>
<tr>
<td>./scripts/scrollbar</td>
<td>Display scrolling text.</td>
</tr>
<tr>
<td>./scripts/scrollbar2</td>
<td>Display scrolling text.</td>
</tr>
<tr>
<td>./scripts/self-repro</td>
<td>A self-reproducing script (careful!)</td>
</tr>
<tr>
<td>./scripts/showperm.bash</td>
<td>Convert ls(1) symbolic permissions into octal mode.</td>
</tr>
<tr>
<td>./scripts/shprompt</td>
<td>Display a prompt and get an answer satisfying certain criteria.</td>
@@ -722,37 +383,6 @@
<td>./scripts/spin.bash</td>
<td>Display a 'spinning wheel' to show progress.</td>
</tr>
<tr>
<td>./scripts/timeout</td>
<td>Give rsh(1) a shorter timeout.</td>
</tr>
<tr>
<td>./scripts/timeout2</td>
<td>Execute a given command with a timeout.</td>
</tr>
<tr>
<td>./scripts/timeout3</td>
<td>Execute a given command with a timeout.</td>
</tr>
<tr>
<td>./scripts/vtree2</td>
<td>Display a tree printout of dir in 1k blocks.</td>
<td>tree</td>
</tr>
<tr>
<td>./scripts/vtree3</td>
<td>Display a graphical tree printout of dir.</td>
<td>tree</td>
</tr>
<tr>
<td>./scripts/vtree3a</td>
<td>Display a graphical tree printout of dir.</td>
<td>tree</td>
</tr>
<tr>
<td>./scripts/websrv.sh</td>
<td>A web server in bash!</td>
</tr>
<tr>
<td>./scripts/xterm_title</td>
<td>Print the contents of the xterm title bar.</td>
@@ -793,36 +423,4 @@
</tr>
<tr>
</tr>
<tr>
<td>./startup-files/apple</td>
<td>Example Start-up files for Mac OS X.</td>
</tr>
<tr>
<td>./startup-files/apple/aliases</td>
<td>Sample aliases for Mac OS X.</td>
</tr>
<tr>
<td>./startup-files/apple/bash.defaults</td>
<td>Sample User preferences file.</td>
</tr>
<tr>
<td>./startup-files/apple/environment</td>
<td>Sample Bourne Again Shell environment file.</td>
</tr>
<tr>
<td>./startup-files/apple/login</td>
<td>Sample login wrapper.</td>
</tr>
<tr>
<td>./startup-files/apple/logout</td>
<td>Sample logout wrapper.</td>
</tr>
<tr>
<td>./startup-files/apple/rc</td>
<td>Sample Bourne Again Shell config file.</td>
</tr>
<tr>
<td>./startup-files/apple/README</td>
<td>README</td>
</tr>
</table>
+8 -104
View File
@@ -9,43 +9,25 @@ Path Description X-Ref
./functions/autoload An almost ksh-compatible 'autoload' (no lazy load). ksh
./functions/autoload.v2 An almost ksh-compatible 'autoload' (no lazy load). ksh
./functions/autoload.v3 A more ksh-compatible 'autoload' (with lazy load). ksh
./functions/autoload.v4 An updated ksh-compatible 'autoload'. ksh
./functions/basename A replacement for basename(1). basename
./functions/basename2 Fast basename(1) and dirname(1) functions for BASH/SH. basename, dirname
./functions/coproc.bash Start, control, and end coprocesses.
./functions/coshell.bash Control shell coprocesses (see coprocess.bash).
./functions/coshell.README README for coshell and coproc.
./functions/csh-compat A C-shell compatibility package. csh
./functions/dirfuncs Directory manipulation functions from the book 'The Korn Shell'.
./functions/dirname A replacement for dirname(1). dirname
./functions/emptydir Find out if a directory is empty.
./functions/dirstack Directory stack functions.
./functions/exitstat Display the exit status of processes.
./functions/external Like 'command' but FORCES use of external command.
./functions/fact Recursive factorial function.
./functions/fstty Front end to sync TERM changes to both stty(1) and readline 'bind'. stty.bash
./functions/func Print out definitions for functions named by arguments.
./functions/gethtml Get a web page from a remote server (wget(1) in bash!).
./functions/getoptx.bash getopt function that parses long-named options.
./functions/inetaddr Internet address conversion (inet2hex & hex2inet).
./functions/inpath Return zero if the argument is in the path and executable. inpath
./functions/isnum.bash Test user input on numeric or character value.
./functions/isnum2 Test user input on numeric values, with floating point.
./functions/isvalidip Test user input for valid IP Addresses.
./functions/jdate.bash Julian date conversion.
./functions/jj.bash Look for running jobs.
./functions/keep Try to keep some programs in the foreground and running.
./functions/ksh-cd ksh-like 'cd': cd [-LP] [dir [change]]. ksh
./functions/ksh-compat-test ksh-like arithmetic test replacements. ksh
./functions/kshenv Functions and aliases to provide the beginnings of a ksh environment for bash. ksh
./functions/login Replace the 'login' and 'newgrp' builtins in old Bourne shells.
./functions/lowercase Rename files to lower case. rename lower
./functions/manpage Find and print a manual page. fman
./functions/mhfold Print MH folders, useful only because folders(1) doesn't print mod date/times.
./functions/notify.bash Notify when jobs change status.
./functions/pathfuncs Path related functions (no_path, add_path, pre-path, del_path). path
./functions/README README
./functions/recurse Recursive directory traverser.
./functions/repeat2 A clone of C shell builtin 'repeat'. repeat, csh
./functions/repeat3 A clone of C shell builtin 'repeat'. repeat, csh
./functions/seq Generate a sequence from m to n, m defaults to 1.
./functions/seq2 Generate a sequence from m to n, m defaults to 1.
./functions/shcat Readline-based pager. cat, readline pager
@@ -53,28 +35,25 @@ Path Description X-Ref
./functions/sort-pos-params Sort the positional parameters.
./functions/substr A function to emulate the ancient ksh builtin. ksh
./functions/substr2 A function to emulate the ancient ksh builtin. ksh
./functions/term A shell function to set the terminal type interactively or not.
./functions/whatis An implementation of the 10th Edition Unix sh builtin 'whatis(1)' command.
./functions/whence An almost-ksh compatible 'whence(1)' command.
./functions/which An emulation of 'which(1)' as it appears in FreeBSD.
./functions/xalias.bash Convert csh alias commands to bash functions. csh, aliasconv
./functions/xfind.bash A 'find(1)' clone.
./loadables/ Example loadable replacements
./loadables/basename.c Return non-directory portion of pathname. basename
./loadables/cat.c cat(1) replacement with no options - the way cat was intended. cat, readline pager
./loadables/cut.c cut(1) replacement.
./loadables/dirname.c Return directory portion of pathname. dirname
./loadables/fdflags.c Display or modify file descriptor flags
./loadables/finfo.c Print file info.
./loadables/getconf.c POSIX.2 getconf utility.
./loadables/getconf.h Replacement definitions for ones the system doesn't provide.
./loadables/head.c Copy first part of files.
./loadables/hello.c Obligatory "Hello World" / sample loadable.
./loadables/id.c POSIX.2 user identity.
./loadables/ln.c Make links.
./loadables/logname.c Print login name of current user.
./loadables/Makefile.in Simple makefile for the sample loadable builtins.
./loadables/Makefile.inc.in Sample makefile to use for loadable builtin development.
./loadables/mkdir.c Make directories.
./loadables/mypid.c Demonstrate how a loadable builtin can create and delete shell variables.
./loadables/necho.c echo without options or argument interpretation.
./loadables/pathchk.c Check pathnames for validity and portability.
./loadables/print.c Loadable ksh-93 style print builtin.
@@ -82,8 +61,11 @@ Path Description X-Ref
./loadables/push.c Anyone remember TOPS-20?
./loadables/README README
./loadables/realpath.c Canonicalize pathnames, resolving symlinks.
./loadables/rm.c Remove file.
./loadables/rmdir.c Remove directory.
./loadables/setpgid.c Set a child process's process group.
./loadables/sleep.c sleep for fractions of a second.
./loadables/stat.c Load an associative array with stat information about a file.
./loadables/strftime.c Loadable builtin interface to strftime(3).
./loadables/sync.c Sync the disks by forcing pending filesystem writes to complete.
./loadables/tee.c Duplicate standard input.
@@ -101,83 +83,13 @@ Path Description X-Ref
./misc/aliasconv.sh Convert csh aliases to bash aliases and functions. csh, xalias
./misc/cshtobash Convert csh aliases, environment variables, and variables to bash equivalents. csh, xalias
./misc/README README
./misc/suncmd.termcap SunView TERMCAP string.
./scripts.noah Noah Friedman's collection of scripts (updated to bash v2 syntax by Chet Ramey)
./scripts.noah/aref.bash Pseudo-arrays and substring indexing examples.
./scripts.noah/bash.sub.bash Library functions used by require.bash.
./scripts.noah/bash_version.bash A function to slice up $BASH_VERSION.
./scripts.noah/meta.bash Enable and disable eight-bit readline input.
./scripts.noah/mktmp.bash Make a temporary file with a unique name.
./scripts.noah/number.bash A fun hack to translate numerals into English.
./scripts.noah/PERMISSION Permissions to use the scripts in this directory.
./scripts.noah/prompt.bash A way to set PS1 to some predefined strings.
./scripts.noah/README README
./scripts.noah/remap_keys.bash A front end to 'bind' to redo readline bindings.
./scripts.noah/require.bash Lisp-like require/provide library functions for bash.
./scripts.noah/send_mail.bash Replacement SMTP client written in bash.
./scripts.noah/shcat.bash Bash replacement for 'cat(1)'. cat
./scripts.noah/source.bash Replacement for source that uses current directory.
./scripts.noah/string.bash The string(3) functions at the shell level.
./scripts.noah/stty.bash Front-end to stty(1) that changes readline bindings too. fstty
./scripts.noah/y_or_n_p.bash Prompt for a yes/no/quit answer. ask
./scripts.v2 John DuBois' ksh script collection (converted to bash v2 syntax by Chet Ramey).
./scripts.v2/arc2tarz Convert an "arc" archive to a compressed tar archive.
./scripts.v2/bashrand Random number generator with upper and lower bounds and optional seed. random
./scripts.v2/cal2day.bash Convert a day number to a name.
./scripts.v2/cdhist.bash cd replacement with a directory stack added.
./scripts.v2/corename Tell what produced a core file.
./scripts.v2/fman Fast man(1) replacement. manpage
./scripts.v2/frcp Copy files using ftp(1) but with rcp-type command line syntax.
./scripts.v2/lowercase Change filenames to lower case. rename lower
./scripts.v2/ncp A nicer front end for cp(1) (has -i, etc.).
./scripts.v2/newext Change the extension of a group of files. rename
./scripts.v2/nmv A nicer front end for mv(1) (has -i, etc.). rename
./scripts.v2/pages Print specified pages from files.
./scripts.v2/PERMISSION Permissions to use the scripts in this directory.
./scripts.v2/pf A pager front end that handles compressed files.
./scripts.v2/pmtop Poor man's 'top(1)' for SunOS 4.x and BSD/OS.
./scripts.v2/README README
./scripts.v2/ren Rename files by changing parts of filenames that match a pattern. rename
./scripts.v2/rename Change the names of files that match a pattern. rename
./scripts.v2/repeat Execute a command multiple times. repeat
./scripts.v2/shprof Line profiler for bash scripts.
./scripts.v2/untar Unarchive a (possibly compressed) tarfile into a directory.
./scripts.v2/uudec Carefully uudecode(1) multiple files.
./scripts.v2/uuenc uuencode(1) multiple files.
./scripts.v2/vtree Print a visual display of a directory tree. tree
./scripts.v2/where Show where commands that match a pattern are.
./scripts Example scripts
./scripts/adventure.sh Text adventure game in bash!
./scripts/bash-hexdump.sh hexdump(1) in bash
./scripts/bcsh.sh Bourne shell cshell-emulator. csh
./scripts/cat.sh Readline-based pager. cat, readline pager
./scripts/center Center - center a group of lines.
./scripts/dd-ex.sh Line editor using only /bin/sh, /bin/dd and /bin/rm.
./scripts/fixfiles.bash Recurse a tree and fix files containing various "bad" chars.
./scripts/hanoi.bash The inevitable Towers of Hanoi in bash.
./scripts/inpath Search $PATH for a file the same name as $1; return TRUE if found. inpath
./scripts/krand.bash Produces a random number within integer limits. random
./scripts/line-input.bash Line input routine for GNU Bourne-Again Shell plus terminal-control primitives.
./scripts/nohup.bash bash version of 'nohup' command.
./scripts/precedence Test relative precedences for '&&' and '||' operators.
./scripts/randomcard.bash Print a random card from a card deck. random
./scripts/README README
./scripts/scrollbar Display scrolling text.
./scripts/scrollbar2 Display scrolling text.
./scripts/self-repro A self-reproducing script (careful!)
./scripts/showperm.bash Convert ls(1) symbolic permissions into octal mode.
./scripts/shprompt Display a prompt and get an answer satisfying certain criteria. ask
./scripts/spin.bash Display a 'spinning wheel' to show progress.
./scripts/timeout Give rsh(1) a shorter timeout.
./scripts/timeout2 Execute a given command with a timeout.
./scripts/timeout3 Execute a given command with a timeout.
./scripts/vtree2 Display a tree printout of dir in 1k blocks. tree
./scripts/vtree3 Display a graphical tree printout of dir. tree
./scripts/vtree3a Display a graphical tree printout of dir. tree
./scripts/websrv.sh A web server in bash!
./scripts/xterm_title Print the contents of the xterm title bar.
./scripts/zprintf Emulate printf (obsolete since it's now a bash builtin).
@@ -189,11 +101,3 @@ Path Description X-Ref
./startup-files/Bashrc.bfox Sample Bourne Again SHell init file (Fox).
./startup-files/README README
./startup-files/apple Example Start-up files for Mac OS X.
./startup-files/apple/aliases Sample aliases for Mac OS X.
./startup-files/apple/bash.defaults Sample User preferences file.
./startup-files/apple/environment Sample Bourne Again Shell environment file.
./startup-files/apple/login Sample login wrapper.
./startup-files/apple/logout Sample logout wrapper.
./startup-files/apple/rc Sample Bourne Again Shell config file.
./startup-files/apple/README README
+7
View File
@@ -0,0 +1,7 @@
Master source: https://github.com/scop/bash-completion
This is the latest version of the bash-completion package, which provides
programmable completion specifications for a large number of commands.
If you are a vendor installing bash or preparing a package containing bash,
please install the latest version of bash-completion when installing bash.
Binary file not shown.
+146
View File
@@ -0,0 +1,146 @@
# arrayops.bash --- hide some of the nasty syntax for manipulating bash arrays
# Author: Noah Friedman <friedman@splode.com>
# Created: 2016-07-08
# Public domain
# $Id: arrayops.bash,v 1.3 2016/07/28 15:38:55 friedman Exp $
# Commentary:
# These functions try to tame the syntactic nightmare that is bash array
# syntax, which makes perl's almost look reasonable.
#
# For example the apush function below lets you write:
#
# apush arrayvar newval
#
# instead of
#
# ${arrayvar[${#arrayvar[@]}]}=newval
#
# Because seriously, you've got to be kidding me.
# These functions avoid the use of local variables as much as possible
# (especially wherever modification occurs) because those variable names
# might shadow the array name passed in. Dynamic scope!
# Code:
#:docstring apush:
# Usage: apush arrayname val1 {val2 {...}}
#
# Appends VAL1 and any remaining arguments to the end of the array
# ARRAYNAME as new elements.
#:end docstring:
apush()
{
eval "$1=(\"\${$1[@]}\" \"\${@:2}\")"
}
#:docstring apop:
# Usage: apop arrayname {n}
#
# Removes the last element from ARRAYNAME.
# Optional argument N means remove the last N elements.
#:end docstring:
apop()
{
eval "$1=(\"\${$1[@]:0:\${#$1[@]}-${2-1}}\")"
}
#:docstring aunshift:
# Usage: aunshift arrayname val1 {val2 {...}}
#
# Prepends VAL1 and any remaining arguments to the beginning of the array
# ARRAYNAME as new elements. The new elements will appear in the same order
# as given to this function, rather than inserting them one at a time.
#
# For example:
#
# foo=(a b c)
# aunshift foo 1 2 3
# => foo is now (1 2 3 a b c)
# but
#
# foo=(a b c)
# aunshift foo 1
# aunshift foo 2
# aunshift foo 3
# => foo is now (3 2 1 a b c)
#
#:end docstring:
aunshift()
{
eval "$1=(\"\${@:2}\" \"\${$1[@]}\")"
}
#:docstring ashift:
# Usage: ashift arrayname {n}
#
# Removes the first element from ARRAYNAME.
# Optional argument N means remove the first N elements.
#:end docstring:
ashift()
{
eval "$1=(\"\${$1[@]: -\${#$1[@]}+${2-1}}\")"
}
#:docstring aset:
# Usage: aset arrayname idx newval
#
# Assigns ARRAYNAME[IDX]=NEWVAL
#:end docstring:
aset()
{
eval "$1[\$2]=${@:3}"
}
#:docstring aref:
# Usage: aref arrayname idx {idx2 {...}}
#
# Echoes the value of ARRAYNAME at index IDX to stdout.
# If more than one IDX is specified, each one is echoed.
#
# Unfortunately bash functions cannot return arbitrary values in the usual way.
#:end docstring:
aref()
{
eval local "v=(\"\${$1[@]}\")"
local x
for x in ${@:2} ; do echo "${v[$x]}"; done
}
#:docstring aref:
# Usage: alen arrayname
#
# Echoes the length of the number of elements in ARRAYNAME.
#
# It also returns number as a numeric value, but return values are limited
# by a maximum of 255 so don't rely on this unless you know your arrays are
# relatively small.
#:end docstring:
alen()
{
eval echo "\${#$1[@]}"
eval return "\${#$1[@]}"
}
#:docstring anreverse:
# Usage: anreverse arrayname
#
# Reverse the order of the elements in ARRAYNAME.
# The array variable is altered by this operation.
#:end docstring:
anreverse()
{
eval set $1 "\"\${$1[@]}\""
eval unset $1
while [ $# -gt 1 ]; do
eval "$1=(\"$2\" \"\${$1[@]}\")"
set $1 "${@:3}"
done
}
#provide arrayops
# arrayops.bash ends here
+1 -1
View File
@@ -22,7 +22,7 @@
#
# Declare a function ($1) to be autoloaded from a file ($2) when it is first
# called. This defines a `temporary' function that will `.' the file
# containg the real function definition, then execute that new definition with
# containing the real function definition, then execute that new definition with
# the arguments given to this `fake' function. The autoload function defined
# by the file and the file itself *must* be named identically.
#
+556
View File
@@ -0,0 +1,556 @@
## -*- sh -*-
# The psuedo-ksh autoloader.
# How to use:
# o One function per file.
# o File and function name match exactly.
# o File is located in a directory that is in FPATH.
# o This script (autoload) must be sourced in as early as possible. This
# implies that any code in this script should NOT rely on any library of local
# or self-defined functions having already been loaded.
# o autoload must be called for each function before the function can be used. If
# autoloads are in directories where there are nothing but autoloads, then
# 'autoload /path/to/files/*' suffices (but see options -a and -f).
# o The call must be made in the current environment, not a subshell.
# o The command line suffices as "current environment". If you have autoload
# calls in a script, that script must be dotted into the process.
# The first cut of this was by Bill Trost, trost@reed.bitnet.
# The second cut came from Chet Ramey, chet@ins.CWRU.Edu
# The third cut came from Mark Kennedy, mtk@ny.ubs.com. 1998/08/25
# The fourth cut came from Matthew Persico, matthew.persico@gmail.com 2017/August
autoload_calc_shimsize ()
{
echo $((AUTOLOAD_SHIM_OVERHEAD + 3 * ${#1}))
}
_autoload_split_fpath ()
{
(IFS=':'; set -- ${FPATH}; echo "$@")
}
_aload()
{
local opt OPTIND
local doexport=0
local doreload=0
local doverbose=0
local doevalshim=0
local loadthese
local optimize=0
local loaded=0
local exported=0
local optimized=0
local summary=0
local dofpath=0
while getopts xrvla:oyf opt; do
case $opt in
x) doexport=1;;
r) doreload=1;;
v) doverbose=1;;
l) doevalshim=1;;
a) loadthese=$(find $OPTARG -maxdepth 1 -type f -printf '%f ');;
o) optimize=1;;
y) summary=1;;
f) loadthese=$(find $(_autoload_split_fpath) -maxdepth 1 -type f -printf '%f ');;
*) echo "_aload: usage: _aload [-xrvlyf] [-a dir] [function ...]" >&2; return;;
esac
done
shift $(($OPTIND-1))
[ -z "$loadthese" ] && loadthese="$@"
local func
for func in $loadthese; do
local exists_fn
exists_fn=$(declare -F $func)
if [ -n "$exists_fn" ] && ((doreload==0)) && ((doevalshim==0))
then
if ((doverbose))
then
echo "autoload: function '$func' already exists"
fi
else
local andevaled=''
local andexported=''
local evalstat=0
local doshim=1
local funcfile
funcfile=$(_autoload_resolve $func)
if [[ $funcfile ]] ; then
## The file was found for $func. Process it.
if ((optimize)); then
## For the first function loaded, we will not know
## AUTOLOAD_SHIM_OVERHEAD. We can only calculate it after
## we have loaded one function.
if [[ $AUTOLOAD_SHIM_OVERHEAD ]]; then
local size=$(wc -c $funcfile| sed 's/ .*//')
local shimsize=$(autoload_calc_shimsize $func)
if (( size <= shimsize)); then
doshim=0
andevaled=', optimized'
((optimized+=1))
fi
fi
fi
if ((doevalshim)); then
doshim=0
andevaled=', evaled'
fi
## 'brand' as in branding a cow with a mark. We add a local
## variable to each function we autoload so that we can tell
## later on it is an autoloaded function without having to
## maintain some bash array or hash that cannot be passed to
## and used by subshells.
local brandtext
brandtext="eval \"\$(type $func | sed -e 1d -e 4ilocal\\ AUTOLOADED=\'$func\')\""
if ((doshim)); then
## Don't bother trying to save space by shoving all the
## eval text below onto one unreadable line; new lines will
## be added at your semicolons and any indentation below
## seems to be ignored anyway if you export the function;
## look at its BASH_FUNCTION representation.
eval $func '()
{
local IS_SHIM="$func"
local file=$(_autoload_resolve '$func')
if [[ $file ]]
then
. $file
'$brandtext'
'$func' "$@"
return $?
else
return 1;
fi
}'
else
. $funcfile
eval "$brandtext"
fi
evalstat=$?
if((evalstat==0))
then
((loaded+=1))
((doexport)) && export -f $func && andexported=', exported' && ((exported+=1))
((doverbose)) && echo "$func autoloaded${andexported}${andevaled}"
if [[ ! $AUTOLOAD_SHIM_OVERHEAD ]] && ((doshim)); then
## ...we have just loaded the first function shim into
## memory. Let's calc the AUTOLOAD_SHIM_OVERHEAD size
## to use going forward. In theory, we could check
## again here to see if we should optimize and source
## in this function, now that we now the
## AUTOLOAD_SHIM_OVERHEAD. In practice, it's not worth
## duping that code or creating a function to do so for
## one function.
AUTOLOAD_SHIM_OVERHEAD=$(type $func | grep -v -E "^$1 is a function" | sed "s/$func//g"| wc -c)
export AUTOLOAD_SHIM_OVERHEAD
fi
else
echo "$func failed to load" >&2
fi
fi
fi
done
((summary)) && echo "autoload: loaded:$loaded exported:$exported optimized:$optimized overhead:$AUTOLOAD_SHIM_OVERHEAD bytes"
}
_autoload_dump()
{
local opt OPTIND
local opt_p=''
local opt_s=''
while getopts ps opt
do
case $opt in
p ) opt_p=1;;
s ) opt_s=1;;
esac
done
shift $(($OPTIND-1))
local exported=''
local executed=''
local func
for func in $(declare | grep -E 'local\\{0,1} AUTOLOADED' | sed -e "s/.*AUTOLOADED=//" -e 's/\\//g' -e 's/[");]//g' -e "s/'//g")
do
if [ -n "$opt_p" ]; then echo -n "autoload "; fi
if [ -n "$opt_s" ]
then
exported=$(declare -F | grep -E "${func}$" | sed 's/declare -f\(x\{0,1\}\).*/\1/')
[ "$exported" = 'x' ] && exported=' exported' || exported=' not exported'
executed=$(type $func | grep 'local IS_SHIM')
[ -z "$executed" ] && executed=' executed' || executed=' not executed'
fi
echo "${func}${exported}${executed}"
done
}
_autoload_resolve()
{
if [[ ! "$FPATH" ]]; then
echo "autoload: FPATH not set or null" >&2
return
fi
local p # for 'path'. The $() commands in the for loop split the FPATH
# string into its constituents so that each one may be processed.
for p in $( _autoload_split_fpath ); do
p=${p:-.}
if [ -f $p/$1 ]; then echo $p/$1; return; fi
done
echo "autoload: $1: function source file not found" >&2
}
_autoload_edit()
{
[ -z "$EDITOR" ] && echo "Error: no EDITOR defined" && return 1
local toedit
local func
for func in "$@"
do
local file=$(_autoload_resolve $func)
if [[ $file ]]
then
toedit="$toedit $file"
else
echo "$funcname not found in FPATH funcfile. Skipping."
fi
done
[ -z "$toedit" ] && return 1
local timemarker=$(mktemp)
$EDITOR $toedit
local i
for i in $toedit
do
if [ $i -nt $timemarker ]
then
local f=$(basename $i)
echo Reloading $f
autoload -r $f
fi
done
}
_autoload_page()
{
[ -z "$PAGER" ] && echo "Error: no PAGER defined" && return 1
local topage
local func
for func in "$@"
do
local file=$(_autoload_resolve $func)
if [[ $file ]]
then
topage="$topage $file"
else
echo "$funcname not found in FPATH funcfile. Skipping."
fi
done
[ -z "$topage" ] && return 1
$PAGER $topage
}
_autoload_remove()
{
unset -f "$@"
}
_autoload_help()
{
cat <<EOH
NAME
autoload
SYNOPSIS
autoload [-ps]
autoload [-xuremloyv] [function ...]
autoload -a directory [-oyv]
autoload -f [-oyv]
autoload [-h]
autoreload [function ...]
DESCRIPTION
An implementation of the 'autoload' functionality built into other
shells, of which 'ksh' is the most prominent. It allows for a keeping
the process environment small by loading small 'shim' functions into
memory that will, on first call, load the full text of the given
function and run it. Subsequent calls to the function just run the
function.
'autoreload' is a synonym for 'autoload -r'. See below.
USAGE
o Each function to be autoloaded should be defined in a single file,
named exactly the same as the function.
o In order to avoid side effects, do NOT put code other than the
function definition in the file. Unless of course you want to do some
one-time initialization. But beware that if you reload the function
for any reason, you will rerun the initialization code. Make sure
your initialization is re-entrant. Or, better yet,
*** do NOT put code other than the function definition in the file ***
o These function definition files should be placed in a directory that
is in the FPATH environment variable. Subdirectories are NOT scanned.
o The autoload script should be sourced into the current process as
early as possible in process start up. See NOTES below for
suggestions.
o The calls to the autoload function must be made in the current
process. If your calls are in their own script, that script must be
sourced in. Command line invocations are also sufficient. (But see
'-l' below.)
o The first time the function is called, the shim function that was
created by the 'autoload' call is what is executed. This function
then goes and finds the appropriate file in FPATH, sources it in and
then calls the actual function with any arguments you just passed in
to the shim function. Subsequent calls just run the function.
OPTIONS
-a Autoload (a)ll the functions found in the given directory.
-f Autoload all the functions found in all the directories on the
FPATH.
-p Print all the autoloaded functions.
-s Print all the autoloaded functions and add their export status.
-x Export the specified functions to the environment for use in
subshells.
-u Unset the function, so it can be reloaded.
-r Reload the shims of the specified functions, even if the functions
have been already been executed. This will allow you to modify the
functions' source and have the new version executed next time the
function is called.
It would be very easy to modify a function's script, run the
function and scratch your head for a long time trying to figure out
why your changes are not being executed. That's why we provide the
'-e' flag described below for modifications.
Reloads, of course, only apply in the context of the current session
and any future subshell you start from the current session. Existing
sessions will need to have the same 'autoload -r' command run in
them.
-e Find the scripts in which the specified functions are defined and
start up \$EDITOR on those scripts. Reload the ones that were
modified when you exit \$EDITOR. (Note: If you use 'autoload -e foo'
to edit function 'foo', and then in your editor you separately load
up function 'bar', 'autoload' has no way of knowing that you edited
'bar' and will NOT reload 'bar' for you.)
Reloads, of course, only apply in the context of the current session
and any future subshell you start from the current session. Existing
sessions will need to have the same 'autoload -r' command run in
them.
-m Find the scripts in which the specified functions are defined and
run \$PAGER on them ('m' is for 'more', because 'p' (page) and 'l'
(load) are already used as options in 'autoload').
-l When autoloading a function, eval the shim immediately in order to
load the true function code. See "Using '-l'" in the NOTES below for
details.
-o Optimize. When autoloading, take the time to execute
'theCharCount=\$(wc -c \$theFuncFile)'
for each funcion and
if \$theCharCount < \$AUTOLOAD_SHIM_OVERHEAD
don't shim it, just eval directly.
-y Summar(y). Print the number of loaded, exported and optimized
functions.
-v Turns up the chattiness.
NOTES
o Calling 'autoload' on a function that already exists (either shimmed
or expanded) silently ignores the request to load the shim unless it
has been previously removed (-u) or you force the reload (-r).
o Changing and reloading a function that has been exported does not
require it be re-exported; the modifications will appear in
subsequent subshells.
o Using '-1'
If you are running under set -x and/or set -v, you may see that the
shim does not appear to "work"; instead of seeing the shim first and
the real code subsequently, you may see the shim evaluated multiple
times.
This may not be an error; review your code. What is most likely
happening is that you are calling the function in subshells via
backticks or $(), or in a script that is not being sourced into the
current environment. If you have not previously called the function
in question at your command line or in a script that was sourced into
the current envirnoment, then the various subshells are going to
encounter the shim and replace with the real code before executing.
Remember, however, that environment modifications that occur in a
subshell are NOT propagated back to the calling shell or over to any
sibling shells. So, if you call an autoloaded function in a very
tight loop of very many subshells, you may want to make an 'autoload
-l' call before you start your loop. '-l' will instruct 'autoload' to
bypass the shim creation and just source in the function's file
directly. For a few calls, the overhead of repeatedly running the
shim is not expensive, but in a tight loop, it might be. Caveat
Programer.
o Although the number of functions in the environment does not change
by using 'autoload', the amount of memory they take up can be greatly
reduced, depending on the size of your functions. If you have a lot
of small functions, then it is possible that the shim text will be
larger than your actual functions, rendering the memory savings moot.
'small' in this case can be determined by calling the function
'autoload_calc_shimsize' with the name of the function to determine
its shim size.
o In order to support the -p and -s options, we need a way to determine
if a function 'func' has been autoloaded or if it was loaded
diredctly. In order to do that, we modify the function's code by
adding the text
local AUTOLOADED='func';
to the shim and to the actual function text, just after the opening
brace. Then supporting -p and -s is just a matter of grepping through
all the function text in memory. Even though grepping through the
environment may not be the most efficient way to support this, it is
the simplest to implement for -p and -s operations that are not
heavily used.
As a consquence of this (and other reasons), the AUTOLOAD* namespace
is reserved for autoloading. Make sure you check any functions that
you bring under autoload for use of variables or functions that start
with AUTOLOAD and change them.
o The easiest way to load shims for all functions on the FPATH is to run
autoload -f -x
in the profile that gets run for login shells.
When called in the profile of a login shell where no definitions
exist, -f will load all functions it can find on FPATH and -x will
export all of those functions to be available in subshells when this
is called in a login shell. Using this option will relieve you of the
need to call 'autoload' after Every Single Function Definition, nor
will you need to call it in subshells.
The only thing left to do is to load up the autoload function itself
and its helper functions. That needs to happen in your profile:
export FPATH=~/functions # or wherever you stash them
if [ -z $(declare -F autoload) ]
then
. ~/bin/autoload # or wherever you've put it
fi
The 'if' statement is used to make sure we don't reload autoload
needlessly. Sourcing in the autoload script loads the 'autoload'
function and all of its support functions. Additionally, we export
all of these functions so that they are available in subshells; you
do not have to re-source the autoload file in '.bashrc'.
o Even with all of these shenanigans, you will find cases where no
matter how hard you try, your autoloaded functions will be
unavailable to you, even if you run 'autoload -x -f'. The typical
condition for this is starting up not a subshell, but a brand new
DIFFERENT shell. And the typical example of this is git extentions.
At the time of this writing, git extentions work by taking a command
'git foo' and looking for a file 'git-foo' on the path. 'git' then
executes 'git-foo' in a new shell - it executes your command in
/bin/sh. That's not a subshell of your process. It will not get your
exported shell functions. Ballgame over.
If you find that you want your functions to be available in such
circumstances, convert them back to plain old scripts, make sure they
are 'sh' compliant and take the read/parse hit every time they are
run.
EOH
}
autoload()
{
if (( $# == 0 )) ; then _autoload_dump; return; fi
local opt OPTIND OPTARG
local passthru
local dumpopt
while getopts psuema:yxrvlohf opt
do
case $opt in
p|s) dumpopt="$dumpopt -${opt}";;
u) shift $((OPTIND-1)); _autoload_remove "$@"; return;;
e) shift $((OPTIND-1)); _autoload_edit "$@"; return;;
m) shift $((OPTIND-1)); _autoload_page "$@"; return;;
x|r|v|l|y|f|o) passthru="$passthru -$opt";;
a) passthru="$passthru -$opt $OPTARG";;
h) _autoload_help; return;;
*) echo "autoload: usage: autoload [-puUx] [function ...]" >&2; return;;
esac
done
shift $(($OPTIND-1))
if [ -n "$dumpopt" ]
then
_autoload_dump $dumpopt
else
_aload $passthru "$@"
fi
}
autoreload ()
{
autoload -r "$@"
}
## When we source in autoload, we export (but NOT autoload) the autoload
## functions so that they are available in subshells and you don't have to
## source in the autoload file in subshells.
export -f _aload \
_autoload_dump \
_autoload_edit \
_autoload_help \
_autoload_page \
_autoload_resolve \
_autoload_split_fpath \
autoload \
autoload_calc_shimsize \
autoreload

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