summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2017-05-31 15:53:02 -0400
committerChet Ramey <chet.ramey@case.edu>2017-05-31 15:53:02 -0400
commit1110e30870a8782425067a060d89cc411b014418 (patch)
treef1f23c2c5d37d7682666ec980acb480dbc1867de
parent8b6b8f6094f95c4282c84924d12ec411a64a1ca7 (diff)
downloadbash-1110e30870a8782425067a060d89cc411b014418.tar.gz
commit bash-snap-20170531 snapshot
-rw-r--r--CWRU/CWRU.chlog16
-rw-r--r--builtins/read.def9
-rw-r--r--doc/FAQ6
-rw-r--r--doc/bash.14
-rw-r--r--doc/bashref.texi2
-rw-r--r--lib/readline/doc/rluser.texi2
-rw-r--r--tests/shopt.right3
-rw-r--r--variables.c9
8 files changed, 40 insertions, 11 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog
index 194927b..bc1155b 100644
--- a/CWRU/CWRU.chlog
+++ b/CWRU/CWRU.chlog
@@ -13984,3 +13984,19 @@ lib/readline/histfile.c
- read_history_range: if the file isn't a regular file, return an
error. Bug report from Eduardo Bustamante <dualbus@gmail.com>,
relaying from IRC
+
+ 5/30
+ ----
+variables.c
+ - set_pwd: if in Posix mode, and PWD appears in initial environment as
+ an absolute pathname to the current directory, set PWD to the result
+ of canonicalizing the environment value, or to the physical path if
+ canonicalization fails. From a suggestion by Eduardo Bustamante
+ <dualbus@gmail.com>
+
+ 5/31
+ ----
+builtins/read.def
+ - read_builtin: if -n or -N option is supplied with a 0 argument,
+ don't attempt to read any characters; bail out right away. Reported
+ by Eduardo Bustamante <dualbus@gmail.com>, relaying from IRC
diff --git a/builtins/read.def b/builtins/read.def
index 9f64406..520a2b3 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -176,7 +176,7 @@ 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;
@@ -239,7 +239,7 @@ read_builtin (list)
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)
@@ -288,6 +288,7 @@ read_builtin (list)
ignore_delim = 1;
delim = -1;
case 'n':
+ nflag = 1;
code = legal_number (list_optarg, &intval);
if (code == 0 || intval < 0 || intval != (int)intval)
{
@@ -361,6 +362,10 @@ 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)
+ 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")))
{
diff --git a/doc/FAQ b/doc/FAQ
index 886eec0..e330270 100644
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -960,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.
@@ -2279,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
@@ -2396,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?
diff --git a/doc/bash.1 b/doc/bash.1
index da12a5f..4f42e6d 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -8292,7 +8292,7 @@ echoed and executed.
.sp 1
In the second form, \fIcommand\fP is re-executed after each instance
of \fIpat\fP is replaced by \fIrep\fP.
-\fICommand\fP is intepreted the same as \fIfirst\fP above.
+\fICommand\fP is interpreted the same as \fIfirst\fP above.
A useful alias to use with this is
.if n ``r="fc -s"'',
.if t \f(CWr='fc \-s'\fP,
@@ -10606,7 +10606,7 @@ If the \fB\-n\fP option is supplied, \fBwait\fP waits for any job to
terminate and returns its exit status.
If the \fB\-f\fP option is supplied, and job control is enabled,
\fBwait\fP forces \fIid\fP to terminate before returning its status,
-intead of returning when it changes status.
+instead of returning when it changes status.
If
.I id
specifies a non-existent process or job, the return status is
diff --git a/doc/bashref.texi b/doc/bashref.texi
index 1025981..9839801 100644
--- a/doc/bashref.texi
+++ b/doc/bashref.texi
@@ -1319,7 +1319,7 @@ will ensure that the output of @code{traceroute foss.org.my} is displayed first.
Finally, Parallel can be used to run a sequence of shell commands in parallel,
similar to @samp{cat file | bash}.
It is not uncommon to take a list of filenames, create a series of shell
-commands to operate on them, and feed that list of commnds to a shell.
+commands to operate on them, and feed that list of commands to a shell.
Parallel can speed this up. Assuming that @file{file} contains a list of
shell commands, one per line,
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index d0a87d1..22bbd1e 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -2214,7 +2214,7 @@ a shell function and bind it to a particular command using @code{complete -F}.
The following function provides completions for the @code{cd} builtin.
It is a reasonably good example of what shell functions must do when
-used for completion. This function uses the word passsed as @code{$2}
+used for completion. This function uses the word passed as @code{$2}
to determine the directory name to complete. You can also use the
@code{COMP_WORDS} array variable; the current word is indexed by the
@code{COMP_CWORD} variable.
diff --git a/tests/shopt.right b/tests/shopt.right
index 91fb073..cec6c2a 100644
--- a/tests/shopt.right
+++ b/tests/shopt.right
@@ -38,6 +38,7 @@ shopt -u inherit_errexit
shopt -s interactive_comments
shopt -u lastpipe
shopt -u lithist
+shopt -u localvar_inherit
shopt -u login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
@@ -96,6 +97,7 @@ shopt -u huponexit
shopt -u inherit_errexit
shopt -u lastpipe
shopt -u lithist
+shopt -u localvar_inherit
shopt -u login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
@@ -135,6 +137,7 @@ huponexit off
inherit_errexit off
lastpipe off
lithist off
+localvar_inherit off
login_shell off
mailwarn off
no_empty_cmd_completion off
diff --git a/variables.c b/variables.c
index b53e1b3..02ab5f5 100644
--- a/variables.c
+++ b/variables.c
@@ -122,7 +122,7 @@ int variable_context = 0;
/* If non-zero, local variables inherit values and attributes from a variable
with the same name at a previous scope. */
-int localvar_inherit = 1;
+int localvar_inherit = 0;
/* The set of shell assignments which are made only in the environment
for a single command. */
@@ -854,8 +854,13 @@ set_pwd ()
current_dir = sh_canonpath (temp_string, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
if (current_dir == 0)
current_dir = get_working_directory ("shell_init");
- else
+ else
set_working_directory (current_dir);
+ if (posixly_correct && current_dir)
+ {
+ temp_var = bind_variable ("PWD", current_dir, 0);
+ set_auto_export (temp_var);
+ }
free (current_dir);
}
else if (home_string && interactive_shell && login_shell &&