]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190301 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 4 Mar 2019 15:48:32 +0000 (10:48 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 4 Mar 2019 15:48:32 +0000 (10:48 -0500)
CWRU/CWRU.chlog
examples/functions/isnum2
examples/functions/shcat
examples/functions/shcat2
examples/loadables/fdflags.c
execute_cmd.c
tests/RUN-ONE-TEST
tests/quote.right
tests/quote4.sub

index bb9ccb50c7eecc8de93494226415d3bd95ae7e04..57f1c618013708387f535443119eb687e327e3ca 100644 (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
index 583e37491927bff0d102499a2aae97ad5ba43b61..b21974db4b0782c5b50565505e64878cfa57bcaa 100644 (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
index c5d3d630b08fcaa4326212b2ba51045be9329d52..84f0391eeab1cc36f656a3655de0c22dd2c27dc1 100644 (file)
@@ -1,6 +1,6 @@
 shcat()
 {
-       while read -r line
+       while IFS= read -r line
        do
                echo "$line"
        done
index 6fe90f4090d844e7311b70d6690fc104ba652418..8ceff330b9e53d1921c1ff0b58bbddb45230c6e7 100644 (file)
@@ -1,8 +1,8 @@
 shcat()
 {
-       while read -r line
+       while read -r
        do
-               echo "$line"
+               echo "$REPLY"
        done
 }
 
index 742ade422a523998a618bcf9037e6560b4711df5..fbe52304c96463400476997230e14a111ad365cb 100644 (file)
 
 #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;
index 908b88ee8da3dd9e32ee5943db724c6b5bffebc1..e4a05e2eda62dec1a3aa154e9fed849d3a01c1d7 100644 (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. */
index 554f3d6ecc09d7149b13daa2d36a6bab1480269f..58c375b70d886bcff86f789ae4a15eee397f87c8 100755 (executable)
@@ -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
 
index 9fda46a72598684ccd45dd70863380456333159c..303e685dc345bf3f4fc7801e979021a03386b121 100644 (file)
@@ -174,3 +174,9 @@ argv[1] = <ab >
 4
 4
 3
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
+argv[1] = <^?>
index 2805b8f8a5735cce8075559d2d396b45bd190b90..fa24457c9ee869b731a0b5057d848c120055179f 100644 (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''