commit bash-20190301 snapshot

This commit is contained in:
Chet Ramey
2019-03-04 10:48:32 -05:00
parent e230f9979d
commit 97021559ab
9 changed files with 73 additions and 12 deletions
+11
View File
@@ -5420,3 +5420,14 @@ subst.c
quoted null as the expansion of "$@", note that we saw it, but still
add a quoted null into the result string instead of short-circuiting.
Part of fix for bug report from Grisha Levit <grishalevit@gmail.com>
3/1
---
examples/loadables/fdflags.c
- O_CLOEXEC: instead of not using it, synthesize a definition for it
from unused bits in the file status word. It's only used as a
placeholder anyway. Fix from code by Robert Elz <kre@bmunnari.oz.au>
execute_cmd.c
- execute_connection: call optimize_fork on the rhs of a `;' connection
to attempt to optimize the last simple command in a list
+1 -1
View File
@@ -20,7 +20,7 @@
isnum2()
{
case "$1" in
'[-+]' | '') return 1;; # empty or bare `-' or `+'
[-+] | '') return 1;; # empty or bare `-' or `+'
[-+]*[!0-9]*) return 1;; # non-digit with leading sign
[-+]*) return 0;; # OK
*[!0-9]*) return 1;; # non-digit
+1 -1
View File
@@ -1,6 +1,6 @@
shcat()
{
while read -r line
while IFS= read -r line
do
echo "$line"
done
+2 -2
View File
@@ -1,8 +1,8 @@
shcat()
{
while read -r line
while read -r
do
echo "$line"
echo "$REPLY"
done
}
+38 -6
View File
@@ -32,6 +32,10 @@
#include "loadables.h"
#ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
#endif
static const struct
{
const char *name;
@@ -40,37 +44,69 @@ static const struct
{
#ifdef O_APPEND
{ "append", O_APPEND },
#else
# define O_APPEND 0
#endif
#ifdef O_ASYNC
{ "async", O_ASYNC },
#else
# define O_ASYNC 0
#endif
#ifdef O_SYNC
{ "sync", O_SYNC },
#else
# define O_SYNC 0
#endif
#ifdef O_NONBLOCK
{ "nonblock", O_NONBLOCK },
#else
# define O_NONBLOCK 0
#endif
#ifdef O_FSYNC
{ "fsync", O_FSYNC },
#else
# define O_FSYNC 0
#endif
#ifdef O_DSYNC
{ "dsync", O_DSYNC },
#else
# define O_DSYNC 0
#endif
#ifdef O_RSYNC
{ "rsync", O_RSYNC },
#else
# define O_RSYNC 0
#endif
#ifdef O_ALT_IO
{ "altio", O_ALT_IO },
#else
# define O_ALT_IO 0
#endif
#ifdef O_DIRECT
{ "direct", O_DIRECT },
#else
# define O_DIRECT 0
#endif
#ifdef O_NOATIME
{ "noatime", O_NOATIME },
#else
# define O_NOATIME 0
#endif
#ifdef O_NOSIGPIPE
{ "nosigpipe", O_NOSIGPIPE },
#else
# define O_NOSIGPIPE 0
#endif
#ifndef O_CLOEXEC
# define ALLFLAGS (O_APPEND|O_ASYNC|O_SYNC|O_NONBLOCK|O_FSYNC|O_DSYNC|\
O_RSYNC|O_ALT_IO|O_DIRECT|O_NOATIME|O_NOSIGPIPE)
/* An unsed bit in the file status flags word we can use to pass around the
state of close-on-exec. */
# define O_CLOEXEC ((~ALLFLAGS) ^ ((~ALLFLAGS) & ((~ALLFLAGS) - 1)))
#endif
#ifdef O_CLOEXEC
{ "cloexec", O_CLOEXEC },
#endif
@@ -113,10 +149,8 @@ getflags(int fd, int p)
return -1;
}
#ifdef O_CLOEXEC
if (c)
f |= O_CLOEXEC;
#endif
return f & getallflags();
}
@@ -201,20 +235,18 @@ setone(int fd, char *v, int verbose)
parseflags(v, &pos, &neg);
cloexec = -1;
#ifdef O_CLOEXEC
if ((pos & O_CLOEXEC) && (f & O_CLOEXEC) == 0)
cloexec = FD_CLOEXEC;
if ((neg & O_CLOEXEC) && (f & O_CLOEXEC))
cloexec = 0;
#endif
if (cloexec != -1 && fcntl(fd, F_SETFD, cloexec) == -1)
builtin_error("can't set status for fd %d: %s", fd, strerror(errno));
#ifdef O_CLOEXEC
pos &= ~O_CLOEXEC;
neg &= ~O_CLOEXEC;
f &= ~O_CLOEXEC;
#endif
n = f;
n |= pos;
+1 -1
View File
@@ -2699,6 +2699,7 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
QUIT;
execute_command (command->value.Connection->first);
QUIT;
optimize_fork (command); /* XXX */
exec_result = execute_command_internal (command->value.Connection->second,
asynchronous, pipe_in, pipe_out,
fds_to_close);
@@ -4506,7 +4507,6 @@ run_builtin:
if (builtin_is_special)
special_builtin_failed = 1; /* XXX - take command builtin into account? */
}
/* In POSIX mode, if there are assignment statements preceding
a special builtin, they persist after the builtin
completes. */
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR
+6
View File
@@ -174,3 +174,9 @@ argv[1] = <ab >
4
4
3
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
argv[1] = <^?>
+12
View File
@@ -74,3 +74,15 @@ set -- '' ''
n ${x+"$@" "$@"}
n "$@" "$@"
n "$@""$@"
# new tests
unset -v x
v=$'\177'
recho ''$'\177'''
recho $'\177'''
recho ''$'\177'
recho ''$v''
recho ''$v
recho $v''