bash-5.0 distribution sources and documentation
This commit is contained in:
parent
6444760999
commit
d233b485e8
528 changed files with 84836 additions and 67099 deletions
818
CHANGES
818
CHANGES
|
@ -1,3 +1,820 @@
|
|||
This document details the changes between this version, bash-5.0-release, and
|
||||
the previous version, bash-5.0-rc1.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Tilde expansion isn't performed on indexed array subscripts, even for
|
||||
backwards compatibility.
|
||||
|
||||
b. The shell doesn't exit in posix mode if the eval builtin gets a parse
|
||||
error when run by the command builtin.
|
||||
|
||||
c. Fixed a bug that caused a shell comment in an alias to not find the end
|
||||
of the alias properly.
|
||||
|
||||
d. Reverted a change from April, 2018 that caused strings containing
|
||||
backslashes to be flagged as glob patterns.
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-5.0-rc1, and
|
||||
the previous version, bash-5.0-beta2.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fix to initial word completion detection code.
|
||||
|
||||
b. Fixed a bug that caused issues with assignment statements containing ^A in
|
||||
the value assigned when IFS contains ^A.
|
||||
|
||||
c. Added a fallback to fnmatch() when strcoll can't correctly deal with
|
||||
bracket expression character equivalence classes.
|
||||
|
||||
d. Fixed a bug that caused $BASH_COMMAND to contain the trap handler command
|
||||
when running a trap handler containing [[ or (( commands.
|
||||
|
||||
e. Fixed a bug that caused nameref assignments in the temporary environment
|
||||
to potentially create variables with invalid names.
|
||||
|
||||
f. Fixed a bug that caused `local -' to turn off alias expansion in scripts.
|
||||
|
||||
g. Fixed a parser issue with a command string containing EOF after an invalid
|
||||
command as an argument to a special builtin not causing a posix-mode shell
|
||||
to exit.
|
||||
|
||||
h. Made a slight change to the FNV-1 string hash algorithm used for associative
|
||||
arrays (corrected the initial seed).
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
a. The `select' command now supports command forms without a word list
|
||||
following `in'.
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-5.0-beta2, and
|
||||
the previous version, bash-5.0-beta.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed a bug that could cause a seg fault while parsing a subshell command
|
||||
inside a command substitution.
|
||||
|
||||
b. Fixed several small memory leaks uncovered by coverity.
|
||||
|
||||
c. Fixed a problem with command substitution inside an interactive shell that
|
||||
could cause the parent to receive a SIGHUP.
|
||||
|
||||
d. Fixed a problem with using `*' and `@' as subscripts when assigning values
|
||||
to an associative array with assoc_expand_once enabled.
|
||||
|
||||
e. Fixed a bug that could cause a huge memory allocation when completing a
|
||||
word beginning with an invalid tilde expansion.
|
||||
|
||||
f. Cleaned up some incompatiblities with bash-4.4 when expanding indexed array
|
||||
subscripts used in arithmetic expansions when assoc_expand_once is enabled.
|
||||
|
||||
g. The ${parameter@a} expansion will display attributes even if `parameter' is
|
||||
unset.
|
||||
|
||||
h. Fixed a bug that caused the output of `set' to cut off some variables before
|
||||
printing the value.
|
||||
|
||||
i. Treat a failure to assign a variable when using the ${x:=value} expansion
|
||||
as an expansion error, so non-interactive posix-mode shells exit
|
||||
|
||||
j. Fixed a problem when expanding $* in a context where word splitting is not
|
||||
performed when IFS is NULL.
|
||||
|
||||
k. Temp files used to store here documents are forced readable, no matter what
|
||||
the user's umask says.
|
||||
|
||||
l. Fixed a problem where an interrupted brace expansion could cause the shell
|
||||
to attempt to free an invalid memory location.
|
||||
|
||||
m. Make sure to check for any terminating signals after running a trap
|
||||
handler; don't wait until the next time we process traps.
|
||||
|
||||
n. Fixed a bug that caused "return" to act like a special builtin with respect
|
||||
to variable assignments even when preceded by "command".
|
||||
|
||||
o. POSIX-mode shells now return failure if the cd builtin fails due to the
|
||||
absolute directory name being longer than PATH_MAX, instead of trying
|
||||
again with a relative pathname.
|
||||
|
||||
p. Fixed a problem with FUNCNAME occasionally being visible when not executing
|
||||
a shell function.
|
||||
|
||||
q. Fixed a problem with the expansions performed on the WORD in the case
|
||||
command.
|
||||
|
||||
r. Fixed a slight POSIX compatibility when removing "IFS whitespace" during
|
||||
word splitting and the read builtin.
|
||||
|
||||
s. Fixed a problem with expanding an array with subscript `*' when all the
|
||||
elements expand to the empty string, and making sure the expansion honors
|
||||
the `:' specifier.
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
a. Fixed a bug with adding multibyte characters to an incremental search string.
|
||||
|
||||
b. Fixed a bug with redoing text insertions in vi mode.
|
||||
|
||||
c. Fixed a bug with pasting text into an incremental search string if bracketed
|
||||
paste mode is enabled. ESC cannot be one of the incremental search
|
||||
terminator characters for this to work.
|
||||
|
||||
d. Fixed a bug with anchored search patterns when performing searches in vi
|
||||
mode.
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
a. Associative and indexed arrays now allow subscripts consisting solely of
|
||||
whitespace.
|
||||
|
||||
b. `checkwinsize' is now enabled by default.
|
||||
|
||||
c. The `localvar_unset' shopt option is now visible and documented.
|
||||
|
||||
d. The `progcomp_alias' shopt option is now visible and documented.
|
||||
|
||||
e. The signal name processing code now understands `SIGRTMIN+n' all the way
|
||||
up to SIGRTMAX.
|
||||
|
||||
f. There is a new `seq' loadable builtin.
|
||||
|
||||
g. Trap execution now honors the (internal) max invocations of `eval', since
|
||||
traps are supposed to be executed as if using `eval'.
|
||||
|
||||
h. The $_ variable doesn't change when the shell executes a command that forks.
|
||||
|
||||
i. The `kill' builtin now supports -sSIGNAME and -nSIGNUM, even though
|
||||
conforming applications aren't supposed to use them.
|
||||
|
||||
j. POSIX mode now enables the `shift_verbose' option.
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
a. Readline now allows application-defined keymap names; there is a new public
|
||||
function, rl_set_keymap_name(), to do that.
|
||||
|
||||
b. The "Insert" keypad key, if available, now puts readline into overwrite
|
||||
mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
This document details the changes between this version, bash-5.0-beta, and
|
||||
the previous version, bash-5.0-alpha.
|
||||
|
||||
1. Changes to Bash
|
||||
|
||||
a. Fixed a bug that allowed subshells to "inherit" enclosing loops -- this
|
||||
is where POSIX says the subshell is not "enclosed" by the loop.
|
||||
|
||||
b. Added more UTF-8-specific versions of multibyte functions, and optimized
|
||||
existing functions if the current locale uses UTF-8 encoding.
|
||||
|
||||
c. In POSIX mode, assignments preceding regular builtins should not persist
|
||||
when the builtin completes.
|
||||
|
||||
d. Added additional checks to special array assignment (e.g., BASH_ALIASES)
|
||||
so it can't be used to bypass validity checks performed in other places.
|
||||
|
||||
e. The `!!' history expansion now refers to the previous history entry as
|
||||
expected, even if used on the second or subsequent line of a multi-line
|
||||
history entry.
|
||||
|
||||
f. Fixed a bug that could cause the shell to dereference a NULL pointer if
|
||||
the environment (`environ') is set to NULL.
|
||||
|
||||
g. Bash uses slightly better integer overflow handling for brace sequence
|
||||
expansion on systems where ints are 32 bits and intmax_t is 64 bits.
|
||||
|
||||
h. Fixed a bug setting attributes for a variable named as an argument to
|
||||
`declare' that also appears as a nameref in the temporary environment.
|
||||
|
||||
i. Fixed several bugs that could cause assignments to namerefs to create
|
||||
variables with invalid names.
|
||||
|
||||
j. Fixed a bug that could result in the SIGINT handler being set incorrectly
|
||||
in asynchronous subshells.
|
||||
|
||||
k. Fixed a bug that could cause `bash -t' to not execute the specified command.
|
||||
|
||||
l. Fixed several bugs that caused the shell to operate on the wrong variable
|
||||
when using namerefs with the same name as a global variable in shell
|
||||
functions.
|
||||
|
||||
m. Internal changes to how the shell handles variables with invalid names in
|
||||
the initial environment and to prevent variables with invalid names from
|
||||
being added to the environment instead of passing them on to children.
|
||||
|
||||
n. Changes to make sure that an expansion that results in a quoted null string
|
||||
is reflected in the expansion, even if the word expands to nothing.
|
||||
|
||||
o. Changes to make sure that $* and ${array[*]} (and $@/${array[@]}) expand
|
||||
the same way after the recent changes for POSIX interpretation 888.
|
||||
|
||||
p. Saving and restoring the positional parameters at function entry and exit
|
||||
is considerably more efficient; noticeably so when there are large numbers
|
||||
of positional parameters.
|
||||
|
||||
q. Fixed a bug that caused `lastpipe' and `pipefail' to return an incorrect
|
||||
status for the pipeline if there was more than one external command in a
|
||||
loop body appearing in the last pipeline element.
|
||||
|
||||
r. Fixed a bug that caused value conversion errors with the printf builtin's
|
||||
%u and %f conversion specifications and invalid constants.
|
||||
|
||||
2. Changes to Readline
|
||||
|
||||
a. Added more UTF-8-specific versions of multibyte functions, and optimized
|
||||
existing functions if the current locale uses UTF-8 encoding.
|
||||
|
||||
b. Fixed a problem with bracketed-paste inserting more than one character and
|
||||
interacting with other readline functions.
|
||||
|
||||
c. Fixed a bug that caused the history library to attempt to append a history
|
||||
line to a non-existent history entry.
|
||||
|
||||
d. If using bracketed paste mode, output a newline after the \r that is the
|
||||
last character of the mode disable string to avoid overwriting output.
|
||||
|
||||
e. Fixes to the vi-mode `b', `B', `w', `W', `e', and `E' commands to better
|
||||
handle multibyte characters.
|
||||
|
||||
f. Fixed a redisplay problem that caused an extra newline to be generated on
|
||||
accept-line when the line length is exactly the screenwidth.
|
||||
|
||||
3. New Features in Bash
|
||||
|
||||
a. Bash no longer allows variable assignments preceding a special builtin that
|
||||
changes variable attributes to propagate back to the calling environment
|
||||
unless the compatibility level is 44 or lower.
|
||||
|
||||
b. You can set the default value for $HISTSIZE at build time in config-top.h.
|
||||
|
||||
c. The `complete' builtin now accepts a -I option that applies the completion
|
||||
to the initial word on the line.
|
||||
|
||||
d. The internal bash malloc now uses mmap (if available) to satisfy requests
|
||||
greater than 128K bytes, so free can use mfree to return the pages to the
|
||||
kernel.
|
||||
|
||||
e. The shell doesn't automatically set BASH_ARGC and BASH_ARGV at startup
|
||||
unless it's in debugging mode, as the documentation has always said, but
|
||||
will dynamically create them if a script references them at the top level
|
||||
without having enabled debugging mode.
|
||||
|
||||
f. The localvar_inherit option will not attempt to inherit a value from a
|
||||
variable of an incompatible type (indexed vs. associative arrays, for
|
||||
example).
|
||||
|
||||
g. The `globasciiranges' option is now enabled by default; it can be set to
|
||||
off by default at configuration time.
|
||||
|
||||
4. New Features in Readline
|
||||
|
||||
a. The history expansion library now understands command and process
|
||||
substitution and extended globbing and allows them to appear anywhere in a
|
||||
word.
|
||||
|
||||
b. The history library has a new variable that allows applications to set the
|
||||
initial quoting state, so quoting state can be inherited from a previous
|
||||
line.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
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 in an attempt to
|
||||
detect file descriptor errors.
|
||||
|
||||
nnn. The `read' builtin now does a better job of acting on signals that don't
|
||||
interrupt 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 searching 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 +838,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.
|
||||
|
|
40
COMPAT
40
COMPAT
|
@ -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,20 @@ 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.
|
||||
|
||||
61. Bash-5.0 doesn't allow a `break' or `continue' in a subshell to attempt
|
||||
to break or continue loop execution inherited from the calling context.
|
||||
|
||||
62. Bash-5.0 doesn't allow variable assignments preceding builtins like
|
||||
export and readonly to modify variables with the same name in preceding
|
||||
contexts (including the global context) unless the shell is in posix
|
||||
mode, since export and readonly are special builtins.
|
||||
|
||||
|
||||
Shell Compatibility Level
|
||||
=========================
|
||||
|
||||
|
@ -446,10 +460,22 @@ compat43 set
|
|||
(declare -a foo='(1 2)')
|
||||
- word expansion errors are considered non-fatal errors that cause the
|
||||
current command to fail, even in Posix mode
|
||||
- when executing a shell function, the loop state (while/until/etc.) is
|
||||
not reset, so `break' or `continue' in a shell function will break or
|
||||
continue loops in the calling context. Bash-4.4 and later reset the
|
||||
loop state to prevent this.
|
||||
- when executing a shell function, the loop state (while/until/etc.)
|
||||
is not reset, so `break' or `continue' in that function will break
|
||||
or 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
|
||||
- a subshell inherits loops from its parent contenxt, so `break'
|
||||
or `continue' will cause the subshell to exit
|
||||
- variable assignments preceding builtins like export and readonly
|
||||
that set attributes continue to affect variables with the same
|
||||
name in the calling environment even if the shell is not in posix
|
||||
mode
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
|
|
15916
CWRU/changelog
15916
CWRU/changelog
File diff suppressed because it is too large
Load diff
50
INSTALL
50
INSTALL
|
@ -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
|
||||
=================
|
||||
|
||||
|
@ -248,8 +248,8 @@ and linked, rather than changing run-time features.
|
|||
|
||||
'--enable-largefile'
|
||||
Enable support for large files
|
||||
(http://www.sas.com/standards/large_file/x_open.20Mar96.html) if
|
||||
the operating system requires special compiler options to build
|
||||
(http://www.unix.org/version2/whatsnew/lfs20mar.html) 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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
|
82
MANIFEST
82
MANIFEST
|
@ -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
|
||||
|
@ -450,6 +453,7 @@ lib/sh/tmpfile.c f
|
|||
lib/sh/uconvert.c f
|
||||
lib/sh/ufuncs.c f
|
||||
lib/sh/unicode.c f
|
||||
lib/sh/utf8.c f
|
||||
lib/sh/vprint.c f
|
||||
lib/sh/wcsdup.c f
|
||||
lib/sh/wcsnwidth.c f
|
||||
|
@ -534,6 +538,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 +637,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 +656,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
|
||||
|
@ -666,12 +675,14 @@ examples/loadables/necho.c f
|
|||
examples/loadables/hello.c f
|
||||
examples/loadables/print.c f
|
||||
examples/loadables/realpath.c f
|
||||
examples/loadables/seq.c f
|
||||
examples/loadables/setpgid.c f
|
||||
examples/loadables/sleep.c f
|
||||
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 +692,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 +705,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 +714,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 +824,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 +842,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 +866,12 @@ 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/array26.sub f
|
||||
tests/array27.sub f
|
||||
tests/array-at-star f
|
||||
tests/array2.right f
|
||||
tests/assoc.tests f
|
||||
|
@ -859,6 +884,8 @@ tests/assoc5.sub f
|
|||
tests/assoc6.sub f
|
||||
tests/assoc7.sub f
|
||||
tests/assoc8.sub f
|
||||
tests/assoc9.sub f
|
||||
tests/assoc10.sub f
|
||||
tests/attr.tests f
|
||||
tests/attr.right f
|
||||
tests/attr1.sub f
|
||||
|
@ -883,6 +910,9 @@ 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/case4.sub f
|
||||
tests/casemod.tests f
|
||||
tests/casemod.right f
|
||||
tests/comsub.tests f
|
||||
|
@ -890,6 +920,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
|
||||
|
@ -933,6 +964,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 +972,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 +989,8 @@ tests/errors3.sub f
|
|||
tests/errors4.sub f
|
||||
tests/errors5.sub f
|
||||
tests/errors6.sub f
|
||||
tests/errors7.sub f
|
||||
tests/errors8.sub f
|
||||
tests/execscript f
|
||||
tests/exec.right f
|
||||
tests/exec1.sub f 755
|
||||
|
@ -979,6 +1017,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 +1036,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 +1057,9 @@ 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/glob4.sub f
|
||||
tests/glob.right f
|
||||
tests/globstar.tests f
|
||||
tests/globstar.right f
|
||||
|
@ -1025,6 +1070,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
|
||||
|
@ -1033,14 +1079,18 @@ tests/histexp1.sub f
|
|||
tests/histexp2.sub f
|
||||
tests/histexp3.sub f
|
||||
tests/histexp4.sub f
|
||||
tests/histexp5.sub f
|
||||
tests/histexp6.sub f
|
||||
tests/histexp.right f
|
||||
tests/history.tests f
|
||||
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 +1112,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 +1144,9 @@ tests/nameref15.sub f
|
|||
tests/nameref16.sub f
|
||||
tests/nameref17.sub f
|
||||
tests/nameref18.sub f
|
||||
tests/nameref19.sub f
|
||||
tests/nameref20.sub f
|
||||
tests/nameref21.sub f
|
||||
tests/nameref.right f
|
||||
tests/new-exp.tests f
|
||||
tests/new-exp1.sub f
|
||||
|
@ -1105,6 +1159,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 +1181,16 @@ 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/posixexp7.sub f
|
||||
tests/posixexp2.tests f
|
||||
tests/posixexp2.right f
|
||||
tests/posixpat.tests f
|
||||
|
@ -1144,9 +1205,13 @@ 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
|
||||
tests/quote2.sub f
|
||||
tests/read.tests f
|
||||
tests/read.right f
|
||||
tests/read1.sub f
|
||||
|
@ -1171,12 +1236,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 +1267,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 +1309,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 +1340,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 +1354,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
|
||||
|
@ -1295,7 +1365,7 @@ tests/unicode1.sub f
|
|||
tests/unicode2.sub f
|
||||
tests/unicode3.sub f
|
||||
tests/varenv.right f
|
||||
tests/varenv.sh f
|
||||
tests/varenv.tests f
|
||||
tests/varenv1.sub f
|
||||
tests/varenv2.sub f
|
||||
tests/varenv3.sub f
|
||||
|
@ -1304,6 +1374,14 @@ 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/varenv13.sub f
|
||||
tests/varenv14.sub f
|
||||
tests/varenv15.sub f
|
||||
tests/varenv15.in f
|
||||
tests/version f
|
||||
tests/version.mini f
|
||||
tests/vredir.tests f
|
||||
|
|
136
Makefile.in
136
Makefile.in
|
@ -1,6 +1,6 @@
|
|||
# Makefile for bash-4.4, version 4.18
|
||||
# Makefile for bash-5.0, version 4.27
|
||||
#
|
||||
# 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
|
||||
|
@ -41,6 +41,7 @@ infodir = @infodir@
|
|||
includedir = @includedir@
|
||||
datadir = @datadir@
|
||||
localedir = @localedir@
|
||||
pkgconfigdir = ${libdir}/pkgconfig
|
||||
|
||||
loadablesdir = @loadablesdir@
|
||||
headersdir = @headersdir@
|
||||
|
@ -77,6 +78,7 @@ AR = @AR@
|
|||
ARFLAGS = @ARFLAGS@
|
||||
RANLIB = @RANLIB@
|
||||
SIZE = @SIZE@
|
||||
STRIP = strip
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
|
@ -144,16 +146,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
|
||||
|
@ -222,7 +231,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
|
|||
${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \
|
||||
${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \
|
||||
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \
|
||||
${SH_LIBSRC}/shmbchar.c
|
||||
${SH_LIBSRC}/shmbchar.c ${SH_LIBSRC}/utf8.c
|
||||
|
||||
SHLIB_LIB = -lsh
|
||||
SHLIB_LIBNAME = libsh.a
|
||||
|
@ -583,22 +592,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
|
||||
|
@ -810,7 +835,7 @@ install-headers-dirs:
|
|||
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)
|
||||
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/builtins
|
||||
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/include
|
||||
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig
|
||||
@${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(pkgconfigdir)
|
||||
|
||||
install-headers: install-headers-dirs
|
||||
@for hf in $(INSTALLED_HEADERS) ; do \
|
||||
|
@ -825,14 +850,14 @@ install-headers: install-headers-dirs
|
|||
@for hf in $(CREATED_HEADERS) ; do \
|
||||
${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \
|
||||
done
|
||||
$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(libdir)/pkgconfig/bash.pc
|
||||
-$(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(pkgconfigdir)/bash.pc
|
||||
|
||||
uninstall-headers:
|
||||
-( cd $(DESTDIR)$(headersdir) && $(RM) $(INSTALLED_HEADERS) )
|
||||
-( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCFILES) )
|
||||
-( cd $(DESTDIR)$(headersdir)/builtins && $(RM) $(INSTALLED_BUILTINS_HEADERS) )
|
||||
-( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) )
|
||||
-( $(RM) $(DESTDIR)$(libdir)/pkgconfig/bash.pc )
|
||||
-( $(RM) $(DESTDIR)$(pkgconfigdir)/bash.pc )
|
||||
|
||||
uninstall: .made
|
||||
$(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug
|
||||
|
@ -902,7 +927,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 +1006,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 +1028,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 +1060,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 +1083,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 +1115,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 +1123,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 +1153,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 +1163,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 +1178,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 +1201,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 +1244,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 +1306,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 +1338,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 +1373,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 +1419,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 +1486,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 +1510,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 +1518,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 +1532,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 +1544,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
|
||||
|
|
178
NEWS
178
NEWS
|
@ -1,3 +1,181 @@
|
|||
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.
|
||||
|
||||
bb. Bash no longer allows variable assignments preceding a special builtin that
|
||||
changes variable attributes to propagate back to the calling environment
|
||||
unless the compatibility level is 44 or lower.
|
||||
|
||||
cc. You can set the default value for $HISTSIZE at build time in config-top.h.
|
||||
|
||||
dd. The `complete' builtin now accepts a -I option that applies the completion
|
||||
to the initial word on the line.
|
||||
|
||||
ee. The internal bash malloc now uses mmap (if available) to satisfy requests
|
||||
greater than 128K bytes, so free can use mfree to return the pages to the
|
||||
kernel.
|
||||
|
||||
ff. The shell doesn't automatically set BASH_ARGC and BASH_ARGV at startup
|
||||
unless it's in debugging mode, as the documentation has always said, but
|
||||
will dynamically create them if a script references them at the top level
|
||||
without having enabled debugging mode.
|
||||
|
||||
gg. The localvar_inherit option will not attempt to inherit a value from a
|
||||
variable of an incompatible type (indexed vs. associative arrays, for
|
||||
example).
|
||||
|
||||
hh. The `globasciiranges' option is now enabled by default; it can be set to
|
||||
off by default at configuration time.
|
||||
|
||||
ii. Associative and indexed arrays now allow subscripts consisting solely of
|
||||
whitespace.
|
||||
|
||||
jj. `checkwinsize' is now enabled by default.
|
||||
|
||||
kk. The `localvar_unset' shopt option is now visible and documented.
|
||||
|
||||
ll. The `progcomp_alias' shopt option is now visible and documented.
|
||||
|
||||
mm. The signal name processing code now understands `SIGRTMIN+n' all the way
|
||||
up to SIGRTMAX.
|
||||
|
||||
nn. There is a new `seq' loadable builtin.
|
||||
|
||||
oo. Trap execution now honors the (internal) max invocations of `eval', since
|
||||
traps are supposed to be executed as if using `eval'.
|
||||
|
||||
pp. The $_ variable doesn't change when the shell executes a command that forks.
|
||||
|
||||
qq. The `kill' builtin now supports -sSIGNAME and -nSIGNUM, even though
|
||||
conforming applications aren't supposed to use them.
|
||||
|
||||
rr. POSIX mode now enables the `shift_verbose' option.
|
||||
|
||||
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.
|
||||
|
||||
h. The history expansion library now understands command and process
|
||||
substitution and extended globbing and allows them to appear anywhere in a
|
||||
word.
|
||||
|
||||
i. The history library has a new variable that allows applications to set the
|
||||
initial quoting state, so quoting state can be inherited from a previous
|
||||
line.
|
||||
|
||||
j. Readline now allows application-defined keymap names; there is a new public
|
||||
function, rl_set_keymap_name(), to do that.
|
||||
|
||||
k. The "Insert" keypad key, if available, now puts readline into overwrite
|
||||
mode.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
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.
|
||||
|
|
127
POSIX
127
POSIX
|
@ -11,205 +11,224 @@ files.
|
|||
|
||||
The following list is what's changed when 'POSIX mode' is in effect:
|
||||
|
||||
1. When a command in the hash table no longer exists, Bash will
|
||||
1. Bash ensures that the 'POSIXLY_CORRECT' variable is set.
|
||||
|
||||
2. When a command in the hash table no longer exists, Bash will
|
||||
re-search '$PATH' to find the new location. This is also available
|
||||
with 'shopt -s checkhash'.
|
||||
|
||||
2. The message printed by the job control code and builtins when a job
|
||||
3. The message printed by the job control code and builtins when a job
|
||||
exits with a non-zero status is 'Done(status)'.
|
||||
|
||||
3. The message printed by the job control code and builtins when a job
|
||||
4. The message printed by the job control code and builtins when a job
|
||||
is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example,
|
||||
'SIGTSTP'.
|
||||
|
||||
4. Alias expansion is always enabled, even in non-interactive shells.
|
||||
5. Alias expansion is always enabled, even in non-interactive shells.
|
||||
|
||||
5. Reserved words appearing in a context where reserved words are
|
||||
6. Reserved words appearing in a context where reserved words are
|
||||
recognized do not undergo alias expansion.
|
||||
|
||||
6. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number
|
||||
7. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number
|
||||
and '!!' to '!' are enabled, and parameter expansion is performed
|
||||
on the values of 'PS1' and 'PS2' regardless of the setting of the
|
||||
'promptvars' option.
|
||||
|
||||
7. The POSIX startup files are executed ('$ENV') rather than the
|
||||
8. The POSIX startup files are executed ('$ENV') rather than the
|
||||
normal Bash files.
|
||||
|
||||
8. Tilde expansion is only performed on assignments preceding a
|
||||
9. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
||||
9. The default history file is '~/.sh_history' (this is the default
|
||||
10. The default history file is '~/.sh_history' (this is the default
|
||||
value of '$HISTFILE').
|
||||
|
||||
10. Redirection operators do not perform filename expansion on the
|
||||
11. Redirection operators do not perform filename expansion on the
|
||||
word in the redirection unless the shell is interactive.
|
||||
|
||||
11. Redirection operators do not perform word splitting on the word in
|
||||
12. Redirection operators do not perform word splitting on the word in
|
||||
the redirection.
|
||||
|
||||
12. Function names must be valid shell 'name's. That is, they may not
|
||||
13. Function names must be valid shell 'name's. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name causes a fatal syntax error in non-interactive shells.
|
||||
|
||||
13. Function names may not be the same as one of the POSIX special
|
||||
14. Function names may not be the same as one of the POSIX special
|
||||
builtins.
|
||||
|
||||
14. POSIX special builtins are found before shell functions during
|
||||
15. POSIX special builtins are found before shell functions during
|
||||
command lookup.
|
||||
|
||||
15. Literal tildes that appear as the first character in elements of
|
||||
16. When printing shell function definitions (e.g., by 'type'), Bash
|
||||
does not print the 'function' keyword.
|
||||
|
||||
17. 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
|
||||
18. 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
|
||||
19. 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
|
||||
20. 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
|
||||
21. 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
|
||||
22. 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
|
||||
23. 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
|
||||
24. 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
|
||||
25. 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
|
||||
26. Non-interactive shells exit if FILENAME in '.' FILENAME is not
|
||||
found.
|
||||
|
||||
25. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
27. 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.
|
||||
28. Non-interactive shells exit if a parameter expansion error occurs.
|
||||
|
||||
27. Non-interactive shells exit if there is a syntax error in a script
|
||||
29. 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.
|
||||
30. Process substitution is not available.
|
||||
|
||||
29. While variable indirection is available, it may not be applied to
|
||||
31. While variable indirection is available, it may not be applied to
|
||||
the '#' and '?' special parameters.
|
||||
|
||||
30. Assignment statements preceding POSIX special builtins persist in
|
||||
32. 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.
|
||||
|
||||
33. Assignment statements preceding POSIX special builtins persist in
|
||||
the shell environment after the builtin completes.
|
||||
|
||||
31. Assignment statements preceding shell function calls persist in
|
||||
34. 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
|
||||
35. 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
|
||||
36. 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
|
||||
37. 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'
|
||||
38. The 'kill' builtin does not accept signal names with a 'SIG'
|
||||
prefix.
|
||||
|
||||
36. The 'export' and 'readonly' builtin commands display their output
|
||||
39. 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
|
||||
40. The 'trap' builtin displays signal names without the leading
|
||||
'SIG'.
|
||||
|
||||
38. The 'trap' builtin doesn't check the first argument for a possible
|
||||
41. 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
|
||||
42. 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
|
||||
43. 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
|
||||
44. Enabling POSIX mode has the effect of setting the 'shift_verbose'
|
||||
option, so numeric arguments to 'shift' that exceed the number of
|
||||
positional parameters will result in an error message.
|
||||
|
||||
45. 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
|
||||
46. 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
|
||||
47. 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
|
||||
48. 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
|
||||
49. When the 'cd' builtin cannot change a directory because the length
|
||||
of the pathname constructed from '$PWD' and the directory name
|
||||
supplied as an argument exceeds PATH_MAX when all symbolic links
|
||||
are expanded, 'cd' will fail instead of attempting to use only the
|
||||
supplied directory name.
|
||||
|
||||
50. 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
|
||||
51. 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'.
|
||||
52. The default editor used by 'fc' is 'ed'.
|
||||
|
||||
48. The 'type' and 'command' builtins will not report a non-executable
|
||||
53. 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
|
||||
54. 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
|
||||
55. 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'
|
||||
56. 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
|
||||
57. 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
|
||||
58. 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
|
||||
59. 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
|
||||
|
|
18
README
18
README
|
@ -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
|
||||
|
|
107
aclocal.m4
vendored
107
aclocal.m4
vendored
|
@ -1,4 +1,4 @@
|
|||
dnl
|
||||
nl
|
||||
dnl Bash specific tests
|
||||
dnl
|
||||
dnl Some derived from PDKSH 5.1.3 autoconf tests
|
||||
|
@ -962,7 +962,8 @@ AC_CACHE_VAL(bash_cv_termcap_lib,
|
|||
[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
|
||||
[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
|
||||
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
|
||||
bash_cv_termcap_lib=gnutermcap)])])])])])
|
||||
[AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
|
||||
bash_cv_termcap_lib=gnutermcap)])])])])])])
|
||||
if test "X$_bash_needmsg" = "Xyes"; then
|
||||
AC_MSG_CHECKING(which library has the termcap functions)
|
||||
fi
|
||||
|
@ -1307,7 +1308,7 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
|
|||
|
||||
typedef RETSIGTYPE sigfunc();
|
||||
|
||||
int nsigint;
|
||||
volatile int nsigint;
|
||||
|
||||
#ifdef HAVE_POSIX_SIGNALS
|
||||
sigfunc *
|
||||
|
@ -1357,7 +1358,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 +1368,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 +1582,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 +1793,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 +1853,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='8.0')])
|
||||
|
||||
CFLAGS="$_save_CFLAGS"
|
||||
LDFLAGS="$_save_LDFLAGS"
|
||||
|
@ -4195,3 +4192,71 @@ 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
|
||||
])
|
||||
|
||||
AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
|
||||
[AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
|
||||
AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
|
||||
[AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fnmatch.h>
|
||||
#include <locale.h>
|
||||
|
||||
char *pattern = "[[=a=]]";
|
||||
|
||||
/* char *string = "ä"; */
|
||||
unsigned char string[4] = { '\xc3', '\xa4', '\0' };
|
||||
|
||||
int
|
||||
main (int c, char **v)
|
||||
{
|
||||
setlocale (LC_ALL, "de_DE.UTF-8");
|
||||
if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
|
||||
exit (0);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
], bash_cv_fnmatch_equiv_fallback=yes, bash_cv_fnmatch_equiv_fallback=no,
|
||||
[AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
|
||||
bash_cv_fnmatch_equiv_fallback=no]
|
||||
)])
|
||||
AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
|
||||
if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
|
||||
bash_cv_fnmatch_equiv_value=1
|
||||
else
|
||||
bash_cv_fnmatch_equiv_value=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
|
||||
])
|
||||
|
|
4
alias.c
4
alias.c
|
@ -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
alias.h
3
alias.h
|
@ -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_ */
|
||||
|
|
285
array.c
285
array.c
|
@ -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;
|
||||
|
@ -414,8 +406,8 @@ int starsub, quoted;
|
|||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *h, *p;
|
||||
arrayind_t i;
|
||||
char *ifs, *sifs, *t;
|
||||
int slen;
|
||||
char *t;
|
||||
WORD_LIST *wl;
|
||||
|
||||
p = a ? array_head (a) : 0;
|
||||
if (p == 0 || array_empty (a) || start > array_max_index(a))
|
||||
|
@ -440,32 +432,12 @@ int starsub, quoted;
|
|||
|
||||
a2 = array_slice(a, h, p);
|
||||
|
||||
if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
|
||||
if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) {
|
||||
/* ${array[*]} */
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free (sifs);
|
||||
} else if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc(sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free (sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
wl = array_to_word_list(a2);
|
||||
array_dispose(a2);
|
||||
if (wl == 0)
|
||||
return (char *)NULL;
|
||||
t = string_list_pos_params(starsub ? '*' : '@', wl, quoted);
|
||||
dispose_words(wl);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
@ -476,46 +448,28 @@ ARRAY *a;
|
|||
char *pat, *rep;
|
||||
int mflags;
|
||||
{
|
||||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *e;
|
||||
char *t, *sifs, *ifs;
|
||||
int slen;
|
||||
char *t;
|
||||
int pchar, qflags;
|
||||
WORD_LIST *wl, *save;
|
||||
|
||||
if (a == 0 || array_head(a) == 0 || array_empty(a))
|
||||
return ((char *)NULL);
|
||||
|
||||
a2 = array_copy(a);
|
||||
for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) {
|
||||
t = pat_subst(element_value(e), pat, rep, mflags);
|
||||
FREE(element_value(e));
|
||||
e->value = t;
|
||||
wl = array_to_word_list(a);
|
||||
if (wl == 0)
|
||||
return (char *)NULL;
|
||||
|
||||
for (save = wl; wl; wl = wl->next) {
|
||||
t = pat_subst (wl->word->word, pat, rep, mflags);
|
||||
FREE (wl->word->word);
|
||||
wl->word->word = t;
|
||||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
if (mflags & MATCH_STARSUB) {
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else if (mflags & MATCH_QUOTED) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_dispose (a2);
|
||||
t = string_list_pos_params (pchar, save, qflags);
|
||||
dispose_words(save);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
@ -527,49 +481,32 @@ char *pat;
|
|||
int modop;
|
||||
int mflags;
|
||||
{
|
||||
ARRAY *a2;
|
||||
ARRAY_ELEMENT *e;
|
||||
char *t, *sifs, *ifs;
|
||||
int slen;
|
||||
char *t;
|
||||
int pchar, qflags;
|
||||
WORD_LIST *wl, *save;
|
||||
|
||||
if (a == 0 || array_head(a) == 0 || array_empty(a))
|
||||
return ((char *)NULL);
|
||||
|
||||
a2 = array_copy(a);
|
||||
for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) {
|
||||
t = sh_modcase(element_value(e), pat, modop);
|
||||
FREE(element_value(e));
|
||||
e->value = t;
|
||||
wl = array_to_word_list(a);
|
||||
if (wl == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
for (save = wl; wl; wl = wl->next) {
|
||||
t = sh_modcase(wl->word->word, pat, modop);
|
||||
FREE(wl->word->word);
|
||||
wl->word->word = t;
|
||||
}
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
array_quote(a2);
|
||||
else
|
||||
array_quote_escapes(a2);
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
if (mflags & MATCH_STARSUB) {
|
||||
array_remove_quoted_nulls (a2);
|
||||
sifs = ifs_firstchar((int *)NULL);
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else if (mflags & MATCH_QUOTED) {
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0) {
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = array_to_string (a2, sifs, 0);
|
||||
free(sifs);
|
||||
} else
|
||||
t = array_to_string (a2, " ", 0);
|
||||
array_dispose (a2);
|
||||
t = string_list_pos_params (pchar, save, qflags);
|
||||
dispose_words(save);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate and return a new array element with index INDEX and value
|
||||
* VALUE.
|
||||
|
@ -618,6 +555,8 @@ arrayind_t i;
|
|||
char *v;
|
||||
{
|
||||
register ARRAY_ELEMENT *new, *ae, *start;
|
||||
arrayind_t startind;
|
||||
int direction;
|
||||
|
||||
if (a == 0)
|
||||
return(-1);
|
||||
|
@ -633,6 +572,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 +585,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 +643,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 +682,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 +700,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
array.h
4
array.h
|
@ -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)
|
||||
|
|
139
arrayfunc.c
139
arrayfunc.c
|
@ -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));
|
||||
|
@ -195,6 +199,8 @@ bind_array_var_internal (entry, ind, key, value, flags)
|
|||
FREE (newval);
|
||||
|
||||
VUNSETATTR (entry, att_invisible); /* no longer invisible */
|
||||
|
||||
/* check mark_modified_variables if we ever want to export array vars */
|
||||
return (entry);
|
||||
}
|
||||
|
||||
|
@ -258,9 +264,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,29 +275,32 @@ 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;
|
||||
int flags;
|
||||
{
|
||||
char *sub, *vname;
|
||||
int sublen;
|
||||
SHELL_VAR *entry, *nv;
|
||||
int sublen, isassoc;
|
||||
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);
|
||||
|
||||
if ((ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']') || (sublen <= 1))
|
||||
entry = find_variable (vname);
|
||||
isassoc = entry && assoc_p (entry);
|
||||
|
||||
if (((isassoc == 0 || (flags & ASS_NOEXPAND) == 0) && (ALL_ELEMENT_SUB (sub[0]) && sub[1] == ']')) || (sublen <= 1))
|
||||
{
|
||||
free (vname);
|
||||
err_badarraysub (name);
|
||||
return ((SHELL_VAR *)NULL);
|
||||
}
|
||||
|
||||
entry = find_variable (vname);
|
||||
entry = assign_array_element_internal (entry, name, vname, sub, sublen, value, flags);
|
||||
|
||||
free (vname);
|
||||
|
@ -317,7 +323,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 +338,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 +459,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 +591,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 +767,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))); /* XXX */
|
||||
if (sub[len] != ']' || len == 0)
|
||||
{
|
||||
builtin_error ("%s[%s: %s", var->name, sub, _(bash_badsub_errmsg));
|
||||
|
@ -790,7 +800,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 +808,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 +829,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)
|
||||
{
|
||||
|
@ -879,42 +890,62 @@ print_assoc_assignment (var, quoted)
|
|||
/***********************************************************************/
|
||||
|
||||
/* Return 1 if NAME is a properly-formed array reference v[sub]. */
|
||||
|
||||
/* We need to reserve 1 for FLAGS, which we pass to skipsubscript. */
|
||||
int
|
||||
valid_array_reference (name, flags)
|
||||
const char *name;
|
||||
int flags;
|
||||
{
|
||||
char *t;
|
||||
int r, len;
|
||||
int r, len, isassoc;
|
||||
SHELL_VAR *entry;
|
||||
|
||||
t = mbschr (name, '['); /* ] */
|
||||
isassoc = 0;
|
||||
if (t)
|
||||
{
|
||||
*t = '\0';
|
||||
r = legal_identifier (name);
|
||||
if (flags & VA_NOEXPAND) /* Don't waste a lookup if we don't need one */
|
||||
isassoc = (entry = find_variable (name)) && assoc_p (entry);
|
||||
*t = '[';
|
||||
if (r == 0)
|
||||
return 0;
|
||||
/* Check for a properly-terminated non-blank subscript. */
|
||||
len = skipsubscript (t, 0, 0);
|
||||
if (t[len] != ']' || len == 1)
|
||||
return 0;
|
||||
if (t[len+1] != '\0')
|
||||
|
||||
if (isassoc && ((flags & (VA_NOEXPAND|VA_ONEWORD)) == (VA_NOEXPAND|VA_ONEWORD)))
|
||||
len = strlen (t) - 1;
|
||||
else if (isassoc)
|
||||
len = skipsubscript (t, 0, flags&VA_NOEXPAND); /* VA_NOEXPAND must be 1 */
|
||||
else
|
||||
/* Check for a properly-terminated non-null subscript. */
|
||||
len = skipsubscript (t, 0, 0); /* arithmetic expression */
|
||||
|
||||
if (t[len] != ']' || len == 1 || t[len+1] != '\0')
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
/* Could check and allow subscripts consisting only of whitespace for
|
||||
existing associative arrays, using isassoc */
|
||||
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 +954,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.1 */
|
||||
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 +985,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 +1004,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 +1031,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 +1082,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. */
|
||||
|
@ -1067,6 +1107,8 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
|||
}
|
||||
else if (var == 0 || value_cell (var) == 0) /* XXX - check for invisible_p(var) ? */
|
||||
return ((char *)NULL);
|
||||
else if (invisible_p (var))
|
||||
return ((char *)NULL);
|
||||
else if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
|
||||
else if (assoc_p (var))
|
||||
|
@ -1082,15 +1124,16 @@ 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 +1145,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 +1163,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)
|
||||
{
|
||||
|
@ -1134,6 +1180,11 @@ array_value_internal (s, quoted, flags, rtype, indp)
|
|||
FREE (akey);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else if (invisible_p (var))
|
||||
{
|
||||
FREE (akey);
|
||||
return ((char *)NULL);
|
||||
}
|
||||
if (array_p (var) == 0 && assoc_p (var) == 0)
|
||||
return (ind == 0 ? value_cell (var) : (char *)NULL);
|
||||
else if (assoc_p (var))
|
||||
|
@ -1182,7 +1233,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 +1253,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);
|
||||
}
|
||||
|
|
22
arrayfunc.h
22
arrayfunc.h
|
@ -25,12 +25,24 @@
|
|||
|
||||
#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 */
|
||||
|
||||
/* Flags for valid_array_reference. Value 1 is reserved for skipsubscript() */
|
||||
#define VA_NOEXPAND 0x001
|
||||
#define VA_ONEWORD 0x002
|
||||
|
||||
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
|
||||
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
|
||||
|
@ -52,21 +64,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
|
||||
|
||||
|
@ -75,6 +87,8 @@ extern SHELL_VAR *array_variable_part __P((const char *, char **, int *));
|
|||
#define AV_USEIND 0
|
||||
#define AV_ASSIGNRHS 0
|
||||
|
||||
#define VA_ONEWORD 0
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_ARRAYFUNC_H_ */
|
||||
|
|
110
assoc.c
110
assoc.c
|
@ -305,54 +305,29 @@ assoc_patsub (h, pat, rep, mflags)
|
|||
char *pat, *rep;
|
||||
int mflags;
|
||||
{
|
||||
BUCKET_CONTENTS *tlist;
|
||||
int i, slen;
|
||||
HASH_TABLE *h2;
|
||||
char *t, *sifs, *ifs;
|
||||
char *t;
|
||||
int pchar, qflags;
|
||||
WORD_LIST *wl, *save;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((char *)NULL);
|
||||
|
||||
h2 = assoc_copy (h);
|
||||
for (i = 0; i < h2->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h2); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = pat_subst ((char *)tlist->data, pat, rep, mflags);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
wl = assoc_to_word_list (h);
|
||||
if (wl == 0)
|
||||
return (char *)NULL;
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
assoc_quote (h2);
|
||||
else
|
||||
assoc_quote_escapes (h2);
|
||||
|
||||
if (mflags & MATCH_STARSUB)
|
||||
for (save = wl; wl; wl = wl->next)
|
||||
{
|
||||
assoc_remove_quoted_nulls (h2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free (sifs);
|
||||
t = pat_subst (wl->word->word, pat, rep, mflags);
|
||||
FREE (wl->word->word);
|
||||
wl->word->word = t;
|
||||
}
|
||||
else if (mflags & MATCH_QUOTED)
|
||||
{
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0)
|
||||
{
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free(sifs);
|
||||
}
|
||||
else
|
||||
t = assoc_to_string (h2, " ", 0);
|
||||
|
||||
assoc_dispose (h2);
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
t = string_list_pos_params (pchar, save, qflags);
|
||||
dispose_words (save);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
@ -364,54 +339,29 @@ assoc_modcase (h, pat, modop, mflags)
|
|||
int modop;
|
||||
int mflags;
|
||||
{
|
||||
BUCKET_CONTENTS *tlist;
|
||||
int i, slen;
|
||||
HASH_TABLE *h2;
|
||||
char *t, *sifs, *ifs;
|
||||
char *t;
|
||||
int pchar, qflags;
|
||||
WORD_LIST *wl, *save;
|
||||
|
||||
if (h == 0 || assoc_empty (h))
|
||||
return ((char *)NULL);
|
||||
|
||||
h2 = assoc_copy (h);
|
||||
for (i = 0; i < h2->nbuckets; i++)
|
||||
for (tlist = hash_items (i, h2); tlist; tlist = tlist->next)
|
||||
{
|
||||
t = sh_modcase ((char *)tlist->data, pat, modop);
|
||||
FREE (tlist->data);
|
||||
tlist->data = t;
|
||||
}
|
||||
wl = assoc_to_word_list (h);
|
||||
if (wl == 0)
|
||||
return ((char *)NULL);
|
||||
|
||||
if (mflags & MATCH_QUOTED)
|
||||
assoc_quote (h2);
|
||||
else
|
||||
assoc_quote_escapes (h2);
|
||||
|
||||
if (mflags & MATCH_STARSUB)
|
||||
for (save = wl; wl; wl = wl->next)
|
||||
{
|
||||
assoc_remove_quoted_nulls (h2);
|
||||
sifs = ifs_firstchar ((int *)NULL);
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free (sifs);
|
||||
t = sh_modcase (wl->word->word, pat, modop);
|
||||
FREE (wl->word->word);
|
||||
wl->word->word = t;
|
||||
}
|
||||
else if (mflags & MATCH_QUOTED)
|
||||
{
|
||||
/* ${array[@]} */
|
||||
sifs = ifs_firstchar (&slen);
|
||||
ifs = getifs ();
|
||||
if (ifs == 0 || *ifs == 0)
|
||||
{
|
||||
if (slen < 2)
|
||||
sifs = xrealloc (sifs, 2);
|
||||
sifs[0] = ' ';
|
||||
sifs[1] = '\0';
|
||||
}
|
||||
t = assoc_to_string (h2, sifs, 0);
|
||||
free(sifs);
|
||||
}
|
||||
else
|
||||
t = assoc_to_string (h2, " ", 0);
|
||||
|
||||
assoc_dispose (h2);
|
||||
pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
|
||||
qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
|
||||
|
||||
t = string_list_pos_params (pchar, save, qflags);
|
||||
dispose_words (save);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
98
bashhist.c
98
bashhist.c
|
@ -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 */
|
||||
|
@ -59,6 +60,10 @@
|
|||
extern int rl_done, rl_dispatching; /* should really include readline.h */
|
||||
#endif
|
||||
|
||||
#ifndef HISTSIZE_DEFAULT
|
||||
# define HISTSIZE_DEFAULT "500"
|
||||
#endif
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
@ -140,6 +145,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 +192,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
|
||||
|
@ -209,7 +213,7 @@ bash_history_inhibit_expansion (string, i)
|
|||
char *string;
|
||||
int i;
|
||||
{
|
||||
int t;
|
||||
int t, si;
|
||||
char hx[2];
|
||||
|
||||
hx[0] = history_expansion_char;
|
||||
|
@ -232,9 +236,20 @@ bash_history_inhibit_expansion (string, i)
|
|||
return (1);
|
||||
#endif
|
||||
|
||||
si = 0;
|
||||
/* If we're supposed to be in single-quoted string, skip over the
|
||||
single-quoted part and then look at what's left. */
|
||||
if (history_quoting_state == '\'')
|
||||
{
|
||||
si = skip_to_delim (string, 0, "'", SD_NOJMP|SD_HISTEXP);
|
||||
if (string[si] == 0 || si >= i)
|
||||
return (1);
|
||||
si++;
|
||||
}
|
||||
|
||||
/* Make sure the history expansion should not be skipped by quoting or
|
||||
command/process substitution. */
|
||||
else if ((t = skip_to_histexp (string, 0, hx, SD_NOJMP|SD_HISTEXP)) > 0)
|
||||
if ((t = skip_to_histexp (string, si, hx, SD_NOJMP|SD_HISTEXP)) > 0)
|
||||
{
|
||||
/* Skip instances of history expansion appearing on the line before
|
||||
this one. */
|
||||
|
@ -267,8 +282,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;
|
||||
|
@ -305,7 +320,7 @@ load_history ()
|
|||
Note that the history file is automatically truncated to the
|
||||
size of HISTSIZE if the user does not explicitly set the size
|
||||
differently. */
|
||||
set_if_not ("HISTSIZE", "500");
|
||||
set_if_not ("HISTSIZE", HISTSIZE_DEFAULT);
|
||||
sv_histsize ("HISTSIZE");
|
||||
|
||||
set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
|
||||
|
@ -350,6 +365,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 ()
|
||||
{
|
||||
|
@ -530,7 +560,15 @@ pre_process_line (line, print_changes, addit)
|
|||
add that line to the history if ADDIT is non-zero. */
|
||||
if (!history_expansion_inhibited && history_expansion && history_expansion_p (line))
|
||||
{
|
||||
/* If we are expanding the second or later line of a multi-line
|
||||
command, decrease history_length so references to history expansions
|
||||
in these lines refer to the previous history entry and not the
|
||||
current command. */
|
||||
if (history_length > 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
|
||||
history_length--;
|
||||
expanded = history_expand (line, &history_value);
|
||||
if (history_length >= 0 && command_oriented_history && current_command_first_line_saved && current_command_line_count > 1)
|
||||
history_length++;
|
||||
|
||||
if (expanded)
|
||||
{
|
||||
|
@ -597,16 +635,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 +746,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 +757,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 +799,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 +858,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 +912,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 ();
|
||||
|
|
18
bashhist.h
18
bashhist.h
|
@ -30,6 +30,15 @@
|
|||
|
||||
#define HC_IGNBOTH (HC_IGNSPACE|HC_IGNDUPS)
|
||||
|
||||
#if defined (STRICT_POSIX)
|
||||
# undef HISTEXPAND_DEFAULT
|
||||
# define HISTEXPAND_DEFAULT 0
|
||||
#else
|
||||
# if !defined (HISTEXPAND_DEFAULT)
|
||||
# define HISTEXPAND_DEFAULT 1
|
||||
# endif /* !HISTEXPAND_DEFAULT */
|
||||
#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 +49,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 +70,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));
|
||||
|
|
|
@ -47,4 +47,8 @@
|
|||
# define setlocale(cat, loc)
|
||||
#endif
|
||||
|
||||
#if !defined (HAVE_LOCALE_H) || !defined (HAVE_LOCALECONV)
|
||||
# define locale_decpoint() '.'
|
||||
#endif
|
||||
|
||||
#endif /* !_BASHINTL_H_ */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
193
bashline.c
193
bashline.c
|
@ -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,10 +1422,11 @@ 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;
|
||||
COMPSPEC *iw_compspec;
|
||||
#endif
|
||||
|
||||
command_separator_chars = COMMAND_SEPARATORS;
|
||||
|
@ -1442,7 +1445,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 +1456,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--;
|
||||
}
|
||||
|
@ -1508,7 +1511,9 @@ attempt_shell_completion (text, start, end)
|
|||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
/* Attempt programmable completion. */
|
||||
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
|
||||
if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
|
||||
iw_compspec = progcomp_search (INITIALWORD);
|
||||
if (matches == 0 &&
|
||||
(in_command_position == 0 || text[0] == '\0' || (in_command_position && iw_compspec)) &&
|
||||
current_prompt_string == ps1_prompt)
|
||||
{
|
||||
int s, e, s1, e1, os, foundcs;
|
||||
|
@ -1562,7 +1567,7 @@ attempt_shell_completion (text, start, end)
|
|||
else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */
|
||||
foundcs = 0;
|
||||
else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */
|
||||
prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
|
||||
prog_complete_matches = programmable_completions (EMPTYCMD, text, s, e, &foundcs);
|
||||
else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start]))
|
||||
foundcs = 0; /* whitespace before command name */
|
||||
else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0)
|
||||
|
@ -1576,7 +1581,10 @@ attempt_shell_completion (text, start, end)
|
|||
{
|
||||
prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
|
||||
/* command completion if programmable completion fails */
|
||||
in_command_position = s == start && STREQ (n, text); /* XXX */
|
||||
/* If we have a completion for the initial word, we can prefer that */
|
||||
in_command_position = s == start && (iw_compspec || STREQ (n, text)); /* XXX */
|
||||
if (iw_compspec && in_command_position)
|
||||
foundcs = 0;
|
||||
}
|
||||
/* empty command name following command separator */
|
||||
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
|
||||
|
@ -1587,8 +1595,8 @@ attempt_shell_completion (text, start, end)
|
|||
}
|
||||
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
|
||||
{
|
||||
foundcs = 0; /* empty command name following assignments */
|
||||
in_command_position = was_assignment;
|
||||
foundcs = 0; /* empty command name following optional assignments */
|
||||
in_command_position += was_assignment;
|
||||
}
|
||||
else if (s == start && e == end && STREQ (n, text) && start > 0)
|
||||
{
|
||||
|
@ -1597,6 +1605,12 @@ attempt_shell_completion (text, start, end)
|
|||
}
|
||||
else
|
||||
foundcs = 0;
|
||||
|
||||
/* If we have defined a compspec for the initial (command) word, call
|
||||
it and process the results like any other programmable completion. */
|
||||
if (in_command_position && have_progcomps && foundcs == 0 && iw_compspec)
|
||||
prog_complete_matches = programmable_completions (INITIALWORD, text, s, e, &foundcs);
|
||||
|
||||
FREE (n);
|
||||
/* XXX - if we found a COMPSPEC for the command, just return whatever
|
||||
the programmable completion code returns, and disable the default
|
||||
|
@ -1639,7 +1653,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 +1817,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 +1895,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 +1923,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 +1960,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 +1991,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 +2320,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 +2338,6 @@ variable_completion_function (text, state)
|
|||
|
||||
varname = savestring (text + first_char_loc);
|
||||
|
||||
namelen = strlen (varname);
|
||||
if (varlist)
|
||||
strvec_dispose (varlist);
|
||||
|
||||
|
@ -2411,7 +2425,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 +2433,6 @@ bash_servicename_completion_function (text, state)
|
|||
if (state == 0)
|
||||
{
|
||||
FREE (sname);
|
||||
firstc = *text;
|
||||
|
||||
sname = savestring (text);
|
||||
snamelen = strlen (sname);
|
||||
|
@ -2552,7 +2565,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 +2717,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 +2747,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);
|
||||
|
@ -2967,7 +2991,7 @@ restore_tilde (val, directory_part)
|
|||
char *val, *directory_part;
|
||||
{
|
||||
int l, vl, dl2, xl;
|
||||
char *dh2, *expdir, *ret;
|
||||
char *dh2, *expdir, *ret, *v;
|
||||
|
||||
vl = strlen (val);
|
||||
|
||||
|
@ -2979,6 +3003,22 @@ restore_tilde (val, directory_part)
|
|||
|
||||
expdir = bash_tilde_expand (directory_part, 0);
|
||||
xl = strlen (expdir);
|
||||
if (*directory_part == '~' && STREQ (directory_part, expdir))
|
||||
{
|
||||
/* tilde expansion failed, so what should we return? we use what the
|
||||
user typed. */
|
||||
v = mbschr (val, '/');
|
||||
vl = STRLEN (v);
|
||||
ret = (char *)xmalloc (xl + vl + 2);
|
||||
strcpy (ret, directory_part);
|
||||
if (v && *v)
|
||||
strcpy (ret + xl, v);
|
||||
|
||||
free (dh2);
|
||||
free (expdir);
|
||||
|
||||
return ret;
|
||||
}
|
||||
free (expdir);
|
||||
|
||||
/*
|
||||
|
@ -2989,6 +3029,11 @@ restore_tilde (val, directory_part)
|
|||
l = length of remainder after tilde-prefix
|
||||
*/
|
||||
l = (vl - xl) + 1;
|
||||
if (l <= 0)
|
||||
{
|
||||
free (dh2);
|
||||
return (savestring (val)); /* XXX - just punt */
|
||||
}
|
||||
|
||||
ret = (char *)xmalloc (dl2 + 2 + l);
|
||||
strcpy (ret, dh2);
|
||||
|
@ -3138,7 +3183,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 +3260,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 +3278,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 +3503,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 +3924,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 +4125,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 +4163,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
bashline.h
10
bashline.h
|
@ -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));
|
||||
|
|
33
braces.c
33
braces.c
|
@ -1,6 +1,6 @@
|
|||
/* braces.c -- code for doing word expansion in curly braces. */
|
||||
|
||||
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2018 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
@ -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)
|
||||
|
@ -418,13 +420,13 @@ mkseq (start, end, incr, type, width)
|
|||
/* Instead of a simple nelem = prevn + 1, something like:
|
||||
nelem = (prevn / imaxabs(incr)) + 1;
|
||||
would work */
|
||||
nelem = (prevn / sh_imaxabs(incr)) + 1;
|
||||
if (nelem > INT_MAX - 2) /* Don't overflow int */
|
||||
if ((prevn / sh_imaxabs (incr)) > INT_MAX - 3) /* check int overflow */
|
||||
return ((char **)NULL);
|
||||
nelem = (prevn / sh_imaxabs(incr)) + 1;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -436,6 +438,7 @@ mkseq (start, end, incr, type, width)
|
|||
#if defined (SHELL)
|
||||
if (ISINTERRUPT)
|
||||
{
|
||||
result[i] = (char *)NULL;
|
||||
strvec_dispose (result);
|
||||
result = (char **)NULL;
|
||||
}
|
||||
|
@ -494,7 +497,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 +746,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)
|
||||
|
@ -790,7 +779,9 @@ array_concat (arr1, arr2)
|
|||
len1 = strvec_len (arr1);
|
||||
len2 = strvec_len (arr2);
|
||||
|
||||
result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *));
|
||||
result = (char **)malloc ((1 + (len1 * len2)) * sizeof (char *));
|
||||
if (result == 0)
|
||||
return (result);
|
||||
|
||||
len = 0;
|
||||
for (i = 0; i < len1; i++)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
@ -140,7 +138,7 @@ bindpwd (no_symlinks)
|
|||
int no_symlinks;
|
||||
{
|
||||
char *dirname, *pwdvar;
|
||||
int old_anm, r;
|
||||
int old_anm, r, canon_failed;
|
||||
SHELL_VAR *tvar;
|
||||
|
||||
r = sh_chkwrite (EXECUTION_SUCCESS);
|
||||
|
@ -150,6 +148,13 @@ bindpwd (no_symlinks)
|
|||
: get_working_directory ("cd");
|
||||
#undef tcwd
|
||||
|
||||
/* If canonicalization fails, reset dirname to the_current_working_directory */
|
||||
if (dirname == 0)
|
||||
{
|
||||
canon_failed = 1;
|
||||
dirname = the_current_working_directory;
|
||||
}
|
||||
|
||||
old_anm = array_needs_making;
|
||||
pwdvar = get_string_value ("PWD");
|
||||
|
||||
|
@ -165,7 +170,7 @@ bindpwd (no_symlinks)
|
|||
|
||||
if (setpwd (dirname) == EXECUTION_FAILURE)
|
||||
r = EXECUTION_FAILURE;
|
||||
if (dirname == 0 && eflag)
|
||||
if (canon_failed && eflag)
|
||||
r = EXECUTION_FAILURE;
|
||||
|
||||
if (dirname && dirname != the_current_working_directory)
|
||||
|
@ -547,7 +552,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 +571,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. */
|
||||
|
@ -583,7 +587,11 @@ change_to_directory (newdir, nolinks, xattr)
|
|||
/* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
|
||||
returns NULL (because it checks the path, it will return NULL if the
|
||||
resolved path doesn't exist), fail immediately. */
|
||||
#if defined (ENAMETOOLONG)
|
||||
if (posixly_correct && nolinks == 0 && canon_failed && (errno != ENAMETOOLONG || ndlen > PATH_MAX))
|
||||
#else
|
||||
if (posixly_correct && nolinks == 0 && canon_failed && ndlen > PATH_MAX)
|
||||
#endif
|
||||
{
|
||||
#if defined ENAMETOOLONG
|
||||
if (errno != ENOENT && errno != ENAMETOOLONG)
|
||||
|
@ -653,8 +661,9 @@ change_to_directory (newdir, nolinks, xattr)
|
|||
|
||||
/* We're not in physical mode (nolinks == 0), but we failed to change to
|
||||
the canonicalized directory name (TDIR). Try what the user passed
|
||||
verbatim. If we succeed, reinitialize the_current_working_directory. */
|
||||
if (chdir (newdir) == 0)
|
||||
verbatim. If we succeed, reinitialize the_current_working_directory.
|
||||
POSIX requires that we just fail here, so we do in posix mode. */
|
||||
if (posixly_correct == 0 && chdir (newdir) == 0)
|
||||
{
|
||||
t = resetpwd ("cd");
|
||||
if (t == 0)
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -684,7 +678,7 @@ get_job_spec (list)
|
|||
if (DIGIT (*word) && all_digits (word))
|
||||
{
|
||||
job = atoi (word);
|
||||
return (job > js.j_jobslots ? NO_JOB : job - 1);
|
||||
return ((job < 0 || job > js.j_jobslots) ? NO_JOB : job - 1);
|
||||
}
|
||||
|
||||
jflags = 0;
|
||||
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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,32 @@ 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 shift.def */
|
||||
extern int print_shift_error;
|
||||
|
||||
/* 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 */
|
||||
|
|
|
@ -23,7 +23,7 @@ $PRODUCES complete.c
|
|||
$BUILTIN complete
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION complete_builtin
|
||||
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
|
||||
$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
|
||||
Specify how arguments are to be completed by Readline.
|
||||
|
||||
For each NAME, specify how arguments are to be completed. If no options
|
||||
|
@ -38,10 +38,12 @@ Options:
|
|||
without any specific completion defined
|
||||
-E apply the completions and actions to "empty" commands --
|
||||
completion attempted on a blank line
|
||||
-I apply the completions and actions to the initial (usually the
|
||||
command) word
|
||||
|
||||
When completion is attempted, the actions are applied in the order the
|
||||
uppercase-letter options are listed above. The -D option takes
|
||||
precedence over -E.
|
||||
uppercase-letter options are listed above. If multiple options are supplied,
|
||||
the -D option takes precedence over -E, and both take precedence over -I.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless an invalid option is supplied or an error occurs.
|
||||
|
@ -79,6 +81,7 @@ struct _optflags {
|
|||
int rflag;
|
||||
int Dflag;
|
||||
int Eflag;
|
||||
int Iflag;
|
||||
};
|
||||
|
||||
static int find_compact __P((char *));
|
||||
|
@ -195,7 +198,7 @@ build_actions (list, flagp, actp, optp)
|
|||
opt_given = 0;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DE")) != -1)
|
||||
while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DEI")) != -1)
|
||||
{
|
||||
opt_given = 1;
|
||||
switch (opt)
|
||||
|
@ -307,6 +310,18 @@ build_actions (list, flagp, actp, optp)
|
|||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
case 'I':
|
||||
if (flagp)
|
||||
{
|
||||
flagp->Iflag = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sh_invalidopt ("-I");
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
case 'F':
|
||||
Farg = list_optarg;
|
||||
break;
|
||||
|
@ -355,7 +370,8 @@ complete_builtin (list)
|
|||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
opt_given = oflags.pflag = oflags.rflag = oflags.Dflag = oflags.Eflag = 0;
|
||||
opt_given = oflags.pflag = oflags.rflag = 0;
|
||||
oflags.Dflag = oflags.Eflag = oflags.Iflag = 0;
|
||||
|
||||
acts = copts = (unsigned long)0L;
|
||||
Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
|
||||
|
@ -370,8 +386,14 @@ complete_builtin (list)
|
|||
|
||||
list = loptend;
|
||||
|
||||
wl = oflags.Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL)
|
||||
: (oflags.Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0);
|
||||
if (oflags.Dflag)
|
||||
wl = make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL);
|
||||
else if (oflags.Eflag)
|
||||
wl = make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL);
|
||||
else if (oflags.Iflag)
|
||||
wl = make_word_list (make_bare_word (INITIALWORD), (WORD_LIST *)NULL);
|
||||
else
|
||||
wl = (WORD_LIST *)NULL;
|
||||
|
||||
/* -p overrides everything else */
|
||||
if (oflags.pflag || (list == 0 && opt_given == 0))
|
||||
|
@ -515,6 +537,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");
|
||||
|
||||
|
@ -562,10 +586,12 @@ print_one_completion (cmd, cs)
|
|||
/* simple arguments that don't require quoting */
|
||||
PRINTARG (cs->funcname, "-F");
|
||||
|
||||
if (STREQ (cmd, EMPTYCMD))
|
||||
printf ("-E\n");
|
||||
else if (STREQ (cmd, DEFAULTCMD))
|
||||
if (STREQ (cmd, DEFAULTCMD))
|
||||
printf ("-D\n");
|
||||
else if (STREQ (cmd, EMPTYCMD))
|
||||
printf ("-E\n");
|
||||
else if (STREQ (cmd, INITIALWORD))
|
||||
printf ("-I\n");
|
||||
else
|
||||
printf ("%s\n", cmd);
|
||||
|
||||
|
@ -589,6 +615,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,14 +626,18 @@ 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");
|
||||
}
|
||||
|
||||
if (STREQ (cmd, EMPTYCMD))
|
||||
printf ("-E\n");
|
||||
else if (STREQ (cmd, DEFAULTCMD))
|
||||
if (STREQ (cmd, DEFAULTCMD))
|
||||
printf ("-D\n");
|
||||
else if (STREQ (cmd, EMPTYCMD))
|
||||
printf ("-E\n");
|
||||
else if (STREQ (cmd, INITIALWORD))
|
||||
printf ("-I\n");
|
||||
else
|
||||
printf ("%s\n", cmd);
|
||||
}
|
||||
|
@ -675,6 +707,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 +749,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. */
|
||||
|
@ -753,7 +795,7 @@ compgen_builtin (list)
|
|||
$BUILTIN compopt
|
||||
$DEPENDS_ON PROGRAMMABLE_COMPLETION
|
||||
$FUNCTION compopt_builtin
|
||||
$SHORT_DOC compopt [-o|+o option] [-DE] [name ...]
|
||||
$SHORT_DOC compopt [-o|+o option] [-DEI] [name ...]
|
||||
Modify or display completion options.
|
||||
|
||||
Modify the completion options for each NAME, or, if no NAMEs are supplied,
|
||||
|
@ -764,6 +806,7 @@ Options:
|
|||
-o option Set completion option OPTION for each NAME
|
||||
-D Change options for the "default" command completion
|
||||
-E Change options for the "empty" command completion
|
||||
-I Change options for completion on the initial word
|
||||
|
||||
Using `+o' instead of `-o' turns off the specified option.
|
||||
|
||||
|
@ -784,15 +827,15 @@ int
|
|||
compopt_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag;
|
||||
int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag, Iflag;
|
||||
WORD_LIST *l, *wl;
|
||||
COMPSPEC *cs;
|
||||
|
||||
opts_on = opts_off = Eflag = Dflag = 0;
|
||||
opts_on = opts_off = Eflag = Dflag = Iflag = 0;
|
||||
ret = EXECUTION_SUCCESS;
|
||||
|
||||
reset_internal_getopt ();
|
||||
while ((opt = internal_getopt (list, "+o:DE")) != -1)
|
||||
while ((opt = internal_getopt (list, "+o:DEI")) != -1)
|
||||
{
|
||||
opts = (list_opttype == '-') ? &opts_on : &opts_off;
|
||||
|
||||
|
@ -813,6 +856,9 @@ compopt_builtin (list)
|
|||
case 'E':
|
||||
Eflag = 1;
|
||||
break;
|
||||
case 'I':
|
||||
Iflag = 1;
|
||||
break;
|
||||
CASE_HELPOPT;
|
||||
default:
|
||||
builtin_usage ();
|
||||
|
@ -821,8 +867,14 @@ compopt_builtin (list)
|
|||
}
|
||||
list = loptend;
|
||||
|
||||
wl = Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL)
|
||||
: (Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0);
|
||||
if (Dflag)
|
||||
wl = make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL);
|
||||
else if (Eflag)
|
||||
wl = make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL);
|
||||
else if (Iflag)
|
||||
wl = make_word_list (make_bare_word (INITIALWORD), (WORD_LIST *)NULL);
|
||||
else
|
||||
wl = (WORD_LIST *)NULL;
|
||||
|
||||
if (list == 0 && wl == 0)
|
||||
{
|
||||
|
|
|
@ -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() */
|
||||
|
@ -403,19 +440,38 @@ restart_new_var_name:
|
|||
refvar = (SHELL_VAR *)NULL;
|
||||
if (variable_context && mkglobal == 0 && ((flags_on & att_function) == 0))
|
||||
{
|
||||
char *newname;
|
||||
|
||||
/* check name for validity here? */
|
||||
var = find_variable (name);
|
||||
if (var == 0)
|
||||
newname = nameref_transform_name (name, ASS_MKLOCAL);
|
||||
else if ((flags_on & att_nameref) == 0 && (flags_off & att_nameref) == 0)
|
||||
{
|
||||
/* Ok, we're following namerefs here, so let's make sure that if
|
||||
we followed one, it was at the same context (see below for
|
||||
more details). */
|
||||
refvar = find_variable_last_nameref (name, 1);
|
||||
newname = (refvar && refvar->context != variable_context) ? name : var->name;
|
||||
refvar = (SHELL_VAR *)NULL;
|
||||
}
|
||||
else
|
||||
newname = name; /* dealing with nameref attribute */
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
/* Pass 1 as second argument to make_local_{assoc,array}_variable
|
||||
return an existing {array,assoc} variable to be flagged as an
|
||||
error below. */
|
||||
if (flags_on & att_assoc)
|
||||
var = make_local_assoc_variable (name);
|
||||
var = make_local_assoc_variable (newname, 1);
|
||||
else if ((flags_on & att_array) || making_array_special)
|
||||
var = make_local_array_variable (name, making_array_special);
|
||||
var = make_local_array_variable (newname, 1);
|
||||
else
|
||||
#endif
|
||||
if (offset == 0 && (flags_on & att_nameref))
|
||||
{
|
||||
/* First look for refvar at current scope */
|
||||
refvar = find_variable_last_nameref (name, 1);
|
||||
var = find_variable (name);
|
||||
/* VARIABLE_CONTEXT != 0, so we are attempting to create or modify
|
||||
the attributes for a local variable at the same scope. If we've
|
||||
used a reference from a previous context to resolve VAR, we
|
||||
|
@ -423,18 +479,19 @@ 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 ((flags_on & att_nameref) ? name : newname, 0); /* sets att_invisible for new vars */
|
||||
|
||||
if (var == 0)
|
||||
{
|
||||
any_failed++;
|
||||
|
@ -528,21 +585,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 +613,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)
|
||||
|
@ -579,19 +643,20 @@ restart_new_var_name:
|
|||
}
|
||||
#endif
|
||||
|
||||
/* See if we are trying to set flags or value for an existing nameref
|
||||
that points to a non-existent variable: e.g.,
|
||||
/* See if we are trying to set flags or value (or create) for an
|
||||
existing nameref that points to a non-existent variable: e.g.,
|
||||
declare -n foo=bar
|
||||
unset foo # unsets bar
|
||||
declare -i foo
|
||||
foo=4+4
|
||||
declare -p foo */
|
||||
if (var == 0 && (flags_on || flags_off || offset))
|
||||
if (var == 0 && (mkglobal || flags_on || flags_off || offset))
|
||||
{
|
||||
refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0);
|
||||
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 +702,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 +892,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 */
|
||||
{
|
||||
|
@ -885,9 +959,12 @@ restart_new_var_name:
|
|||
{
|
||||
tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring ("");
|
||||
tv = bind_variable (var->name, tvalue, 0);
|
||||
tv->attributes |= var->attributes & ~att_tempvar;
|
||||
if (tv->context > 0)
|
||||
VSETATTR (tv, att_propagate);
|
||||
if (tv)
|
||||
{
|
||||
tv->attributes |= var->attributes & ~att_tempvar;
|
||||
if (tv->context > 0)
|
||||
VSETATTR (tv, att_propagate);
|
||||
}
|
||||
free (tvalue);
|
||||
}
|
||||
VSETATTR (var, att_propagate);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
This file is echo.def, from which is created echo.c.
|
||||
It implements the builtin "echo" 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.
|
||||
|
||||
|
@ -62,6 +62,10 @@ Options:
|
|||
0 to 3 octal digits
|
||||
\xHH the eight-bit character whose value is HH (hexadecimal). HH
|
||||
can be one or two hex digits
|
||||
\uHHHH the Unicode character whose value is the hexadecimal value HHHH.
|
||||
HHHH can be one to four hex digits.
|
||||
\UHHHHHHHH the Unicode character whose value is the hexadecimal value
|
||||
HHHHHHHH. HHHHHHHH can be one to eight hex digits.
|
||||
|
||||
Exit Status:
|
||||
Returns success unless a write error occurs.
|
||||
|
@ -99,8 +103,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. */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
@ -433,11 +448,11 @@ parse_and_execute (string, from_file, flags)
|
|||
}
|
||||
else
|
||||
{
|
||||
last_result = EXECUTION_FAILURE;
|
||||
last_result = EX_BADUSAGE; /* was EXECUTION_FAILURE */
|
||||
|
||||
if (interactive_shell == 0 && this_shell_builtin &&
|
||||
(this_shell_builtin == source_builtin || this_shell_builtin == eval_builtin) &&
|
||||
last_command_exit_value == EX_BADSYNTAX && posixly_correct)
|
||||
last_command_exit_value == EX_BADSYNTAX && posixly_correct && executing_command_builtin == 0)
|
||||
{
|
||||
should_jump_to_top_level = 1;
|
||||
code = ERREXIT;
|
||||
|
@ -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
|
||||
|
|
|
@ -68,13 +68,13 @@ $END
|
|||
#endif
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "input.h"
|
||||
|
||||
/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int subshell_environment;
|
||||
extern REDIRECT *redirection_undo_list;
|
||||
extern char *exec_argv0;
|
||||
|
||||
|
@ -190,8 +190,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)
|
||||
|
@ -219,6 +222,11 @@ exec_builtin (list)
|
|||
default_tty_job_signals (); /* undo initialize_job_signals */
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
#if defined (BUFFERED_INPUT)
|
||||
if (default_buffered_input >= 0)
|
||||
sync_buffered_stream (default_buffered_input);
|
||||
#endif
|
||||
|
||||
exit_value = shell_execve (command, args, env);
|
||||
|
||||
/* We have to set this to NULL because shell_execve has called realloc()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 **));
|
||||
|
@ -423,6 +419,7 @@ fc_builtin (list)
|
|||
{
|
||||
sh_wrerror ();
|
||||
fclose (stream);
|
||||
FREE (fn);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
fclose (stream);
|
||||
|
@ -463,7 +460,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;
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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 **));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
@ -120,6 +118,7 @@ kill_builtin (list)
|
|||
if (list)
|
||||
{
|
||||
sigspec = list->word->word;
|
||||
use_sigspec:
|
||||
if (sigspec[0] == '0' && sigspec[1] == '\0')
|
||||
sig = 0;
|
||||
else
|
||||
|
@ -133,6 +132,16 @@ kill_builtin (list)
|
|||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
}
|
||||
else if (word[0] == '-' && word[1] == 's' && ISALPHA (word[2]))
|
||||
{
|
||||
sigspec = word + 2;
|
||||
goto use_sigspec;
|
||||
}
|
||||
else if (word[0] == '-' && word[1] == 'n' && ISDIGIT (word[2]))
|
||||
{
|
||||
sigspec = word + 2;
|
||||
goto use_sigspec;
|
||||
}
|
||||
else if (ISOPTION (word, '-'))
|
||||
{
|
||||
list = list->next;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) \
|
||||
{ \
|
||||
|
@ -244,6 +247,9 @@ printf_builtin (list)
|
|||
char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/
|
||||
int mbind, mblen;
|
||||
#endif
|
||||
#if defined (ARRAY_VARS)
|
||||
int arrayflags;
|
||||
#endif
|
||||
|
||||
conversion_error = 0;
|
||||
retval = EXECUTION_SUCCESS;
|
||||
|
@ -258,7 +264,8 @@ printf_builtin (list)
|
|||
case 'v':
|
||||
vname = list_optarg;
|
||||
#if defined (ARRAY_VARS)
|
||||
if (legal_identifier (vname) || valid_array_reference (vname, 0))
|
||||
arrayflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (legal_identifier (vname) || valid_array_reference (vname, arrayflags))
|
||||
#else
|
||||
if (legal_identifier (vname))
|
||||
#endif
|
||||
|
@ -293,9 +300,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 +585,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 +719,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 +963,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);
|
||||
|
@ -1192,8 +1202,10 @@ getuintmax ()
|
|||
if (*ep)
|
||||
{
|
||||
sh_invalidnum (garglist->word->word);
|
||||
#if 0
|
||||
/* Same POSIX.2 conversion error requirements as getintmax(). */
|
||||
ret = 0;
|
||||
#endif
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
|
@ -1221,8 +1233,10 @@ getfloatmax ()
|
|||
if (*ep)
|
||||
{
|
||||
sh_invalidnum (garglist->word->word);
|
||||
#if 0
|
||||
/* Same thing about POSIX.2 conversion error requirements. */
|
||||
ret = 0;
|
||||
#endif
|
||||
conversion_error = 1;
|
||||
}
|
||||
else if (errno == ERANGE)
|
||||
|
@ -1239,18 +1253,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 +1281,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 ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 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 */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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,12 @@ 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 raw, edit, nchars, silent, have_timeout, ignore_delim, fd;
|
||||
int lastsig, t_errno;
|
||||
int mb_cur_max;
|
||||
unsigned int tmsec, tmusec;
|
||||
long ival, uval;
|
||||
intmax_t intval;
|
||||
|
@ -196,6 +193,7 @@ read_builtin (list)
|
|||
TTYSTRUCT ttattrs, ttset;
|
||||
#if defined (ARRAY_VARS)
|
||||
WORD_LIST *alist;
|
||||
int vflags;
|
||||
#endif
|
||||
#if defined (READLINE)
|
||||
char *rlbuf, *itext;
|
||||
|
@ -239,10 +237,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 +290,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 +338,8 @@ 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)
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, vflags) == 0)
|
||||
#else
|
||||
if (list && legal_identifier (list->word->word) == 0)
|
||||
#endif
|
||||
|
@ -364,6 +365,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 +393,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 +497,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 +514,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 +557,7 @@ read_builtin (list)
|
|||
{
|
||||
if (rlbuf && rlbuf[rlind] == '\0')
|
||||
{
|
||||
xfree (rlbuf);
|
||||
free (rlbuf);
|
||||
rlbuf = (char *)0;
|
||||
}
|
||||
if (rlbuf == 0)
|
||||
|
@ -574,11 +587,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 +596,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 +616,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 +646,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 +685,31 @@ 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
|
||||
if (locale_utf8locale == 0 || ((c & 0x80) != 0))
|
||||
i += read_mbchar (fd, input_string, i, c, unbuffered_read);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -742,20 +773,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 +803,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 +839,7 @@ assign_vars:
|
|||
else
|
||||
VUNSETATTR (var, att_invisible);
|
||||
|
||||
xfree (input_string);
|
||||
free (input_string);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
@ -825,13 +856,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, vflags) == 0)
|
||||
#else
|
||||
if (legal_identifier (varname) == 0)
|
||||
#endif
|
||||
{
|
||||
sh_invalidid (varname);
|
||||
xfree (orig_input_string);
|
||||
free (orig_input_string);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -849,7 +880,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 +894,7 @@ assign_vars:
|
|||
FREE (t);
|
||||
if (var == 0)
|
||||
{
|
||||
xfree (orig_input_string);
|
||||
free (orig_input_string);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -873,13 +904,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, vflags) == 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 +941,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 +955,7 @@ assign_vars:
|
|||
retval = EXECUTION_FAILURE;
|
||||
|
||||
FREE (tofree);
|
||||
xfree (orig_input_string);
|
||||
free (orig_input_string);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
@ -936,10 +967,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 ? (VA_NOEXPAND|VA_ONEWORD) : 0) == 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 +1004,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 +1035,7 @@ static void
|
|||
ttyrestore (ttp)
|
||||
struct ttsave *ttp;
|
||||
{
|
||||
ttsetattr (ttp->fd, ttp->attrs);
|
||||
ttsetattr (ttp->fd, &(ttp->attrs));
|
||||
tty_modified = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
124
builtins/set.def
124
builtins/set.def
|
@ -1,7 +1,7 @@
|
|||
This file is set.def, from which is created set.c.
|
||||
It implements the "set" and "unset" builtins in Bash.
|
||||
|
||||
Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2018 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
@ -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 ...]
|
||||
|
@ -161,6 +154,8 @@ $END
|
|||
typedef int setopt_set_func_t __P((int, char *));
|
||||
typedef int setopt_get_func_t __P((char *));
|
||||
|
||||
static int find_minus_o_option __P((char *));
|
||||
|
||||
static void print_minus_o_option __P((char *, int, int));
|
||||
static void print_all_shell_variables __P((void));
|
||||
|
||||
|
@ -249,6 +244,18 @@ const struct {
|
|||
((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \
|
||||
: (*o_options[i].variable = (onoff == FLAG_ON)))
|
||||
|
||||
static int
|
||||
find_minus_o_option (name)
|
||||
char *name;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
if (STREQ (name, o_options[i].name))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
minus_o_option_value (name)
|
||||
char *name;
|
||||
|
@ -256,21 +263,17 @@ minus_o_option_value (name)
|
|||
register int i;
|
||||
int *on_or_off;
|
||||
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (STREQ (name, o_options[i].name))
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
{
|
||||
on_or_off = find_flag (o_options[i].letter);
|
||||
return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off);
|
||||
}
|
||||
else
|
||||
return (GET_BINARY_O_OPTION_VALUE (i, name));
|
||||
}
|
||||
}
|
||||
i = find_minus_o_option (name);
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
|
||||
return (-1);
|
||||
if (o_options[i].letter)
|
||||
{
|
||||
on_or_off = find_flag (o_options[i].letter);
|
||||
return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off);
|
||||
}
|
||||
else
|
||||
return (GET_BINARY_O_OPTION_VALUE (i, name));
|
||||
}
|
||||
|
||||
#define MINUS_O_FORMAT "%-15s\t%s\n"
|
||||
|
@ -330,9 +333,12 @@ char *
|
|||
get_current_options ()
|
||||
{
|
||||
char *temp;
|
||||
int i;
|
||||
int i, posixopts;
|
||||
|
||||
temp = (char *)xmalloc (1 + N_O_OPTIONS);
|
||||
posixopts = num_posix_options (); /* shopts modified by posix mode */
|
||||
/* Make the buffer big enough to hold the set -o options and the shopt
|
||||
options modified by posix mode. */
|
||||
temp = (char *)xmalloc (1 + N_O_OPTIONS + posixopts);
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
|
@ -340,7 +346,11 @@ get_current_options ()
|
|||
else
|
||||
temp[i] = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
}
|
||||
temp[i] = '\0';
|
||||
|
||||
/* Add the shell options that are modified by posix mode to the end of the
|
||||
bitmap. They will be handled in set_current_options() */
|
||||
get_posix_options (temp+i);
|
||||
temp[i+posixopts] = '\0';
|
||||
return (temp);
|
||||
}
|
||||
|
||||
|
@ -352,6 +362,7 @@ set_current_options (bitmap)
|
|||
|
||||
if (bitmap == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
{
|
||||
if (o_options[i].letter)
|
||||
|
@ -359,6 +370,9 @@ set_current_options (bitmap)
|
|||
else
|
||||
SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name);
|
||||
}
|
||||
|
||||
/* Now reset the variables changed by posix mode */
|
||||
set_posix_options (bitmap+i);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -458,32 +472,29 @@ set_minus_o_option (on_or_off, option_name)
|
|||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; o_options[i].name; i++)
|
||||
i = find_minus_o_option (option_name);
|
||||
if (i < 0)
|
||||
{
|
||||
if (STREQ (option_name, o_options[i].name))
|
||||
{
|
||||
if (o_options[i].letter == 0)
|
||||
{
|
||||
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
|
||||
{
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
sh_invalidoptname (option_name);
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
sh_invalidoptname (option_name);
|
||||
return (EX_USAGE);
|
||||
if (o_options[i].letter == 0)
|
||||
{
|
||||
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
|
||||
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
|
||||
{
|
||||
sh_invalidoptname (option_name);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -807,7 +818,7 @@ unset_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int unset_function, unset_variable, unset_array, opt, nameref, any_failed;
|
||||
int global_unset_func, global_unset_var;
|
||||
int global_unset_func, global_unset_var, vflags;
|
||||
char *name, *tname;
|
||||
|
||||
unset_function = unset_variable = unset_array = nameref = any_failed = 0;
|
||||
|
@ -844,6 +855,10 @@ unset_builtin (list)
|
|||
else if (unset_function && nameref)
|
||||
nameref = 0;
|
||||
|
||||
#if defined (ARRAY_VARS)
|
||||
vflags = assoc_expand_once ? (VA_NOEXPAND|VA_ONEWORD) : 0;
|
||||
#endif
|
||||
|
||||
while (list)
|
||||
{
|
||||
SHELL_VAR *var;
|
||||
|
@ -859,7 +874,8 @@ unset_builtin (list)
|
|||
|
||||
#if defined (ARRAY_VARS)
|
||||
unset_array = 0;
|
||||
if (!unset_function && nameref == 0 && valid_array_reference (name, 0))
|
||||
/* XXX valid array reference second arg was 0 */
|
||||
if (!unset_function && nameref == 0 && valid_array_reference (name, vflags))
|
||||
{
|
||||
t = strchr (name, '[');
|
||||
*t++ = '\0';
|
||||
|
@ -916,7 +932,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, vflags); /* 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 +954,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, vflags); /* XXX new third arg */
|
||||
free (tname);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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
|
||||
|
@ -279,6 +277,12 @@ set_or_show_attributes (list, attribute, nodefs)
|
|||
}
|
||||
|
||||
set_var_attribute (name, attribute, undo);
|
||||
if (assign) /* restore word */
|
||||
{
|
||||
name[assign] = '=';
|
||||
if (aflags & ASS_APPEND)
|
||||
name[assign-1] = '+';
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
|
@ -506,7 +510,7 @@ show_name_attributes (name, nodefs)
|
|||
var = find_variable_noref (name);
|
||||
#endif
|
||||
|
||||
if (var /* && invisible_p (var) == 0 */) /* XXX bash-4.4/bash-5.0 */
|
||||
if (var /* && invisible_p (var) == 0 */)
|
||||
{
|
||||
show_var_attributes (var, READONLY_OR_EXPORT, nodefs);
|
||||
return (0);
|
||||
|
@ -539,7 +543,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);
|
||||
|
@ -562,18 +566,23 @@ set_var_attribute (name, attribute, undo)
|
|||
var->attributes |= tv->attributes & ~att_tempvar;
|
||||
/* This avoids an error message when propagating a read-only var
|
||||
later on. */
|
||||
if (var->context == 0 && (attribute & att_readonly))
|
||||
if (posixly_correct || shell_compatibility_level <= 44)
|
||||
{
|
||||
/* Don't bother to set the `propagate to the global variables
|
||||
table' flag if we've just bound the variable in that table */
|
||||
v = find_global_variable (tv->name);
|
||||
if (v != var)
|
||||
if (var->context == 0 && (attribute & att_readonly))
|
||||
{
|
||||
/* Don't bother to set the `propagate to the global variables
|
||||
table' flag if we've just bound the variable in that
|
||||
table */
|
||||
v = find_global_variable (tv->name);
|
||||
if (v != var)
|
||||
VSETATTR (tv, att_propagate);
|
||||
}
|
||||
else
|
||||
VSETATTR (tv, att_propagate);
|
||||
if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
}
|
||||
else
|
||||
VSETATTR (tv, att_propagate);
|
||||
if (var->context != 0)
|
||||
VSETATTR (var, att_propagate);
|
||||
|
||||
SETVARATTR (tv, attribute, undo); /* XXX */
|
||||
|
||||
stupidly_hack_special_variables (tv->name);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
This file is shopt.def, from which is created shopt.c.
|
||||
It implements the Bash `shopt' builtin.
|
||||
|
||||
Copyright (C) 1994-2016 Free Software Foundation, Inc.
|
||||
Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -108,20 +110,25 @@ extern int enable_hostname_completion __P((int));
|
|||
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
extern int prog_completion_enabled;
|
||||
#endif
|
||||
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
extern char *shell_name;
|
||||
extern int progcomp_alias;
|
||||
#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 +136,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 +149,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 +162,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 +181,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 },
|
||||
|
@ -206,6 +219,8 @@ static struct {
|
|||
#if defined (HISTORY)
|
||||
{ "lithist", &literal_history, (shopt_set_func_t *)NULL },
|
||||
#endif
|
||||
{ "localvar_inherit", &localvar_inherit, (shopt_set_func_t *)NULL },
|
||||
{ "localvar_unset", &localvar_unset, (shopt_set_func_t *)NULL },
|
||||
{ "login_shell", &shopt_login_shell, set_login_shell },
|
||||
{ "mailwarn", &mail_warning, (shopt_set_func_t *)NULL },
|
||||
#if defined (READLINE)
|
||||
|
@ -216,6 +231,9 @@ static struct {
|
|||
{ "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
|
||||
#if defined (PROGRAMMABLE_COMPLETION)
|
||||
{ "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
|
||||
# if defined (ALIAS)
|
||||
{ "progcomp_alias", &progcomp_alias, (shopt_set_func_t *)NULL },
|
||||
# endif
|
||||
#endif
|
||||
{ "promptvars", &promptvars, (shopt_set_func_t *)NULL },
|
||||
#if defined (RESTRICTED_SHELL)
|
||||
|
@ -223,6 +241,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 +366,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 +601,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 +615,7 @@ shopt_enable_hostname_completion (option_name, mode)
|
|||
{
|
||||
return (enable_hostname_completion (mode));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
set_compatibility_level (option_name, mode)
|
||||
|
@ -590,6 +623,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 +632,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 +650,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 +670,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:
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -97,9 +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;
|
||||
extern int sourcelevel, running_trap;
|
||||
|
||||
int
|
||||
trap_builtin (list)
|
||||
WORD_LIST *list;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -94,13 +94,15 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
|
|||
#define W_HASQUOTEDNULL 0x040000 /* word contains a quoted null character */
|
||||
#define W_DQUOTE 0x080000 /* word should be treated as if double-quoted */
|
||||
#define W_NOPROCSUB 0x100000 /* don't perform process substitution */
|
||||
#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */
|
||||
#define W_SAWQUOTEDNULL 0x200000 /* word contained a quoted null that was removed */
|
||||
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
|
||||
#define W_ASSIGNARRAY 0x800000 /* word looks like a compound indexed array assignment */
|
||||
#define W_ARRAYIND 0x1000000 /* word is an array index being expanded */
|
||||
#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;
|
||||
|
||||
|
|
34
config-top.h
34
config-top.h
|
@ -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,17 +124,25 @@
|
|||
# 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
|
||||
|
||||
/* Define to 0 if you want the checkwinsize option off by default, 1 if you
|
||||
want it on. */
|
||||
#define CHECKWINSIZE_DEFAULT 0
|
||||
#define CHECKWINSIZE_DEFAULT 1
|
||||
|
||||
/* Define to 1 if you want to optimize for sequential array assignment when
|
||||
using indexed arrays, 0 if you want bash-4.2 behavior, which favors
|
||||
|
@ -149,7 +161,8 @@
|
|||
no longer exists. This behavior is the default in Posix mode. */
|
||||
#define CHECKHASH_DEFAULT 0
|
||||
|
||||
/* Define to the maximum level of recursion you want for the eval builtin.
|
||||
/* Define to the maximum level of recursion you want for the eval builtin
|
||||
and trap handlers (since traps are run as if run by eval).
|
||||
0 means the limit is not active. */
|
||||
#define EVALNEST_MAX 0
|
||||
|
||||
|
@ -160,3 +173,16 @@
|
|||
/* 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
|
||||
|
||||
/* Define to set the initial size of the history list ($HISTSIZE). This must
|
||||
be a string. */
|
||||
/*#define HISTSIZE_DEFAULT "500"*/
|
||||
|
||||
/* Define to 0 if you want history expansion to be disabled by default in
|
||||
interactive shells; define to 1 for the historical behavior of enabling
|
||||
when the shell is interactive. */
|
||||
#define HISTEXPAND_DEFAULT 1
|
||||
|
|
18
config.h.in
18
config.h.in
|
@ -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,12 @@
|
|||
/* Define if you have the fcntl function. */
|
||||
#undef HAVE_FCNTL
|
||||
|
||||
/* Define if you have the fnmatch function. */
|
||||
#undef HAVE_FNMATCH
|
||||
|
||||
/* Can fnmatch be used as a fallback to match [=equiv=] with collation weights? */
|
||||
#undef FNMATCH_EQUIV_FALLBACK
|
||||
|
||||
/* Define if you have the fpurge/__fpurge function. */
|
||||
#undef HAVE_FPURGE
|
||||
#undef HAVE___FPURGE
|
||||
|
@ -1021,6 +1031,9 @@
|
|||
/* Define if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
|
@ -1126,6 +1139,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. */
|
||||
|
@ -1158,6 +1173,9 @@
|
|||
/* Define if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define if you have the `mremap' function. */
|
||||
#undef HAVE_MREMAP
|
||||
|
||||
/* Define if you have the `munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
|
|
402
configure
vendored
402
configure
vendored
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
# From configure.ac for Bash 4.4, version 4.082.
|
||||
# From configure.ac for Bash 5.0, version 5.005.
|
||||
# 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-release.
|
||||
#
|
||||
# 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-release'
|
||||
PACKAGE_STRING='bash 5.0-release'
|
||||
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-release 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-release:";;
|
||||
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-release
|
||||
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-release, 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,7 +2758,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
|||
ac_config_headers="$ac_config_headers config.h"
|
||||
|
||||
|
||||
BASHVERS=4.4
|
||||
BASHVERS=5.0
|
||||
RELSTATUS=release
|
||||
|
||||
case "$RELSTATUS" in
|
||||
|
@ -2842,33 +2847,38 @@ opt_with_installed_readline=no
|
|||
#htmldir=
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
# mostly obsolete platforms
|
||||
alpha*-*) opt_bash_malloc=no ;; # alpha running osf/1 or linux
|
||||
*[Cc]ray*-*) opt_bash_malloc=no ;; # Crays
|
||||
*-osf1*) opt_bash_malloc=no ;; # other osf/1 machines
|
||||
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
|
||||
sparc-svr4*) opt_bash_malloc=no ;; # sparc SVR4, SVR4.2
|
||||
sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir
|
||||
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
|
||||
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
|
||||
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
|
||||
# These need additional investigation
|
||||
sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
||||
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-aix*) opt_bash_malloc=no ;; # AIX machines
|
||||
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
|
||||
# Mach-derived systems have a ton of extra malloc functions and lack sbrk(2)
|
||||
*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
|
||||
*-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep
|
||||
*-macos*) opt_bash_malloc=no ;; # Apple MacOS X
|
||||
*-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
|
||||
*-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
|
||||
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
|
||||
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
|
||||
# Niche or non-mainstream-shell-user systems
|
||||
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x
|
||||
*-nsk*) opt_bash_malloc=no ;; # HP NonStop
|
||||
*-haiku*) opt_bash_malloc=no ;; # Haiku OS
|
||||
# Deprecated -- bash malloc is suitable
|
||||
#sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
#mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
#*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
#*-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
esac
|
||||
|
||||
# memory scrambling on free()
|
||||
|
@ -2976,8 +2986,9 @@ opt_casemod_attrs=yes
|
|||
opt_casemod_expansions=yes
|
||||
opt_extglob_default=no
|
||||
opt_dircomplete_expand_default=no
|
||||
opt_globascii_default=no
|
||||
opt_globascii_default=yes
|
||||
opt_function_import=yes
|
||||
opt_dev_fd_stat_broken=no
|
||||
|
||||
opt_static_link=no
|
||||
opt_profiling=no
|
||||
|
@ -2998,7 +3009,7 @@ if test $opt_minimal_config = yes; then
|
|||
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
|
||||
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
|
||||
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
|
||||
opt_globascii_default=no
|
||||
opt_globascii_default=yes
|
||||
fi
|
||||
|
||||
# Check whether --enable-alias was given.
|
||||
|
@ -3061,6 +3072,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 +3342,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 +4916,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
|
||||
|
@ -4915,16 +4938,10 @@ fi
|
|||
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
|
||||
# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX
|
||||
|
||||
# turn off paren warnings in gcc
|
||||
if test "$GCC" = yes # && test -n "$DEBUG"
|
||||
then
|
||||
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
|
||||
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 +4957,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 +4969,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)'}
|
||||
|
@ -5195,6 +5216,45 @@ fi
|
|||
$as_echo "$ac_cv_lib_ncurses_tgetent" >&6; }
|
||||
if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then :
|
||||
bash_cv_termcap_lib=libncurses
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5
|
||||
$as_echo_n "checking for tgetent in -lncursesw... " >&6; }
|
||||
if ${ac_cv_lib_ncursesw_tgetent+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lncursesw $LIBS"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char tgetent ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return tgetent ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_lib_ncursesw_tgetent=yes
|
||||
else
|
||||
ac_cv_lib_ncursesw_tgetent=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5
|
||||
$as_echo "$ac_cv_lib_ncursesw_tgetent" >&6; }
|
||||
if test "x$ac_cv_lib_ncursesw_tgetent" = xyes; then :
|
||||
bash_cv_termcap_lib=libncursesw
|
||||
else
|
||||
bash_cv_termcap_lib=gnutermcap
|
||||
fi
|
||||
|
@ -5209,6 +5269,8 @@ fi
|
|||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test "X$_bash_needmsg" = "Xyes"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5
|
||||
$as_echo_n "checking which library has the termcap functions... " >&6; }
|
||||
|
@ -5268,7 +5330,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='8.0'
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
@ -5382,7 +5444,7 @@ fi
|
|||
|
||||
|
||||
case "$ac_cv_rl_version" in
|
||||
5*|6*|7*|8*|9*) ;;
|
||||
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;}
|
||||
|
@ -9270,7 +9332,7 @@ fi
|
|||
done
|
||||
|
||||
for ac_header in sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \
|
||||
sys/param.h sys/socket.h sys/stat.h \
|
||||
sys/mman.h sys/param.h sys/socket.h sys/stat.h \
|
||||
sys/time.h sys/times.h sys/types.h sys/wait.h
|
||||
do :
|
||||
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
|
@ -9804,7 +9866,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 +10327,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;
|
||||
}
|
||||
|
@ -11024,7 +11086,7 @@ fi
|
|||
rm -f conftest.mmap conftest.txt
|
||||
|
||||
for ac_func in __argz_count __argz_next __argz_stringify dcgettext mempcpy \
|
||||
munmap stpcpy strcspn
|
||||
munmap mremap stpcpy strcspn
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||
|
@ -11445,6 +11507,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 +14504,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 :
|
||||
|
@ -15118,6 +15269,67 @@ $as_echo "#define HAVE_PRINTF_A_FORMAT 1" >>confdefs.h
|
|||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fnmatch can be used to check bracket equivalence classes" >&5
|
||||
$as_echo_n "checking whether fnmatch can be used to check bracket equivalence classes... " >&6; }
|
||||
if ${bash_cv_fnmatch_equiv_fallback+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&5
|
||||
$as_echo "$as_me: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&2;}
|
||||
bash_cv_fnmatch_equiv_fallback=no
|
||||
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <fnmatch.h>
|
||||
#include <locale.h>
|
||||
|
||||
char *pattern = "[[=a=]]";
|
||||
|
||||
/* char *string = "ä"; */
|
||||
unsigned char string[4] = { '\xc3', '\xa4', '\0' };
|
||||
|
||||
int
|
||||
main (int c, char **v)
|
||||
{
|
||||
setlocale (LC_ALL, "de_DE.UTF-8");
|
||||
if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
|
||||
exit (0);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
bash_cv_fnmatch_equiv_fallback=yes
|
||||
else
|
||||
bash_cv_fnmatch_equiv_fallback=no
|
||||
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_fnmatch_equiv_fallback" >&5
|
||||
$as_echo "$bash_cv_fnmatch_equiv_fallback" >&6; }
|
||||
if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
|
||||
bash_cv_fnmatch_equiv_value=1
|
||||
else
|
||||
bash_cv_fnmatch_equiv_value=0
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define FNMATCH_EQUIV_FALLBACK $bash_cv_fnmatch_equiv_value
|
||||
_ACEOF
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if signal handlers must be reinstalled when invoked" >&5
|
||||
|
@ -15141,7 +15353,7 @@ else
|
|||
|
||||
typedef RETSIGTYPE sigfunc();
|
||||
|
||||
int nsigint;
|
||||
volatile int nsigint;
|
||||
|
||||
#ifdef HAVE_POSIX_SIGNALS
|
||||
sigfunc *
|
||||
|
@ -15201,12 +15413,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 +15426,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; }
|
||||
|
@ -15888,6 +16097,45 @@ fi
|
|||
$as_echo "$ac_cv_lib_ncurses_tgetent" >&6; }
|
||||
if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then :
|
||||
bash_cv_termcap_lib=libncurses
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5
|
||||
$as_echo_n "checking for tgetent in -lncursesw... " >&6; }
|
||||
if ${ac_cv_lib_ncursesw_tgetent+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lncursesw $LIBS"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char tgetent ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return tgetent ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_lib_ncursesw_tgetent=yes
|
||||
else
|
||||
ac_cv_lib_ncursesw_tgetent=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5
|
||||
$as_echo "$ac_cv_lib_ncursesw_tgetent" >&6; }
|
||||
if test "x$ac_cv_lib_ncursesw_tgetent" = xyes; then :
|
||||
bash_cv_termcap_lib=libncursesw
|
||||
else
|
||||
bash_cv_termcap_lib=gnutermcap
|
||||
fi
|
||||
|
@ -15902,6 +16150,8 @@ fi
|
|||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if test "X$_bash_needmsg" = "Xyes"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5
|
||||
$as_echo_n "checking which library has the termcap functions... " >&6; }
|
||||
|
@ -15976,9 +16226,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 +16313,12 @@ 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" ;;
|
||||
netbsd*|openbsd*) LOCAL_CFLAGS="-DDEV_FD_STAT_BROKEN" ;;
|
||||
*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 ;;
|
||||
|
@ -16106,6 +16356,16 @@ m88k-motorola-sysv3) LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
|
|||
mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
|
||||
esac
|
||||
|
||||
# turn off paren warnings in gcc
|
||||
if test "$GCC" = yes # && test -n "$DEBUG"
|
||||
then
|
||||
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
|
||||
# if test -n "$DEBUG"
|
||||
# then
|
||||
# CFLAGS="$CFLAGS -Werror"
|
||||
# fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Shared object configuration section. These values are generated by
|
||||
# ${srcdir}/support/shobj-conf
|
||||
|
@ -16124,6 +16384,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 +16457,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 +16968,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-release, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -16771,7 +17034,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-release
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -16922,6 +17185,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;;
|
||||
|
|
103
configure.ac
103
configure.ac
|
@ -1,11 +1,11 @@
|
|||
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
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# Copyright (C) 1987-2016 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1987-2018 Free Software Foundation, Inc.
|
||||
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
@ -21,9 +21,9 @@ 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 5.005])dnl
|
||||
|
||||
define(bashvers, 4.4)
|
||||
define(bashvers, 5.0)
|
||||
define(relstatus, release)
|
||||
|
||||
AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
|
||||
|
@ -63,33 +63,38 @@ dnl some systems should be configured without the bash malloc by default
|
|||
dnl and some need a special compiler or loader
|
||||
dnl look in the NOTES file for more
|
||||
case "${host_cpu}-${host_os}" in
|
||||
# mostly obsolete platforms
|
||||
alpha*-*) opt_bash_malloc=no ;; # alpha running osf/1 or linux
|
||||
*[[Cc]]ray*-*) opt_bash_malloc=no ;; # Crays
|
||||
*-osf1*) opt_bash_malloc=no ;; # other osf/1 machines
|
||||
*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
|
||||
sparc-svr4*) opt_bash_malloc=no ;; # sparc SVR4, SVR4.2
|
||||
sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
m68k-sysv) opt_bash_malloc=no ;; # fixes file descriptor leak in closedir
|
||||
*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
|
||||
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
|
||||
*-beos*) opt_bash_malloc=no ;; # they say it's suitable
|
||||
# These need additional investigation
|
||||
sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF
|
||||
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
*-aix*) opt_bash_malloc=no ;; # AIX machines
|
||||
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
|
||||
# Mach-derived systems have a ton of extra malloc functions and lack sbrk(2)
|
||||
*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
|
||||
*-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep
|
||||
*-macos*) opt_bash_malloc=no ;; # Apple MacOS X
|
||||
*-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
|
||||
*-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
|
||||
*-cygwin*) opt_bash_malloc=no ;; # Cygnus's CYGWIN environment
|
||||
*-opennt*|*-interix*) opt_bash_malloc=no ;; # Interix, now owned by Microsoft
|
||||
# Niche or non-mainstream-shell-user systems
|
||||
*-qnx*) opt_bash_malloc=no ;; # QNX 4.2, QNX [67].x
|
||||
*-nsk*) opt_bash_malloc=no ;; # HP NonStop
|
||||
*-haiku*) opt_bash_malloc=no ;; # Haiku OS
|
||||
# Deprecated -- bash malloc is suitable
|
||||
#sparc-netbsd*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
#mips-irix6*) opt_bash_malloc=no ;; # needs 8-byte alignment
|
||||
#*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here
|
||||
#*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree
|
||||
#*-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
#*-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment
|
||||
esac
|
||||
|
||||
# memory scrambling on free()
|
||||
|
@ -177,8 +182,9 @@ opt_casemod_attrs=yes
|
|||
opt_casemod_expansions=yes
|
||||
opt_extglob_default=no
|
||||
opt_dircomplete_expand_default=no
|
||||
opt_globascii_default=no
|
||||
opt_globascii_default=yes
|
||||
opt_function_import=yes
|
||||
opt_dev_fd_stat_broken=no
|
||||
|
||||
dnl options that affect how bash is compiled and linked
|
||||
opt_static_link=no
|
||||
|
@ -199,7 +205,7 @@ if test $opt_minimal_config = yes; then
|
|||
opt_net_redirs=no opt_progcomp=no opt_separate_help=no
|
||||
opt_multibyte=yes opt_cond_regexp=no opt_coproc=no
|
||||
opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no
|
||||
opt_globascii_default=no
|
||||
opt_globascii_default=yes
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(alias, AC_HELP_STRING([--enable-alias], [enable shell aliases]), opt_alias=$enableval)
|
||||
|
@ -214,6 +220,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 +253,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 +354,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 +450,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
|
||||
|
@ -461,18 +474,12 @@ dnl default values
|
|||
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
|
||||
# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX
|
||||
|
||||
# turn off paren warnings in gcc
|
||||
if test "$GCC" = yes # && test -n "$DEBUG"
|
||||
then
|
||||
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
|
||||
fi
|
||||
|
||||
dnl handle options that alter how bash is compiled and linked
|
||||
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 +495,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 +507,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 +549,7 @@ then
|
|||
RL_LIB_READLINE_VERSION
|
||||
|
||||
case "$ac_cv_rl_version" in
|
||||
5*|6*|7*|8*|9*) ;;
|
||||
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])
|
||||
|
@ -702,7 +713,7 @@ AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
|
|||
stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \
|
||||
regex.h syslog.h ulimit.h)
|
||||
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \
|
||||
sys/param.h sys/socket.h sys/stat.h \
|
||||
sys/mman.h sys/param.h sys/socket.h sys/stat.h \
|
||||
sys/time.h sys/times.h sys/types.h sys/wait.h)
|
||||
AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
|
||||
|
||||
|
@ -770,7 +781,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 +819,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)])
|
||||
]
|
||||
|
@ -838,7 +849,7 @@ AC_CHECK_HEADERS([argz.h errno.h fcntl.h malloc.h stdio_ext.h])
|
|||
dnl AC_FUNC_MALLOC
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify dcgettext mempcpy \
|
||||
munmap stpcpy strcspn])
|
||||
munmap mremap stpcpy strcspn])
|
||||
|
||||
INTL_DEP= INTL_INC= LIBINTL_H=
|
||||
if test "x$USE_INCLUDED_LIBINTL" = "xyes"; then
|
||||
|
@ -980,6 +991,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
|
||||
|
@ -1010,6 +1024,8 @@ fi
|
|||
|
||||
BASH_FUNC_PRINTF_A_FORMAT
|
||||
|
||||
BASH_FUNC_FNMATCH_EQUIV_FALLBACK
|
||||
|
||||
dnl presence and behavior of OS functions
|
||||
BASH_SYS_REINSTALL_SIGHANDLERS
|
||||
BASH_SYS_JOB_CONTROL_MISSING
|
||||
|
@ -1093,9 +1109,11 @@ 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" ;;
|
||||
netbsd*|openbsd*) LOCAL_CFLAGS="-DDEV_FD_STAT_BROKEN" ;;
|
||||
*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 ;;
|
||||
|
@ -1135,6 +1153,16 @@ m88k-motorola-sysv3) LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
|
|||
mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
|
||||
esac
|
||||
|
||||
# turn off paren warnings in gcc
|
||||
if test "$GCC" = yes # && test -n "$DEBUG"
|
||||
then
|
||||
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
|
||||
# if test -n "$DEBUG"
|
||||
# then
|
||||
# CFLAGS="$CFLAGS -Werror"
|
||||
# fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Shared object configuration section. These values are generated by
|
||||
# ${srcdir}/support/shobj-conf
|
||||
|
@ -1151,6 +1179,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 +1258,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
|
||||
|
|
17
copy_cmd.c
17
copy_cmd.c
|
@ -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
cross-build/qnx.cache
Normal file
66
cross-build/qnx.cache
Normal 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}
|
20
doc/FAQ
20
doc/FAQ
|
@ -1,6 +1,4 @@
|
|||
This is the Bash FAQ, version 4.14, for Bash version 4.4.
|
||||
|
||||
[THIS FAQ IS NO LONGER MAINTAINED]
|
||||
This is the Bash FAQ, version 4.15, for Bash version 5.0.
|
||||
|
||||
This document contains a set of frequently-asked questions concerning
|
||||
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
|
||||
|
@ -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?
|
||||
|
|
3505
doc/bash.0
3505
doc/bash.0
File diff suppressed because it is too large
Load diff
610
doc/bash.1
610
doc/bash.1
File diff suppressed because it is too large
Load diff
633
doc/bash.html
633
doc/bash.html
File diff suppressed because it is too large
Load diff
1754
doc/bash.info
1754
doc/bash.info
File diff suppressed because it is too large
Load diff
BIN
doc/bash.pdf
BIN
doc/bash.pdf
Binary file not shown.
15892
doc/bash.ps
15892
doc/bash.ps
File diff suppressed because it is too large
Load diff
BIN
doc/bashref.dvi
BIN
doc/bashref.dvi
Binary file not shown.
723
doc/bashref.html
723
doc/bashref.html
File diff suppressed because it is too large
Load diff
1754
doc/bashref.info
1754
doc/bashref.info
File diff suppressed because it is too large
Load diff
BIN
doc/bashref.pdf
BIN
doc/bashref.pdf
Binary file not shown.
18033
doc/bashref.ps
18033
doc/bashref.ps
File diff suppressed because it is too large
Load diff
464
doc/bashref.texi
464
doc/bashref.texi
File diff suppressed because it is too large
Load diff
1161
doc/builtins.0
1161
doc/builtins.0
File diff suppressed because it is too large
Load diff
|
@ -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,
|
||||
|
|
3778
doc/builtins.ps
3778
doc/builtins.ps
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.22.3
|
||||
%%CreationDate: Wed Aug 31 10:24:00 2016
|
||||
%%CreationDate: Wed Jan 2 09:14:38 2019
|
||||
%%DocumentNeededResources: font Times-Roman
|
||||
%%+ font Times-Bold
|
||||
%%DocumentSuppliedResources: procset grops 1.22 3
|
||||
|
|
|
@ -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 Fri Dec 7 09:49:07 EST 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 7 December 2018
|
||||
@set UPDATED-MONTH December 2018
|
||||
|
|
3
error.c
3
error.c
|
@ -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));
|
||||
|
|
80
eval.c
80
eval.c
|
@ -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
|
||||
|
@ -78,6 +69,9 @@ reader_loop ()
|
|||
|
||||
our_indirection_level = ++indirection_level;
|
||||
|
||||
if (just_one_command)
|
||||
reset_readahead_token ();
|
||||
|
||||
while (EOF_Reached == 0)
|
||||
{
|
||||
int code;
|
||||
|
@ -90,7 +84,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 +151,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 +167,11 @@ reader_loop ()
|
|||
free (ps0_string);
|
||||
}
|
||||
|
||||
current_command_number++;
|
||||
|
||||
executing = 1;
|
||||
stdin_redir = 0;
|
||||
|
||||
execute_command (current_command);
|
||||
|
||||
exec_done:
|
||||
|
@ -202,6 +197,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 +264,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 +281,6 @@ int
|
|||
parse_command ()
|
||||
{
|
||||
int r;
|
||||
char *command_to_execute;
|
||||
|
||||
need_here_doc = 0;
|
||||
run_pending_traps ();
|
||||
|
@ -249,9 +293,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 */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
examples/bash-completion/README
Normal file
7
examples/bash-completion/README
Normal 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.
|
BIN
examples/bash-completion/bash-completion-2.5.tar.xz
Normal file
BIN
examples/bash-completion/bash-completion-2.5.tar.xz
Normal file
Binary file not shown.
146
examples/functions/arrayops.bash
Normal file
146
examples/functions/arrayops.bash
Normal 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
|
|
@ -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
examples/functions/autoload.v4
Normal file
556
examples/functions/autoload.v4
Normal 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
|
184
examples/functions/autoload.v4.t
Normal file
184
examples/functions/autoload.v4.t
Normal file
|
@ -0,0 +1,184 @@
|
|||
#!/bin/bash
|
||||
|
||||
workdir=$(mktemp -d)
|
||||
|
||||
cp autoload $workdir
|
||||
|
||||
cd $workdir
|
||||
pwd
|
||||
|
||||
. ./autoload
|
||||
|
||||
funclist='ALTEST_func1 ALTEST_funcexport ALTEST_funcu'
|
||||
for funcname in $funclist; do
|
||||
cat <<EOFFUNC > $funcname
|
||||
$funcname ()
|
||||
{
|
||||
echo this is $funcname
|
||||
|
||||
}
|
||||
EOFFUNC
|
||||
|
||||
done
|
||||
|
||||
export FPATH=$workdir
|
||||
|
||||
autoload ALTEST_func1 ALTEST_funcu
|
||||
autoload -x ALTEST_funcexport
|
||||
|
||||
ok=0
|
||||
failed=0
|
||||
|
||||
for funcname in $funclist; do
|
||||
|
||||
testname="$funcname loaded"
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ $got =~ "$funcname: not found" ]]; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
|
||||
testname="$funcname is a shim"
|
||||
if [[ ! $got =~ "IS_SHIM" ]]; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
|
||||
testname="$funcname shim executed"
|
||||
$funcname > /dev/null
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ $got =~ "IS_SHIM" ]]; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
funcname=ALTEST_func1
|
||||
testname="$funcname shim reloaded"
|
||||
autoload -r $funcname
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ ! $got =~ "IS_SHIM" ]]; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
fi
|
||||
|
||||
funcname=ALTEST_funcu
|
||||
testname="$funcname shim unloaded"
|
||||
autoload -u $funcname
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ ! $got =~ "$funcname: not found" ]]; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
fi
|
||||
|
||||
testname="autoload -p"
|
||||
got=$(autoload -p | grep ALTEST)
|
||||
if [[ ! $got =~ "autoload ALTEST_func1" ]] || \
|
||||
[[ ! $got =~ "autoload ALTEST_funcexport" ]] ; then
|
||||
echo "## Failed $testname"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
fi
|
||||
|
||||
testname="autoload -s"
|
||||
echo "Executing $testname, could take a long time..."
|
||||
got=$(autoload -s | grep ALTEST)
|
||||
if [[ ! $got =~ "ALTEST_func1 not exported not executed" ]] || \
|
||||
[[ ! $got =~ "ALTEST_funcexport exported executed" ]] ; then
|
||||
echo "## Failed $testname"
|
||||
echo "## got: $got"
|
||||
((failed+=1))
|
||||
else
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
fi
|
||||
|
||||
testname="autoload -r -a $FPATH"
|
||||
autoload -r -a $FPATH
|
||||
localfailed=0
|
||||
localok=0
|
||||
for funcname in $funclist; do
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ $got =~ "$funcname: not found" ]]; then
|
||||
echo "## Failed $testname - $funcname"
|
||||
((localfailed+=1))
|
||||
else
|
||||
((localok+=1))
|
||||
if [[ ! $got =~ "IS_SHIM" ]]; then
|
||||
((localfailed+=1))
|
||||
else
|
||||
((localok+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if ((localfailed==0)); then
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
else
|
||||
((failed+=1))
|
||||
fi
|
||||
|
||||
testname="autoload -u $funclist"
|
||||
autoload -u $funclist
|
||||
localfailed=0
|
||||
localok=0
|
||||
for funcname in $funclist; do
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ ! $got =~ "$funcname: not found" ]]; then
|
||||
echo "## Failed $testname - $funcname"
|
||||
((localfailed+=1))
|
||||
else
|
||||
((localok+=1))
|
||||
fi
|
||||
done
|
||||
if ((localfailed==0)); then
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
else
|
||||
((failed+=1))
|
||||
fi
|
||||
|
||||
testname="autoload -r -f"
|
||||
autoload -r -f
|
||||
localfailed=0
|
||||
localok=0
|
||||
for funcname in $funclist; do
|
||||
got=$(type $funcname 2>&1)
|
||||
if [[ $got =~ "$funcname: not found" ]]; then
|
||||
echo "## Failed $testname - $funcname"
|
||||
((localfailed+=1))
|
||||
else
|
||||
((localok+=1))
|
||||
if [[ ! $got =~ "IS_SHIM" ]]; then
|
||||
((localfailed+=1))
|
||||
else
|
||||
((localok+=1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if ((localfailed==0)); then
|
||||
echo "ok - $testname"
|
||||
((ok+=1))
|
||||
else
|
||||
((failed+=1))
|
||||
fi
|
||||
|
||||
echo $ok passed, $failed failed
|
||||
exit $failed
|
|
@ -100,10 +100,10 @@ INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins -I${srcdir} \
|
|||
$(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CCFLAGS) $(INC) -c -o $@ $<
|
||||
|
||||
|
||||
ALLPROG = print truefalse sleep finfo logname basename dirname \
|
||||
ALLPROG = print truefalse sleep finfo logname basename dirname fdflags \
|
||||
tty pathchk tee head mkdir rmdir printenv id whoami \
|
||||
uname sync push ln unlink realpath strftime mypid setpgid
|
||||
OTHERPROG = necho hello cat pushd
|
||||
uname sync push ln unlink realpath strftime mypid setpgid seq
|
||||
OTHERPROG = necho hello cat pushd stat rm
|
||||
|
||||
all: $(SHOBJ_STATUS)
|
||||
|
||||
|
@ -142,6 +142,15 @@ finfo: finfo.o
|
|||
cat: cat.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ cat.o $(SHOBJ_LIBS)
|
||||
|
||||
rm: rm.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ rm.o $(SHOBJ_LIBS)
|
||||
|
||||
fdflags: fdflags.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ fdflags.o $(SHOBJ_LIBS)
|
||||
|
||||
seq: seq.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ seq.o $(SHOBJ_LIBS)
|
||||
|
||||
logname: logname.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ logname.o $(SHOBJ_LIBS)
|
||||
|
||||
|
@ -202,10 +211,12 @@ strftime: strftime.o
|
|||
mypid: mypid.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ mypid.o $(SHOBJ_LIBS)
|
||||
|
||||
|
||||
setpgid: setpgid.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ setpgid.o $(SHOBJ_LIBS)
|
||||
|
||||
stat: stat.o
|
||||
$(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ stat.o $(SHOBJ_LIBS)
|
||||
|
||||
# pushd is a special case. We use the same source that the builtin version
|
||||
# uses, with special compilation options.
|
||||
#
|
||||
|
@ -236,6 +247,7 @@ installdirs:
|
|||
|
||||
install-dev: installdirs
|
||||
@$(INSTALL_DATA) Makefile.inc $(DESTDIR)$(loadablesdir)/Makefile.inc
|
||||
@$(INSTALL_DATA) $(srcdir)/loadables.h $(DESTDIR)$(loadablesdir)/loadables.h
|
||||
@( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" install-headers)
|
||||
|
||||
install-supported: all installdirs install-dev
|
||||
|
@ -246,7 +258,7 @@ install-supported: all installdirs install-dev
|
|||
done
|
||||
|
||||
uninstall-dev:
|
||||
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc
|
||||
-$(RM) $(DESTDIR)$(loadablesdir)/Makefile.inc $(DESTDIR)$(loadablesdir)/loadables.h
|
||||
-( cd $(BUILD_DIR) && ${MAKE} ${MFLAGS} DESTDIR="$(DESTDIR)" uninstall-headers)
|
||||
|
||||
uninstall-supported: uninstall-dev
|
||||
|
@ -283,3 +295,6 @@ mkdir.o: mkdir.c
|
|||
realpath.o: realpath.c
|
||||
strftime.o: strftime.c
|
||||
setpgid.o: setpgid.c
|
||||
stat.o: stat.c
|
||||
fdflags.o: fdflags.c
|
||||
seq.o: seq.c
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue