]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
changes to several error messages; more test suite additions
authorChet Ramey <chet.ramey@case.edu>
Wed, 4 Oct 2023 19:04:31 +0000 (15:04 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 4 Oct 2023 19:04:31 +0000 (15:04 -0400)
95 files changed:
CWRU/CWRU.chlog
MANIFEST
builtins/alias.def
builtins/exec.def
builtins/history.def
builtins/pushd.def
builtins/read.def
builtins/type.def
builtins/ulimit.def
general.c
subst.c
subst.h
tests/alias.right
tests/alias4.sub
tests/array.right
tests/array.tests
tests/array33.sub
tests/assoc.right
tests/assoc.tests
tests/builtins.right
tests/builtins.tests
tests/builtins1.sub
tests/builtins10.sub
tests/builtins11.sub [new file with mode: 0644]
tests/builtins12.sub [new file with mode: 0644]
tests/builtins2.sub
tests/builtins8.sub
tests/case.right
tests/case.tests
tests/casemod.right
tests/casemod.tests
tests/complete.right
tests/complete.tests
tests/comsub2.right
tests/comsub23.sub
tests/cond-error1.sub
tests/cond.right
tests/cond.tests
tests/dbg-support.right
tests/dbg-support.tests
tests/errors.right
tests/errors.tests
tests/exec.right
tests/execscript
tests/func.right
tests/func.tests
tests/func5.sub
tests/history.right
tests/history.tests
tests/history3.sub
tests/history5.sub
tests/invocation.right
tests/invocation.tests
tests/invocation3.sub [new file with mode: 0644]
tests/jobs.right
tests/jobs.tests
tests/jobs9.sub [new file with mode: 0644]
tests/lastpipe.tests
tests/nameref.right
tests/nameref23.sub
tests/new-exp.right
tests/new-exp10.sub
tests/printf.right
tests/printf.tests
tests/printf1.sub
tests/printf6.sub [new file with mode: 0644]
tests/read.right
tests/read2.sub
tests/read3.sub
tests/redir.right
tests/redir.tests
tests/redir12.sub
tests/redir13.in [new file with mode: 0644]
tests/rsh.right
tests/rsh.tests
tests/run-set-x
tests/set-x.right
tests/set-x.tests
tests/set-x1.sub
tests/set-x2.sub [new file with mode: 0644]
tests/tilde.right
tests/tilde.tests
tests/time.tests
tests/trap.right
tests/trap.tests
tests/type.right
tests/type5.sub
tests/varenv.right
tests/varenv14.sub
tests/varenv21.sub
tests/vredir.right
tests/vredir.tests
tests/vredir1.sub
tests/vredir4.sub
tests/vredir7.sub

index 7c204a1abcde979fc88543c56d7fae83bb21abb7..63145c3dcd96887461a1b62dacd1cc2e6204c057 100644 (file)
@@ -7693,3 +7693,15 @@ builtins/shift.def
 
 builtins/break.def
        - break_builtin,continue_builtin: ditto with get_numeric_arg and `--'
+
+                                  9/28
+                                  ----
+builtins/history.def
+       - history_builtin: changed error message if the numeric argument to -d
+         is invalid
+
+                                  9/29
+                                  ----
+subst.c
+       - array_length_reference: include the open bracket in the error message
+         passed to err_badarraysub; it looks cleaner
index 16eac82ffe96aa73c7252bf12d868990a02958ac..aa96a0696ee47b31d687499f61570e2dd2dbd13a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1026,6 +1026,7 @@ tests/builtins7.sub       f
 tests/builtins8.sub    f
 tests/builtins9.sub    f
 tests/builtins10.sub   f
+tests/builtins11.sub   f
 tests/source1.sub      f
 tests/source2.sub      f
 tests/source3.sub      f
@@ -1281,6 +1282,8 @@ tests/intl.right  f
 tests/invocation.tests f
 tests/invocation.right f
 tests/invocation1.sub  f
+tests/invocation2.sub  f
+tests/invocation3.sub  f
 tests/iquote.tests     f
 tests/iquote.right     f
 tests/iquote1.sub      f
@@ -1295,6 +1298,7 @@ tests/jobs5.sub           f
 tests/jobs6.sub                f
 tests/jobs7.sub                f
 tests/jobs8.sub                f
+tests/jobs9.sub                f
 tests/jobs.right       f
 tests/lastpipe.right   f
 tests/lastpipe.tests   f
@@ -1444,6 +1448,8 @@ tests/redir8.sub  f
 tests/redir9.sub       f
 tests/redir10.sub      f
 tests/redir11.sub      f
+tests/redir12.sub      f
+tests/redir13.in       f
 tests/rhs-exp.tests    f
 tests/rhs-exp.right    f
 tests/rhs-exp1.sub     f
@@ -1547,6 +1553,7 @@ tests/set-e3a.sub f
 tests/set-e.right      f
 tests/set-x.tests      f
 tests/set-x1.sub       f
+tests/set-x2.sub       f
 tests/set-x.right      f
 tests/shopt.tests      f
 tests/shopt1.sub       f
index b75262c52dc0ef431780e932c1f50e25c6aa5905..6ff4a7df8677ce9395aa8b873afeaa1ff8becccc 100644 (file)
@@ -208,11 +208,7 @@ unalias_builtin (WORD_LIST *list)
   aflag = 0;
   while (list)
     {
-      alias = find_alias (list->word->word);
-
-      if (alias)
-       remove_alias (alias->name);
-      else
+      if (remove_alias (list->word->word) < 0)
        {
          sh_notfound (list->word->word);
          aflag++;
index 54dc6645903c1b9cd550e7329a3b91ed0ac26de5..fc7bc67254462a5c8cf5e7bffdbd7bd51dda5182 100644 (file)
@@ -98,12 +98,13 @@ mkdashname (char *name)
 int
 exec_builtin (WORD_LIST *list)
 {
-  int exit_value = EXECUTION_FAILURE;
+  int exit_value;
   int cleanenv, login, opt, orig_job_control;
   char *argv0, *command, **args, **env, *newname, *com2;
 
   cleanenv = login = orig_job_control = 0;
   exec_argv0 = argv0 = (char *)NULL;
+  exit_value = EXECUTION_FAILURE;
 
   reset_internal_getopt ();
   while ((opt = internal_getopt (list, "cla:")) != -1)
@@ -227,6 +228,7 @@ exec_builtin (WORD_LIST *list)
     sync_buffered_stream (default_buffered_input);
 
   exit_value = shell_execve (command, args, env);
+  opt = errno;
 
   /* We have to set this to NULL because shell_execve has called realloc()
      to stuff more items at the front of the array, which may have caused
@@ -239,6 +241,7 @@ exec_builtin (WORD_LIST *list)
     goto failed_exec;
   else if (executable_file (command) == 0)
     {
+      errno = opt;
       builtin_error (_("%s: cannot execute: %s"), command, strerror (errno));
       exit_value = EX_NOEXEC;  /* As per Posix.2, 3.14.6 */
     }
index 2b0dfdd4443ad2510b99f6b5e28a51e746510637..7c0013bdd898007648228601ad5d9c0a18937e3e 100644 (file)
@@ -226,7 +226,7 @@ history_builtin (WORD_LIST *list)
     {
       if (legal_number (delete_arg, &delete_offset) == 0)
        {
-         sh_erange (delete_arg, _("history position"));
+         sh_invalidnum (delete_arg);
          return (EXECUTION_FAILURE);
        }
       /* check for negative offsets, count back from end of list */
index cc9e5d62989219f2704d491af435b7932496feab..b328c82516711d7018ec48c543a28a59cf8f7c9b 100644 (file)
@@ -363,6 +363,30 @@ popd_builtin (WORD_LIST *list)
        break;
     }
 
+#if 0
+  /* If we didn't find `which' but there are arguments remaining, assume we
+     got `--' */
+  if (which_word == 0 && list)
+    {
+      if (((direction = list->word->word[0]) == '+') || direction == '-')
+       {
+         if (legal_number (list->word->word + 1, &which) == 0)
+           {
+             sh_invalidnum (list->word->word);
+             builtin_usage ();
+             return (EX_USAGE);
+           }
+         which_word = list->word->word;
+       }
+      else
+       {
+         builtin_error (_("%s: invalid argument"), list->word->word);
+         builtin_usage ();
+         return (EX_USAGE);
+       }
+    }
+#endif
+
   if (which > directory_list_offset || (which < -directory_list_offset) || (directory_list_offset == 0 && which == 0))
     {
       pushd_error (directory_list_offset, which_word ? which_word : "");
index 8496fe47499dcecc7130556c57605707e00b076b..981f5a2f1b092d3484c7e729c914e00fac268261 100644 (file)
@@ -459,7 +459,7 @@ read_builtin (WORD_LIST *list)
 #endif
   if (input_is_tty == 0)
 #ifndef __CYGWIN__
-    input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE);
+    input_is_pipe = fd_ispipe (fd);
 #else
     input_is_pipe = 1;
 #endif
index ad67a938d338a17bc0ef308b7fe8674cf79528c8..a0d31929883a8d206a14f6bcf1775dc60926df52 100644 (file)
@@ -367,6 +367,7 @@ describe_command (char *command, int dflags)
         probably doesn't exist.  Check whether or not the command is an
         executable file.  If it's not, don't report a match.  This is
         the default posix mode behavior */
+      /* This code path isn't executed any more as of 3/2023. */
       if (STREQ (full_path, command) || posixly_correct)
        {
          f = file_status (full_path);
index 11c55c91b4206196081fee0c534d470474fd3981..fa527ad788de4ecda4ec86d8c3b83c20a2509726 100644 (file)
@@ -746,6 +746,7 @@ printone (int limind, RLIMTYPE curlim, int pdesc)
     print_rlimtype ((curlim / factor), 1);
 }
 
+#ifdef NOTYET
 /* Set all limits to NEWLIM.  NEWLIM currently must be RLIM_INFINITY, which
    causes all limits to be set as high as possible depending on mode (like
    csh `unlimit').  Returns -1 if NEWLIM is invalid, 0 if all limits
@@ -783,5 +784,6 @@ set_all_limits (int mode, RLIMTYPE newlim)
       }
   return retval;
 }
+#endif /* NOTYET */
 
 #endif /* !_MINIX */
index 0ca51b7d1104781567f06d3c9902cef5e7363fb0..aa96566109f53ad0d8d0ff5f3b6f4091de3f95bb 100644 (file)
--- a/general.c
+++ b/general.c
@@ -177,6 +177,8 @@ string_to_rlimtype (char *s)
 
   ret = 0;
   neg = 0;
+  /* ulimit_builtin doesn't allow leading whitespace or an optional
+     leading `+' or `-'. */
   while (s && *s && whitespace (*s))
     s++;
   if (s && (*s == '-' || *s == '+'))
diff --git a/subst.c b/subst.c
index 9f4c4e54c7796561b9d09eee743c859b60b583ab..52ab5a9f7e518c1de984b3c7e74c7454be57c0a1 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3449,7 +3449,7 @@ do_compound_assignment (const char *name, char *value, int flags)
        v = make_local_assoc_variable (newname, 0);
       else if (v == 0 || (array_p (v) == 0 && assoc_p (v) == 0) || v->context != variable_context)
         v = make_local_array_variable (newname, 0);
-      r = v? assign_compound_array_list (v, list, flags) : 0;
+      r = v ? assign_compound_array_list (v, list, flags) : 0;
       if (list)
        dispose_words (list);
       if (r == 0)              /* compound assignment error */
@@ -7416,11 +7416,14 @@ array_length_reference (const char *s)
   if (assoc_p (var))
     {
       t[len - 1] = '\0';
-      akey = expand_subscript_string (t, 0);   /* [ */
+      akey = expand_subscript_string (t, 0);
       t[len - 1] = RBRACK;
       if (akey == 0 || *akey == 0)
        {
-         err_badarraysub (t);
+         char *t1;
+
+         t1 = (t > s) ? t - 1 : t;             /* get the left bracket */
+         err_badarraysub (t1);
          FREE (akey);
          return (-1);
        }
@@ -7435,7 +7438,10 @@ array_length_reference (const char *s)
        ind = array_max_index (array_cell (var)) + 1 + ind;
       if (ind < 0)
        {
-         err_badarraysub (t);
+         char *t1;
+
+         t1 = (t > s) ? t - 1 : t;             /* get the left bracket */
+         err_badarraysub (t1);
          return (-1);
        }
       if (array_p (var))
diff --git a/subst.h b/subst.h
index 4ac602fb605cbafad736d8e69bde053ebc8bdbaa..c83bf5a203c5e5ffdac220ab1bcf619b7a36002a 100644 (file)
--- a/subst.h
+++ b/subst.h
@@ -44,7 +44,7 @@
 #define Q_ARRAYSUB      0x200  /* expanding indexed array subscript */
 
 /* Flag values controlling how assignment statements are treated. */
-#define ASS_APPEND     0x0001
+#define ASS_APPEND     0x0001  /* a+=b */
 #define ASS_MKLOCAL    0x0002
 #define ASS_MKASSOC    0x0004
 #define ASS_MKGLOBAL   0x0008  /* force global assignment */
@@ -58,6 +58,7 @@
 #define ASS_ALLOWALLSUB        0x0800  /* allow * and @ as associative array keys */
 #define ASS_ONEWORD    0x1000  /* don't check array subscripts, assume higher level has done that */
 #define ASS_NOTEMPENV  0x2000  /* don't assign into temporary environment */
+#define ASS_XTRACE     0x4000  /* print trace after compound assignment expansion */
 
 /* Flags for the string extraction functions. */
 #define SX_NOALLOC     0x0001  /* just skip; don't return substring */
index b6cc7ea6a30fed2f8cb3b2cc67daf22a7d2704ae..3ab73512a7ce4058c275e27e8d9d32ecaa7c77b5 100644 (file)
@@ -35,6 +35,7 @@ a b
 a a b
 ok 3
 ok 4
+line with escaped newline
 bar
 bad
 0
index 0864a3c463e015dccbb0a621e3777ebc2f5347b5..cd2cb1d4261bdbc234a61511179be3b9f9d32b00 100644 (file)
@@ -82,6 +82,12 @@ long_comment text after
 # comment
 comment foo bar
 
+# make sure escaped newlines in alias bodies are processed correctly
+alias xx='echo line with \
+escaped newline'
+xx
+unalias xx
+
 # alias ending in a tab
 alias foo="\
        echo \"bar\" \
@@ -98,3 +104,4 @@ foo>&2
 
 alias a='printf "<%s>\n" \'
 a|cat
+
index 846e05f74de41e4735573ff05ebf7a2b55f36a6f..fb08a5c1e48d13b4930ee7d0df20b35d5d02860c 100644 (file)
@@ -123,15 +123,17 @@ argv[1] = </>
 55
 49
 6 -- 6
+./array.tests: line 232: [-10]: bad array subscript
+0
 42 14 44
 grep [ 123 ] *
 6 7 9
 6 7 9 5
 length = 3
 value = new1 new2 new3
-./array.tests: line 256: syntax error near unexpected token `&'
-./array.tests: line 256: `badarray=( metacharacters like & need to be quoted in compound assignments)'
-./array.tests: line 260: narray: unbound variable
+./array.tests: line 261: syntax error near unexpected token `&'
+./array.tests: line 261: `badarray=( metacharacters like & need to be quoted in compound assignments)'
+./array.tests: line 265: narray: unbound variable
 ./array1.sub: line 1: syntax error near unexpected token `('
 ./array1.sub: line 1: `printf "%s\n" -a a=(a 'b  c')'
 ./array2.sub: line 1: declare: `[]=asdf': not a valid identifier
@@ -158,10 +160,10 @@ for case if then else
 12 14 16 18 20
 4414758999202
 aaa bbb
-./array.tests: line 310: syntax error near unexpected token `<>'
-./array.tests: line 310: `metas=( <> < > ! )'
-./array.tests: line 311: syntax error near unexpected token `<>'
-./array.tests: line 311: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
+./array.tests: line 315: syntax error near unexpected token `<>'
+./array.tests: line 315: `metas=( <> < > ! )'
+./array.tests: line 316: syntax error near unexpected token `<>'
+./array.tests: line 316: `metas=( [1]=<> [2]=< [3]=> [4]=! )'
 abc 3
 case 4
 abc case if then else 5
@@ -846,3 +848,4 @@ declare -a A=([0]="x" [1]="x")
 declare -a A=([0]="x" [1]="x")
 ./array33.sub: line 46: A: cannot convert indexed to associative array
 declare -a A=([0]="x" [1]="x")
+./array33.sub: line 52: read: A: not an indexed array
index 10f605559f7dd63edda2d75073dd0dadcc432ba2..bd2ee5660a8e9e3c7c4ddda82f96f7eaeec98a61 100644 (file)
@@ -228,6 +228,11 @@ unset xpath[nelem-1]
 nelem=${#xpath[@]}
 echo ${#xpath[@]} -- $nelem
 
+# error
+echo ${#xpath[-10]}
+# zero length for unset elements
+echo ${#xpath[42]}
+
 # arrays and things that look like index assignments
 array=(42 [1]=14 [2]=44)
 
index 383fc01931c93ab9477340190c58a30cc082fb2a..5eb40a464cf44b4fc917c50c88bffab23a72ebda 100644 (file)
@@ -45,3 +45,8 @@ declare -p A
 # error to convert indexed to associative
 declare -A A=([1]=1)
 declare -p A
+
+# can't read into an associative array
+unset -v A
+declare -A A
+read -a A </dev/null
index 8cf91f9539c265d389461841b888c2b10b165df3..84a2bc49e652699faba26e6fc8a43dd290423228 100644 (file)
@@ -40,6 +40,8 @@ argv[2] = <qix>
 argv[1] = <qux qix>
 declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
 argv[1] = <2>
+./assoc.tests: line 99: [$unset]: bad array subscript
+0
 argv[1] = <7>
 argv[1] = <qux>
 argv[2] = <qix>
index 5055d5ca085a495fcd72c5cd952283c5ebf61c58..07fc9b591cb29beb10273f4a4002860b77625d7a 100644 (file)
@@ -95,6 +95,11 @@ wheat=([six]=6 [foo bar]="qux qix" )
 
 recho ${#wheat[@]}
 
+# and error
+echo ${#wheat[$unset]}
+# zero length for unset element
+echo ${#wheat[unset]}
+
 recho ${#wheat[foo bar]}
 
 # TEST - appending assignment operator
index 94185909952b2bf0233e5901215fe5f04b0de670..1f788774cbb29971f80b0661b485f94f6c195cc2 100644 (file)
@@ -1,4 +1,3 @@
-1000
 a
 end-1
 a
@@ -84,7 +83,10 @@ enable times
 enable trap
 enable unset
 enable -n test worked
+enable -n test
 enable test worked
+./builtins.tests: line 126: enable: notbuiltin: not a shell builtin
+./builtins.tests: line 127: enable: test: not dynamically loaded
 specialname
 -specialname
 FOO=BAR
@@ -107,6 +109,7 @@ m n o p
 /tmp/bash-dir-a
 /tmp/bash-dir-a
 /tmp/bash-dir-a
+/
 ./source5.sub: line 23: /tmp/source-notthere: No such file or directory
 after bad source 1
 ./source5.sub: line 30: /tmp/source-notthere: No such file or directory
@@ -157,6 +160,8 @@ a
 
 
 b
+-p
+a      b       c
 before: f = 4
 inside
 after: f = 8 bar = 4
@@ -296,6 +301,7 @@ u=rwx,g=rx,o=rx
 u=rwx,g=rx,o=rx
 u=rwx,g=rx,o=rx
 u=rwx,g=rx,o=rx
+u=rwx,g=rx,o=x
 hash: hash table empty
 ./builtins9.sub: line 19: hash: notthere: not found
 1
@@ -379,6 +385,16 @@ Shell commands matching keyword `read*'
 read: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
 readarray: readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
 readonly: readonly [-aAf] [name[=value] ...] or readonly -p
+read: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
+readarray: readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
+readonly: readonly [-aAf] [name[=value] ...] or readonly -p
+:: :
+    Null command.
+    
+    No effect; the command does nothing.
+    
+    Exit Status:
+    Always succeeds.
 NAME
     : - Null command.
 
@@ -445,4 +461,32 @@ A star (*) next to a name means that the command is disabled.
  getopts optstring name [arg ...]        while COMMANDS; do COMMANDS-2; done
  hash [-lr] [-p pathname] [-dt] [name >  { COMMANDS ; }
  help [-dms] [pattern ...]
-./builtins.tests: line 316: exit: status: numeric argument required
+./builtins10.sub: line 39: help: no help topics match `bash'.  Try `help help' or `man -k bash' or `info bash'.
+unlimited
+unlimited
+./builtins11.sub: line 27: ulimit: +1999: invalid number
+0
+0
+./builtins11.sub: line 37: ulimit: -q: invalid option
+ulimit: usage: ulimit [-SHabcdefiklmnpqrstuvxPRT] [limit]
+./builtins11.sub: line 39: ulimit: max user processes: cannot modify limit: Operation not permitted
+/tmp /bin
+/tmp /bin
+/bin /tmp
+./builtins12.sub: line 21: pushd: -x: invalid number
+pushd: usage: pushd [-n] [+N | -N | dir]
+/tmp
+./builtins12.sub: line 24: popd: -x: invalid number
+popd: usage: popd [-n] [+N | -N]
+/ /tmp
+./builtins12.sub: line 27: popd: dir: invalid argument
+popd: usage: popd [-n] [+N | -N]
+/
+/tmp
+/tmp /
+/bin /tmp /
+./builtins12.sub: line 35: popd: -8: directory stack index out of range
+./builtins12.sub: line 36: popd: +8: directory stack index out of range
+/tmp /
+/
+./builtins.tests: line 322: exit: status: numeric argument required
index 781c021c9cca63b28a26d12471325ad3e28c5a61..f3a8fc2bc684907ca8f8bd473fdcfc8f2e5cf8e4 100644 (file)
 set +p
 set +o posix
 
-ulimit -S -c 0 2>/dev/null
-ulimit -c -S -- 1000 2>/dev/null
-ulimit -c 2>/dev/null
-
 # check that break breaks loops
 for i in a b c; do echo $i; break; echo bad-$i; done
 echo end-1
@@ -119,6 +115,7 @@ case "$(type -t test)" in
 builtin)       echo oops -- enable -n test failed ;;
 *)     echo enable -n test worked ;;
 esac
+enable -n | grep test
 
 enable test
 case "$(type -t test)" in
@@ -126,6 +123,9 @@ builtin)    echo enable test worked ;;
 *)     echo oops -- enable test failed ;;
 esac
 
+enable -d notbuiltin
+enable -d test
+
 # test options to exec
 (exec -a specialname ${THIS_SH} -c 'echo $0' )
 (exec -l -a specialname ${THIS_SH} -c 'echo $0' )
@@ -307,6 +307,12 @@ ${THIS_SH} ./builtins9.sub
 # help tests
 ${THIS_SH} ./builtins10.sub
 
+# ulimit tests
+${THIS_SH} ./builtins11.sub
+
+# pushd/popd/dirs
+${THIS_SH} ./builtins12.sub
+
 shift 0        # succeeds silently
 
 options=$(set -o -B 2>&1 | wc -l)
index 52185b54f99e9879fe74a5e80874817b1eebc096..ae3defb87019d25f69383fa6b05ebaaeeab766fa 100644 (file)
@@ -12,3 +12,7 @@ echo $PWD
 
 cd "$MYDIR"
 rmdir $FULLDIR
+
+cd /
+cd /tmp
+cd -           # should print /
index 4b9e6659fd95aa571a6862a1c33cad3db0569352..e8413f819b8f235a664745c74cee616ba922c175 100644 (file)
@@ -25,8 +25,15 @@ help -s builtin shift
 
 # this hasn't ever been very useful
 help -s 'read*'
+# but prefix matching is
+help -s rea
+
+help :
 
 help -m : | grep -v version
 
 LC_ALL=en_US.UTF-8
 help -- | sed 1d
+
+# maybe sometime in the future this will do something
+help -- bash
diff --git a/tests/builtins11.sub b/tests/builtins11.sub
new file mode 100644 (file)
index 0000000..ec841cb
--- /dev/null
@@ -0,0 +1,45 @@
+#   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
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# ulimit tests
+
+ulimit unlimited       # default to -f
+ulimit -f              # better be unlimited
+ulimit -Sf hard
+
+corelim=${ ulimit -c; }
+
+# pick -c because everyone's going to have it
+ulimit -Sc unlimited
+ulimit -c soft
+ulimit -c              # unlimited
+# maybe someday the leading `+' will be accepted, but not today
+ulimit -c -S -- +1999
+ulimit -c -S -- 1999
+ulimit -c 0
+ulimit -Hc             # hard and soft 0
+ulimit -Sc hard                # should be 0
+ulimit -c
+
+ulimit -a >/dev/null   # just make sure we have no errors
+
+# these are errors
+ulimit -q
+# have to see about this one
+ulimit -u $(( 2**31 - 1 ))
+
+lim=$(ulimit -Sn)
+ulimit -n $lim
+lim2=$(ulimit -n)
+
+[[ $lim -eq $lim2 ]] || echo 'ulimit: setting to soft limit fails' >&2
diff --git a/tests/builtins12.sub b/tests/builtins12.sub
new file mode 100644 (file)
index 0000000..89e23ec
--- /dev/null
@@ -0,0 +1,40 @@
+#   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
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# pushd/popd/dirs tests
+
+cd /bin
+pushd /tmp
+dirs --
+
+pushd --
+pushd -x
+
+popd --
+popd -x
+
+pushd /
+popd dir       # error
+
+dirs -p
+pushd --
+
+pushd /bin
+
+# out of range errors
+popd -8
+popd +8
+
+# this needs a fix to work right
+popd -- +8
+popd -- -8
index e4cb32ae6bc3145e0ae91cc66ce757db1532df15..9b6cb73ea48b0277022fe4ff01a106787591f0d7 100644 (file)
@@ -8,3 +8,7 @@ echo 'a\n\n\nb'
 
 shopt -s xpg_echo
 echo 'a\n\n\nb'
+
+echo -p
+set -o posix
+echo 'a\tb\tc'
index ffe9869b080eed7207948061fedb8e6a499b899e..6b35e795fb9f789f514f21a0645d59afa124892f 100644 (file)
@@ -79,3 +79,7 @@ umask -S
 umask 022
 umask g+x,o+x
 umask -S
+
+umask 022
+umask u+g,g+o,o-rw
+umask -S
index d33c8c5af566862b2ddbafa1d05f81e595f61f58..3ff3eaf51b30bb8345d95ebcc890547a183df06f 100644 (file)
@@ -15,6 +15,9 @@ no
 no
 ok
 esac
+unset word ok 1
+unset word ok 2
+unset word ok 3
 ok 1
 ok 2
 ok 3
index 7ad4c683afb6fe98c5537b855d5a03404fdeb322..2bb0922de9abc64ee4f54b03e7ec37e083d0571c 100644 (file)
@@ -66,6 +66,15 @@ case " " in ( [" "] ) echo ok;; ( * ) echo no;; esac
 case esac in (esac) echo esac;; esac
 case k in else|done|time|esac) for f in 1 2 3 ; do :; done esac
 
+# null words and patterns
+var=value
+case $unset in
+'')    echo unset word ok 1 ;;&
+$unset|$var)   echo unset word ok 2 ;;&
+unset|$unset)  echo unset word ok 3 ;;
+*)     echo unset word bad ;;
+esac
+
 # tests of quote removal and pattern matching
 ${THIS_SH} ./case1.sub
 ${THIS_SH} ./case2.sub
index df12475478580f440e1e73aebf7a2982b9b432f5..55081a59efebd6ed2130e25ce2a7369c329371ed 100644 (file)
@@ -43,5 +43,7 @@ Be Conservative in what you send and Liberal in what you accept
 BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
 Be conservative in what you send and liberal in what you accept
 BE CONSERVATIVE IN WHAT YOU SEND AND LIBERAL IN WHAT YOU ACCEPT
+acKnowledGEmEnt
+oENoPHiLe
 abcdexyz
 ABCDEXYZ
index 56ab20d956ed5b9a6b76b1fe45e20628e96f736f..a7709a5f62229b5de0b87bbb5e9962e97fce7060 100644 (file)
@@ -114,8 +114,11 @@ echo ${TEXT2^^}
 M1=${S1^^[aeiou]}
 M2=${U2,,[AEIOU]}
 
-#echo ${M1} ${M1~}
-#echo ${M2} ${M2~~}
+# case-toggling modifiers are still in there for now
+Z1=AcKnowledGEmEnt
+Z2=OenOphIlE
+echo ${Z1~}
+echo ${Z2~~}
 
 declare -l lower=aBcDe
 lower+=XyZ
index 500ec8f71f8754b4eb02828d23752de5c1d09fce..d933a22ddb995759c499f826ccfae9deaae6245a 100644 (file)
@@ -61,6 +61,13 @@ complete -d rmdir
 complete -f more
 complete -f -X '!*.+(gz|tgz)' gzcat
 ./complete.tests: line 123: complete: notthere: no completion specification
+./complete.tests: line 130: complete: -V: invalid option
+complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
+./complete.tests: line 132: compgen: `invalid-name': not a valid identifier
+.
+unalias -- fee
+unalias -- fi
+unalias -- fum
 !
 %
 (( ... ))
@@ -138,6 +145,91 @@ variables
 wait
 while
 { ... }
+allexport
+braceexpand
+emacs
+errexit
+errtrace
+functrace
+hashall
+histexpand
+history
+ignoreeof
+interactive-comments
+keyword
+monitor
+noclobber
+noexec
+noglob
+nolog
+notify
+nounset
+onecmd
+physical
+pipefail
+posix
+privileged
+verbose
+vi
+xtrace
+autocd
+array_expand_once
+assoc_expand_once
+cdable_vars
+cdspell
+checkhash
+checkjobs
+checkwinsize
+cmdhist
+compat31
+compat32
+compat40
+compat41
+compat42
+compat43
+compat44
+complete_fullquote
+direxpand
+dirspell
+dotglob
+execfail
+expand_aliases
+extdebug
+extglob
+extquote
+failglob
+force_fignore
+globasciiranges
+globskipdots
+globstar
+gnu_errfmt
+histappend
+histreedit
+histverify
+hostcomplete
+huponexit
+inherit_errexit
+interactive_comments
+lastpipe
+lithist
+localvar_inherit
+localvar_unset
+login_shell
+mailwarn
+no_empty_cmd_completion
+nocaseglob
+nocasematch
+noexpand_translation
+nullglob
+patsub_replacement
+progcomp
+progcomp_alias
+promptvars
+restricted_shell
+shift_verbose
+sourcepath
+varredir_close
+xpg_echo
 .
 :
 [
@@ -282,9 +374,13 @@ time
 [[
 ]]
 coproc
-./complete.tests: line 136: compgen: -r: invalid option
+./complete.tests: line 152: complete: -z: invalid option
+complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
+complete: usage: complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]
+./complete.tests: line 154: compgen: -r: invalid option
 compgen: usage: compgen [-V varname] [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
-./complete.tests: line 137: compgen: noaction: invalid action name
-./complete.tests: line 138: compgen: -D: invalid option
+./complete.tests: line 155: compgen: noaction: invalid action name
+./complete.tests: line 156: compgen: -D: invalid option
 compgen: usage: compgen [-V varname] [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]
-./complete.tests: line 140: compopt: nooption: invalid option name
+./complete.tests: line 157: compgen: nooption: invalid option name
+./complete.tests: line 159: compopt: nooption: invalid option name
index e4c655ce344559605d1df1ea16a20d51a57c0231..adb7761a2d49587d368ac25766bc4011e57b2577 100644 (file)
@@ -125,16 +125,35 @@ complete -r notthere
 complete -r
 complete
 
+# new complete/compgen -V option
+# doesn't work for complete
+complete -V name
+
+compgen -V invalid-name -b
+compgen -V array -b
+echo ${array[0]}
+
+# a more complicated example
+unalias -a
+alias fee=one fi=two fo=three fum=four
+compgen -a -X 'fo*' -V vv -P 'unalias -- ' f
+printf '%s\n' "${vv[@]}"
+
 # some random compgen topics
 
 compgen -A helptopic
+builtin compgen -A setopt
+compgen -A shopt
 command compgen -b 
 compgen -A enabled
 compgen -k
 
 # and some errors
+complete -z
+complete -b
 compgen -r
 compgen -A noaction
 compgen -D
+compgen -o nooption
 
 compopt -o nooption
index cdfb27c83b0690135f663a0ccf507e9f812fe1a3..3588cca708601aca71da6c7678d60f604451b7ae 100644 (file)
@@ -92,6 +92,13 @@ after here-doc: 1
 [2]+  Running                 sleep 1 &
 17772 26794
 17772 26794
+we should try rhs
+comsub
+and
+funsub
+in here-documents
+after all they work here
+and work here
 a b c == 1 2 3
  == 1 2 3
 before return
index 8a4a5743e07c3e00bb52811df65f9aa18d715c99..2edda3bfa0751ffb6e1cb8ea9bf879624107f09d 100644 (file)
@@ -61,3 +61,19 @@ echo $RANDOM ${ echo $RANDOM; }
 
 RANDOM=42
 echo $RANDOM $RANDOM
+
+# here-documents and other word expansions with comsub/funsub on the rhs
+
+exec 4<<EOF
+we should try rhs
+${word-$(echo comsub)}
+and
+${word-${ echo funsub; }}
+in here-documents
+EOF
+
+cat <&4
+exec 4<&-
+
+echo after all they ${word-$(echo work here)}
+echo and ${word-${ echo work here; }}
index f04f775cceaf26557edf3ed4bb5162075b99b443..172c3f46749b1ee494af08b8748d8f2310bcf166 100644 (file)
@@ -17,4 +17,12 @@ ${THIS_SH} -c '[[ & ]]' bash
 ${THIS_SH} -c '[[ -Q 7 ]]' bash
 ${THIS_SH} -c '[[ -n < ]]' bash
 
+# let's see what failed cond commands do with ERR trap
+trap 'echo ERR: $LINENO: -$BASH_COMMAND- failed' ERR
+[[ -n $unset ]]
 
+func()
+{
+       [[ -z nonempty ]]
+}
+func
index cbe552b2a355888d6871f56260925e4a33b829a6..4f90a7a7d0ff891ed643b9dd9a08e8340232c125 100644 (file)
@@ -54,6 +54,12 @@ ok 2
 ok 3
 ok 4
 ok 5
+ok c1
+ok c2
+ok c3
+ok c4
+ok c5
+ok c6
 match 1
 match 2
 match 3
@@ -178,6 +184,8 @@ bash: -c: line 1: `[[ -Q 7 ]]'
 bash: -c: line 1: unexpected argument `<' to conditional unary operator
 bash: -c: line 1: syntax error near `<'
 bash: -c: line 1: `[[ -n < ]]'
+ERR: 22: -[[ -n $unset ]]- failed
+ERR: 28: -[[ -z nonempty ]]- failed
 + [[ -t X ]]
 ./cond-xtrace1.sub: line 6: [[: X: integer expected
 + [[ '' > 7 ]]
index 68f168649acdc500677c264878b8206bcdafdfad..110f702fee77ff39c87cc6a261efab72ec55cdd1 100644 (file)
@@ -229,6 +229,17 @@ del=$'\177'
 # allow reserved words after a conditional command just because
 if [[ str ]] then [[ str ]] fi
 
+# make sure pattern matching does the right thing with CTLESC
+var=$'ab\001'
+[[ $var == $var ]] && echo ok c1
+[[ $var == a* ]] && echo ok c2
+[[ $var == $'ab\001' ]] && echo ok c3
+
+var=$'ab\001c'
+[[ $var == $var ]] && echo ok c4
+[[ $var == a* ]] && echo ok c5
+[[ $var == $'ab\001'* ]] && echo ok c6
+
 ${THIS_SH} ./cond-regexp1.sub
 ${THIS_SH} ./cond-regexp2.sub
 ${THIS_SH} ./cond-regexp3.sub
index 6e2194aae9cb162642751d9f2a558d464851c798..f502701127fbc065fa2dd791b6d9421bdc280caf 100644 (file)
@@ -1,7 +1,10 @@
-debug lineno: 74 main
-debug lineno: 77 main
-FUNCNAME main
+0 NULL
+./dbg-support.tests: line 72: caller: -z: invalid option
+caller: usage: caller [expr]
+debug lineno: 78 main
 debug lineno: 81 main
+FUNCNAME main
+debug lineno: 85 main
 debug lineno: 30 fn1
 debug lineno: 31 fn1
 LINENO 31
@@ -12,9 +15,9 @@ BASH_SOURCE[0] ./dbg-support.tests
 debug lineno: 34 fn1
 FUNCNAME[0] fn1
 debug lineno: 35 fn1
-debug lineno: 35 fn1 81 ./dbg-support.tests
+debug lineno: 35 fn1 85 ./dbg-support.tests
 debug lineno: 36 fn1
-debug lineno: 36 fn1 81 main ./dbg-support.tests
+debug lineno: 36 fn1 85 main ./dbg-support.tests
 debug lineno: 37 fn1
 debug lineno: 37 fn1
 debug lineno: 38 fn1
@@ -26,7 +29,7 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 30 fn1
 debug lineno: 27 print_return_trap
-debug lineno: 82 main
+debug lineno: 86 main
 debug lineno: 41 fn2
 debug lineno: 42 fn2
 fn2 here. Calling fn1...
@@ -45,7 +48,7 @@ debug lineno: 35 fn1 43 ./dbg-support.tests
 debug lineno: 36 fn1
 debug lineno: 36 fn1 43 fn2 ./dbg-support.tests
 debug lineno: 37 fn1
-debug lineno: 37 fn1 82 main ./dbg-support.tests
+debug lineno: 37 fn1 86 main ./dbg-support.tests
 debug lineno: 38 fn1
 ./dbg-support.tests: line 38: caller: foo: invalid number
 caller: usage: caller [expr]
@@ -60,7 +63,7 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 41 fn2
 debug lineno: 27 print_return_trap
-debug lineno: 83 main
+debug lineno: 87 main
 debug lineno: 46 fn3
 debug lineno: 47 fn3
 LINENO 47
@@ -112,7 +115,7 @@ debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
 debug lineno: 25 sourced_fn
 debug lineno: 26 sourced_fn
-FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 83
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 87
 debug lineno: 23 sourced_fn
 debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
@@ -137,7 +140,7 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 46 fn3
 debug lineno: 27 print_return_trap
-debug lineno: 84 main
+debug lineno: 88 main
 debug lineno: 31 source
 SOURCED LINENO 31
 debug lineno: 32 source
@@ -160,7 +163,7 @@ debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
 debug lineno: 25 sourced_fn
 debug lineno: 26 sourced_fn
-FUNCNAME[1]: source called from ./dbg-support.tests at line 84
+FUNCNAME[1]: source called from ./dbg-support.tests at line 88
 debug lineno: 23 sourced_fn
 debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
@@ -175,24 +178,24 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 16 sourced_fn
 debug lineno: 27 print_return_trap
-debug lineno: 84 main
+debug lineno: 88 main
 debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
-return lineno: 84 main
+return lineno: 88 main
 debug lineno: 27 print_return_trap
-debug lineno: 87 main
-debug lineno: 90 main
+debug lineno: 91 main
+debug lineno: 94 main
 LINENO 31
 LINENO 32
 BASH_SOURCE[0] ./dbg-support.tests
 FUNCNAME[0] fn1
-90 ./dbg-support.tests
-90 main ./dbg-support.tests
+94 ./dbg-support.tests
+94 main ./dbg-support.tests
 
 ./dbg-support.tests: line 38: caller: foo: invalid number
 caller: usage: caller [expr]
 
-debug lineno: 91 main
+debug lineno: 95 main
 fn2 here. Calling fn1...
 LINENO 31
 LINENO 32
@@ -200,11 +203,11 @@ BASH_SOURCE[0] ./dbg-support.tests
 FUNCNAME[0] fn1
 43 ./dbg-support.tests
 43 fn2 ./dbg-support.tests
-91 main ./dbg-support.tests
+95 main ./dbg-support.tests
 ./dbg-support.tests: line 38: caller: foo: invalid number
 caller: usage: caller [expr]
 
-debug lineno: 92 main
+debug lineno: 96 main
 LINENO 47
 BASH_SOURCE[0] ./dbg-support.tests
 fn3 called from file  `./dbg-support.tests' at line 0
@@ -214,13 +217,13 @@ SOURCED BASH_SOURCE[0] ./dbg-support.sub
 SOURCED FN LINENO 18
 FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
 FUNCNAME[1]: source called from ./dbg-support.tests at line 59
-FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 92
+FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 96
 FUNCNAME[3]: main called from ./dbg-support.tests at line 0
-debug lineno: 93 main
+debug lineno: 97 main
 fn4 here. Calling fn3...
 LINENO 47
 BASH_SOURCE[0] ./dbg-support.tests
-fn3 called from file  `./dbg-support.tests' at line 93
+fn3 called from file  `./dbg-support.tests' at line 97
 fn4 called from file  `./dbg-support.tests' at line 0
 main called from file  `./dbg-support.tests' at line 0
 SOURCED LINENO 31
@@ -229,18 +232,18 @@ SOURCED FN LINENO 18
 FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
 FUNCNAME[1]: source called from ./dbg-support.tests at line 59
 FUNCNAME[2]: fn3 called from ./dbg-support.tests at line 64
-FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 93
+FUNCNAME[3]: fn4 called from ./dbg-support.tests at line 97
 FUNCNAME[4]: main called from ./dbg-support.tests at line 0
-debug lineno: 94 main
+debug lineno: 98 main
 SOURCED LINENO 31
 SOURCED BASH_SOURCE[0] ./dbg-support.sub
 SOURCED FN LINENO 18
 FUNCNAME[0]: sourced_fn called from ./dbg-support.sub at line 33
-FUNCNAME[1]: source called from ./dbg-support.tests at line 94
+FUNCNAME[1]: source called from ./dbg-support.tests at line 98
 FUNCNAME[2]: main called from ./dbg-support.tests at line 0
-return lineno: 94 main
-debug lineno: 97 main
-debug lineno: 100 main
+return lineno: 98 main
+debug lineno: 101 main
+debug lineno: 104 main
 debug lineno: 31 source
 SOURCED LINENO 31
 debug lineno: 32 source
@@ -263,7 +266,7 @@ debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
 debug lineno: 25 sourced_fn
 debug lineno: 26 sourced_fn
-FUNCNAME[1]: source called from ./dbg-support.tests at line 100
+FUNCNAME[1]: source called from ./dbg-support.tests at line 104
 debug lineno: 23 sourced_fn
 debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
@@ -278,39 +281,39 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 16 sourced_fn
 debug lineno: 27 print_return_trap
-debug lineno: 100 main
+debug lineno: 104 main
 debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
-return lineno: 100 main
+return lineno: 104 main
 debug lineno: 27 print_return_trap
-debug lineno: 101 main
-debug lineno: 104 main
-debug lineno: 104 main
 debug lineno: 105 main
 debug lineno: 108 main
-debug lineno: 104 main
-debug lineno: 104 main
-debug lineno: 105 main
 debug lineno: 108 main
-debug lineno: 104 main
-debug lineno: 104 main
-debug lineno: 105 main
-debug lineno: 106 main
+debug lineno: 109 main
+debug lineno: 112 main
+debug lineno: 108 main
+debug lineno: 108 main
+debug lineno: 109 main
+debug lineno: 112 main
+debug lineno: 108 main
+debug lineno: 108 main
+debug lineno: 109 main
+debug lineno: 110 main
 Hit 2
+debug lineno: 112 main
 debug lineno: 108 main
-debug lineno: 104 main
-debug lineno: 104 main
-debug lineno: 114 main
-SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 114 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
-debug lineno: 115 main
-SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 115 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
-debug lineno: 116 main
-debug lineno: 117 main
+debug lineno: 108 main
+debug lineno: 118 main
+SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 118 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 119 main
+SOURCED FN LINENO 18 FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 119 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
+debug lineno: 120 main
+debug lineno: 121 main
 SOURCED FN LINENO 18
-FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 117
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 121
 FUNCNAME[1]: main called from ./dbg-support.tests at line 0
-debug lineno: 121 main
-debug lineno: 122 main
+debug lineno: 125 main
+debug lineno: 126 main
 debug lineno: 16 sourced_fn
 debug lineno: 17 sourced_fn
 debug lineno: 18 sourced_fn
@@ -322,7 +325,7 @@ debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
 debug lineno: 25 sourced_fn
 debug lineno: 26 sourced_fn
-FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 122
+FUNCNAME[0]: sourced_fn called from ./dbg-support.tests at line 126
 debug lineno: 23 sourced_fn
 debug lineno: 23 sourced_fn
 debug lineno: 24 sourced_fn
@@ -337,21 +340,21 @@ debug lineno: 25 print_return_trap
 debug lineno: 26 print_return_trap
 return lineno: 16 sourced_fn
 debug lineno: 27 print_return_trap
-debug lineno: 125 main
-debug lineno: 130 main
+debug lineno: 129 main
 debug lineno: 134 main
+debug lineno: 138 main
 got it
-debug lineno: 142 main
-debug lineno: 143 main
-debug lineno: 144 main
-debug lineno: 143 main
-debug lineno: 144 main
-debug lineno: 142 main
-debug lineno: 143 main
-debug lineno: 144 main
-debug lineno: 143 main
-debug lineno: 144 main
+debug lineno: 146 main
+debug lineno: 147 main
+debug lineno: 148 main
+debug lineno: 147 main
+debug lineno: 148 main
+debug lineno: 146 main
+debug lineno: 147 main
+debug lineno: 148 main
+debug lineno: 147 main
 debug lineno: 148 main
+debug lineno: 152 main
 main: calling f1
 f1: calling f2
 f2: calling f3
index b4a58e4b6a42225c9c2d04e7d3160294d71402b4..d07d928c9535e7d5744db71965714c8a0a9c813d 100644 (file)
@@ -67,6 +67,10 @@ fn4() {
 #
 # Test of support for debugging facilities in bash
 # 
+
+caller
+caller -z
+
 # Test debugger set option functrace - set on. Not in vanilla Bash 2.05
 #
 set -o functrace
index 76bfbf3209716877dfbcd3845ba753da3b21441b..d8a6a17cd7f904dbd39848e568cef5b476ea9027 100644 (file)
-./errors.tests: line 30: alias: -x: invalid option
+unalias: usage: unalias [-a] name [name ...]
+./errors.tests: line 31: alias: -x: invalid option
 alias: usage: alias [-p] [name[=value] ... ]
-./errors.tests: line 31: unalias: -x: invalid option
+./errors.tests: line 32: unalias: -x: invalid option
 unalias: usage: unalias [-a] name [name ...]
-./errors.tests: line 32: alias: hoowah: not found
-./errors.tests: line 33: unalias: hoowah: not found
-./errors.tests: line 36: `1': not a valid identifier
-./errors.tests: line 37: `f\1': not a valid identifier
-./errors.tests: line 41: `invalid-name': not a valid identifier
-./errors.tests: line 43: `f\1': not a valid identifier
-./errors.tests: line 46: `1': not a valid identifier
-./errors.tests: line 47: `f\1': not a valid identifier
-./errors.tests: line 48: `invalid-name': not a valid identifier
-./errors.tests: line 50: `1': not a valid identifier
-./errors.tests: line 51: `f\1': not a valid identifier
-./errors.tests: line 55: `$1': not a valid identifier
+./errors.tests: line 33: alias: hoowah: not found
+./errors.tests: line 34: unalias: hoowah: not found
+./errors.tests: line 37: `1': not a valid identifier
+./errors.tests: line 38: `f\1': not a valid identifier
+./errors.tests: line 42: `invalid-name': not a valid identifier
+./errors.tests: line 44: `f\1': not a valid identifier
+./errors.tests: line 47: `1': not a valid identifier
+./errors.tests: line 48: `f\1': not a valid identifier
+./errors.tests: line 49: `invalid-name': not a valid identifier
+./errors.tests: line 51: `1': not a valid identifier
+./errors.tests: line 52: `f\1': not a valid identifier
+./errors.tests: line 56: `$1': not a valid identifier
 declare -fr func
-./errors.tests: line 72: func: readonly function
-./errors.tests: line 75: unset: -x: invalid option
+./errors.tests: line 73: func: readonly function
+./errors.tests: line 76: unset: -x: invalid option
 unset: usage: unset [-f] [-v] [-n] [name ...]
-./errors.tests: line 78: unset: func: cannot unset: readonly function
-./errors.tests: line 81: declare: func: readonly function
-./errors.tests: line 85: declare: -a: invalid option
-./errors.tests: line 86: declare: -i: invalid option
-./errors.tests: line 90: unset: XPATH: cannot unset: readonly variable
-./errors.tests: line 96: unset: cannot simultaneously unset a function and a variable
-./errors.tests: line 99: declare: -z: invalid option
+./errors.tests: line 79: unset: func: cannot unset: readonly function
+./errors.tests: line 82: declare: func: readonly function
+./errors.tests: line 86: declare: -a: invalid option
+./errors.tests: line 87: declare: -i: invalid option
+./errors.tests: line 91: unset: XPATH: cannot unset: readonly variable
+./errors.tests: line 97: unset: cannot simultaneously unset a function and a variable
+./errors.tests: line 100: declare: -z: invalid option
 declare: usage: declare [-aAfFgiIlnrtux] [name[=value] ...] or declare -p [-aAfFilnrtux] [name ...]
-./errors.tests: line 101: declare: `-z': not a valid identifier
-./errors.tests: line 102: declare: `/bin/sh': not a valid identifier
-./errors.tests: line 106: declare: cannot use `-f' to make functions
-./errors.tests: line 109: exec: -i: invalid option
+./errors.tests: line 102: declare: `-z': not a valid identifier
+./errors.tests: line 103: declare: `/bin/sh': not a valid identifier
+./errors.tests: line 107: declare: cannot use `-f' to make functions
+./errors.tests: line 110: exec: -i: invalid option
 exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
-./errors.tests: line 113: export: XPATH: not a function
-./errors.tests: line 116: break: only meaningful in a `for', `while', or `until' loop
-./errors.tests: line 117: continue: only meaningful in a `for', `while', or `until' loop
-./errors.tests: line 120: shift: label: numeric argument required
-./errors.tests: line 125: shift: too many arguments
-./errors.tests: line 131: let: expression expected
-./errors.tests: line 134: local: can only be used in a function
-./errors.tests: line 137: logout: not login shell: use `exit'
-./errors.tests: line 140: hash: notthere: not found
-./errors.tests: line 143: hash: -v: invalid option
+./errors.tests: line 117: export: XPATH: not a function
+./errors.tests: line 120: break: only meaningful in a `for', `while', or `until' loop
+./errors.tests: line 121: continue: only meaningful in a `for', `while', or `until' loop
+./errors.tests: line 124: shift: label: numeric argument required
+./errors.tests: line 129: shift: too many arguments
+./errors.tests: line 135: let: expression expected
+./errors.tests: line 138: local: can only be used in a function
+./errors.tests: line 141: logout: not login shell: use `exit'
+./errors.tests: line 144: hash: notthere: not found
+./errors.tests: line 147: hash: -v: invalid option
 hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
-./errors.tests: line 147: hash: hashing disabled
-./errors.tests: line 150: export: `AA[4]': not a valid identifier
-./errors.tests: line 151: readonly: `AA[4]': not a valid identifier
-./errors.tests: line 152: export: `invalid-var=4': not a valid identifier
-./errors.tests: line 153: readonly: `invalid-var=4': not a valid identifier
-./errors.tests: line 154: export: `invalid-var': not a valid identifier
-./errors.tests: line 155: readonly: `invalid-var': not a valid identifier
-./errors.tests: line 158: unset: [-2]: bad array subscript
-./errors.tests: line 162: AA: readonly variable
-./errors.tests: line 166: AA: readonly variable
-./errors.tests: line 174: shift: 5: shift count out of range
-./errors.tests: line 175: shift: -2: shift count out of range
-./errors.tests: line 178: shopt: no_such_option: invalid shell option name
-./errors.tests: line 179: shopt: no_such_option: invalid shell option name
-./errors.tests: line 180: shopt: no_such_option: invalid option name
-./errors.tests: line 183: umask: 09: octal number out of range
-./errors.tests: line 184: umask: `:': invalid symbolic mode character
-./errors.tests: line 185: umask: `:': invalid symbolic mode operator
-./errors.tests: line 188: umask: -i: invalid option
+./errors.tests: line 150: hash: -d: option requires an argument
+./errors.tests: line 154: hash: hashing disabled
+./errors.tests: line 157: export: `AA[4]': not a valid identifier
+./errors.tests: line 158: readonly: `AA[4]': not a valid identifier
+./errors.tests: line 159: export: `invalid-var=4': not a valid identifier
+./errors.tests: line 160: readonly: `invalid-var=4': not a valid identifier
+./errors.tests: line 161: export: `invalid-var': not a valid identifier
+./errors.tests: line 162: readonly: `invalid-var': not a valid identifier
+./errors.tests: line 165: unset: [-2]: bad array subscript
+./errors.tests: line 169: AA: readonly variable
+./errors.tests: line 173: AA: readonly variable
+./errors.tests: line 181: shift: 5: shift count out of range
+./errors.tests: line 182: shift: -2: shift count out of range
+./errors.tests: line 183: shift: 5: shift count out of range
+./errors.tests: line 184: shift: -2: shift count out of range
+./errors.tests: line 187: shopt: no_such_option: invalid shell option name
+./errors.tests: line 188: shopt: no_such_option: invalid shell option name
+./errors.tests: line 189: shopt: no_such_option: invalid option name
+./errors.tests: line 192: umask: 09: octal number out of range
+./errors.tests: line 193: umask: `:': invalid symbolic mode character
+./errors.tests: line 194: umask: `:': invalid symbolic mode operator
+./errors.tests: line 197: umask: -i: invalid option
 umask: usage: umask [-p] [-S] [mode]
-./errors.tests: line 192: umask: `p': invalid symbolic mode character
-./errors.tests: line 201: VAR: readonly variable
-./errors.tests: line 204: declare: VAR: readonly variable
-./errors.tests: line 205: declare: VAR: readonly variable
-./errors.tests: line 207: declare: unset: not found
+./errors.tests: line 201: umask: `p': invalid symbolic mode character
 ./errors.tests: line 210: VAR: readonly variable
+./errors.tests: line 213: declare: VAR: readonly variable
+./errors.tests: line 214: declare: VAR: readonly variable
+./errors.tests: line 216: declare: unset: not found
+./errors.tests: line 219: VAR: readonly variable
 comsub: -c: line 1: syntax error near unexpected token `)'
 comsub: -c: line 1: `: $( for z in 1 2 3; do )'
 comsub: -c: line 1: syntax error near unexpected token `done'
 comsub: -c: line 1: `: $( for z in 1 2 3; done )'
-./errors.tests: line 217: cd: HOME not set
-./errors.tests: line 218: cd: /tmp/xyz.bash: No such file or directory
-./errors.tests: line 220: cd: OLDPWD not set
-./errors.tests: line 221: cd: /bin/sh: Not a directory
-./errors.tests: line 223: cd: /tmp/cd-notthere: No such file or directory
-./errors.tests: line 225: cd: too many arguments
+./errors.tests: line 226: cd: HOME not set
+./errors.tests: line 227: cd: /tmp/xyz.bash: No such file or directory
+./errors.tests: line 229: cd: OLDPWD not set
+./errors.tests: line 230: cd: /bin/sh: Not a directory
+./errors.tests: line 232: cd: /tmp/cd-notthere: No such file or directory
+./errors.tests: line 234: cd: too many arguments
 bash: line 1: PWD: readonly variable
 1
-./errors.tests: line 230: .: filename argument required
+bash: line 1: OLDPWD: readonly variable
+1
+./errors.tests: line 241: .: filename argument required
 .: usage: . filename [arguments]
-./errors.tests: line 231: source: filename argument required
+./errors.tests: line 242: source: filename argument required
 source: usage: source filename [arguments]
-./errors.tests: line 234: .: -i: invalid option
+./errors.tests: line 245: .: -i: invalid option
 .: usage: . filename [arguments]
-./errors.tests: line 237: set: -q: invalid option
+./errors.tests: line 248: set: -q: invalid option
 set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
-./errors.tests: line 240: enable: sh: not a shell builtin
-./errors.tests: line 240: enable: bash: not a shell builtin
-./errors.tests: line 243: shopt: cannot set and unset shell options simultaneously
-./errors.tests: line 246: read: -x: invalid option
+./errors.tests: line 251: enable: sh: not a shell builtin
+./errors.tests: line 251: enable: bash: not a shell builtin
+./errors.tests: line 254: shopt: cannot set and unset shell options simultaneously
+./errors.tests: line 257: read: -x: invalid option
 read: usage: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
-./errors.tests: line 249: read: var: invalid timeout specification
-./errors.tests: line 252: read: `/bin/sh': not a valid identifier
-./errors.tests: line 253: read: `/bin/sh': not a valid identifier
-./errors.tests: line 256: VAR: readonly variable
-./errors.tests: line 259: read: XX: invalid file descriptor specification
-./errors.tests: line 260: read: 42: invalid file descriptor: Bad file descriptor
-./errors.tests: line 263: mapfile: XX: invalid file descriptor specification
-./errors.tests: line 264: mapfile: 42: invalid file descriptor: Bad file descriptor
-./errors.tests: line 268: mapfile: empty array variable name
-./errors.tests: line 269: mapfile: `invalid-var': not a valid identifier
-./errors.tests: line 272: readonly: -x: invalid option
+./errors.tests: line 260: read: var: invalid timeout specification
+./errors.tests: line 263: read: `/bin/sh': not a valid identifier
+./errors.tests: line 264: read: `/bin/sh': not a valid identifier
+./errors.tests: line 265: read: `invalid-name': not a valid identifier
+./errors.tests: line 268: VAR: readonly variable
+./errors.tests: line 271: read: XX: invalid file descriptor specification
+./errors.tests: line 272: read: 42: invalid file descriptor: Bad file descriptor
+./errors.tests: line 275: mapfile: XX: invalid file descriptor specification
+./errors.tests: line 276: mapfile: 42: invalid file descriptor: Bad file descriptor
+./errors.tests: line 280: mapfile: empty array variable name
+./errors.tests: line 281: mapfile: `invalid-var': not a valid identifier
+./errors.tests: line 284: readonly: -x: invalid option
 readonly: usage: readonly [-aAf] [name[=value] ...] or readonly -p
-./errors.tests: line 275: eval: -i: invalid option
+./errors.tests: line 287: eval: -i: invalid option
 eval: usage: eval [arg ...]
-./errors.tests: line 276: command: -i: invalid option
+./errors.tests: line 288: command: -i: invalid option
 command: usage: command [-pVv] command [arg ...]
-./errors.tests: line 279: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
-./errors.tests: line 280: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
-./errors.tests: line 283: trap: NOSIG: invalid signal specification
-./errors.tests: line 286: trap: -s: invalid option
+./errors.tests: line 291: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 292: /bin/sh + 0: arithmetic syntax error: operand expected (error token is "/bin/sh + 0")
+./errors.tests: line 295: trap: NOSIG: invalid signal specification
+./errors.tests: line 298: trap: -s: invalid option
 trap: usage: trap [-Plp] [[action] signal_spec ...]
-./errors.tests: line 292: return: can only `return' from a function or sourced script
-./errors.tests: line 296: break: 0: loop count out of range
-./errors.tests: line 300: continue: 0: loop count out of range
-./errors.tests: line 305: builtin: bash: not a shell builtin
-./errors.tests: line 309: bg: no job control
-./errors.tests: line 310: fg: no job control
-./errors.tests: line 313: kill: -s: option requires an argument
-./errors.tests: line 315: kill: S: invalid signal specification
-./errors.tests: line 317: kill: `': not a pid or valid job spec
+./errors.tests: line 304: return: can only `return' from a function or sourced script
+./errors.tests: line 308: break: 0: loop count out of range
+./errors.tests: line 312: continue: 0: loop count out of range
+./errors.tests: line 317: builtin: -x: invalid option
+builtin: usage: builtin [shell-builtin [arg ...]]
+./errors.tests: line 320: builtin: bash: not a shell builtin
+./errors.tests: line 324: bg: no job control
+./errors.tests: line 325: fg: no job control
+kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
+./errors.tests: line 329: kill: -s: option requires an argument
+./errors.tests: line 331: kill: S: invalid signal specification
+./errors.tests: line 333: kill: `': not a pid or valid job spec
 kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
-./errors.tests: line 321: kill: SIGBAD: invalid signal specification
-./errors.tests: line 323: kill: BAD: invalid signal specification
-./errors.tests: line 325: kill: @12: arguments must be process or job IDs
-./errors.tests: line 328: unset: BASH_LINENO: cannot unset
-./errors.tests: line 328: unset: BASH_SOURCE: cannot unset
-./errors.tests: line 331: set: trackall: invalid option name
-./errors.tests: line 332: set: -q: invalid option
+./errors.tests: line 337: kill: SIGBAD: invalid signal specification
+./errors.tests: line 339: kill: BAD: invalid signal specification
+./errors.tests: line 341: kill: @12: arguments must be process or job IDs
+./errors.tests: line 344: unset: BASH_LINENO: cannot unset
+./errors.tests: line 344: unset: BASH_SOURCE: cannot unset
+./errors.tests: line 347: set: trackall: invalid option name
+./errors.tests: line 348: set: -q: invalid option
 set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
-./errors.tests: line 333: set: -i: invalid option
+./errors.tests: line 349: set: -i: invalid option
 set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
-./errors.tests: line 337: xx: readonly variable
+./errors.tests: line 353: xx: readonly variable
 1
 ./errors1.sub: line 14: .: -i: invalid option
 .: usage: . filename [arguments]
@@ -267,4 +277,4 @@ sh: line 1: unset: `a-b': not a valid identifier
 sh: line 1: /nosuchfile: No such file or directory
 sh: line 1: trap: SIGNOSIG: invalid signal specification
 after trap
-./errors.tests: line 376: `!!': not a valid identifier
+./errors.tests: line 392: `!!': not a valid identifier
index 5f45cfd35c9e9e748f1dff0feaf180f6689baa71..d33bfa089b5a4a41655670b2896a6847a93b97b7 100644 (file)
@@ -24,6 +24,7 @@ set +e
 set +o posix
 
 # various alias/unalias errors
+unalias
 
 # at some point, this may mean to `export' an alias, like ksh, but
 # for now it is an error
@@ -108,6 +109,9 @@ declare -f func='() { echo "this is func"; }'
 # bad option to exec -- this should not exit the script
 exec -i /bin/sh
 
+# trying to exec non-executable file is a fatal error
+( exec ./errors1.sub 2>/dev/null ; echo after failed exec )
+
 # try to export -f something that is not a function -- this should be
 # an error, not create an `invisible function'
 export -f XPATH
@@ -142,6 +146,9 @@ hash notthere
 # bad option to hash, although it may mean `verbose' at some future point
 hash -v
 
+# hash -d requires an argument
+hash -d
+
 # turn off hashing, then try to hash something
 set +o hashall
 hash -p ${THIS_SH} ${THIS_SH##*/}
@@ -173,6 +180,8 @@ AA=(one two three)
 shopt -s shift_verbose
 shift $(( $# + 5 ))
 shift -2
+shift -- $(( $# + 5 ))
+shift -- -2
 
 # bad shell options
 shopt -s no_such_option
@@ -225,6 +234,8 @@ cd -
 cd one two three
 # cd doesn't like it if PWD is readonly
 ${THIS_SH} -c 'readonly PWD ; cd / ; echo $?' bash
+# or if OLDPWD is readonly
+${THIS_SH} -c 'readonly OLDPWD ; cd / ; echo $?' bash
 
 # various `source/.' errors
 .
@@ -251,6 +262,7 @@ read -t var < /dev/null
 # try to read into an invalid identifier
 read /bin/sh < /dev/null
 read A /bin/sh < /dev/null
+read -a invalid-name < /dev/null
 
 # try to read into a readonly variable
 read VAR < /dev/null
@@ -301,6 +313,9 @@ for z in 1 2 3; do
        echo $x
 done
 
+# invalid option
+builtin -x
+
 # builtin with non-builtin
 builtin bash
 
@@ -310,6 +325,7 @@ bg
 fg
 
 # argument required
+kill
 kill -s
 # bad argument
 kill -S
index 3a2469999a038cf390ebfec4e56a3ab1f647cac1..dd1913305c57970e1449415016de728add219124 100644 (file)
@@ -5,13 +5,14 @@ after exec1.sub with args: 0
 
 after exec1.sub without args: 0
 after exec1.sub: one two three
-./execscript: line 21: notthere: command not found
+./execscript: line 37: notthere: command not found
 127
+we would do something here with notthere
 /tmp/bash: notthere: No such file or directory
 127
 /bin/sh: /bin/sh: cannot execute binary file
 126
-./execscript: line 40: /: Is a directory
+./execscript: line 64: /: Is a directory
 126
 /: /: Is a directory
 126
@@ -19,7 +20,7 @@ bash: line 1: exec: .: cannot execute: Is a directory
 posix-bash: line 1: exec: .: cannot execute: Is a directory
 bash: line 1: exec: .: cannot execute: Is a directory
 posix-bash: line 1: exec: .: cannot execute: Is a directory
-./execscript: line 55: .: /: is a directory
+./execscript: line 79: .: /: is a directory
 1
 126
 0
@@ -35,17 +36,17 @@ trap -- '' SIGTERM
 trap -- 'echo USR1' SIGUSR1
 USR1
 EXIT
-./execscript: line 79: notthere: command not found
+./execscript: line 103: notthere: command not found
 127
-./execscript: line 81: notthere: command not found
+./execscript: line 105: notthere: command not found
 127
-./execscript: line 83: notthere: command not found
+./execscript: line 107: notthere: command not found
 127
-./execscript: line 89: notthere: command not found
+./execscript: line 113: notthere: command not found
 127
-./execscript: line 91: notthere: command not found
+./execscript: line 115: notthere: command not found
 127
-./execscript: line 93: notthere: command not found
+./execscript: line 117: notthere: command not found
 127
 this is sh
 this is sh
index e797c9fc90717a66bac72f4a67dc21fe080ab698..1e2117e6b220fff50761f0e620552712a9b9bfb2 100644 (file)
@@ -1,3 +1,16 @@
+#   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
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 export LC_ALL=C
 export LANG=C
 
@@ -5,6 +18,9 @@ if [ $UID -eq 0 ]; then
         echo "execscript: the test suite should not be run as root" >&2
 fi
 
+# this should succeed silently
+$cmd &
+
 set -- one two three
 echo before exec1.sub: "$@"
 echo calling exec1.sub
@@ -21,6 +37,14 @@ export PATH
 notthere
 echo $?
 
+# now let's set up a command-not-found hook
+command_not_found_handle()
+{
+        echo we would do something here with $1
+}
+notthere a b c
+unset -f command_not_found_handle
+
 # this is iffy, since the error messages may vary from system to system
 # and /tmp might not exist
 ln -s ${THIS_SH} /tmp/bash 2>/dev/null
index f5341351f29c9caa7af73ab3911c2e8083b187a0..9cbb34d1c77a46793977a30a24ea344d6bcb05c5 100644 (file)
@@ -184,11 +184,41 @@ function a=2 ()
     printf "FUNCNAME: %s\n" $FUNCNAME
 }
 FUNCNAME: a=2
+<(:)
+<(:) is a function
+<(:) () 
+{ 
+    echo $FUNCNAME
+}
 break is a function
 break () 
 { 
     echo FUNCNAME: $FUNCNAME
 }
 FUNCNAME: break
-./func5.sub: line 54: `break': is a special builtin
+break is a function
+break () 
+{ 
+    echo FUNCNAME: $FUNCNAME
+}
+break
+./func5.sub: line 69: `break': is a special builtin
+./func5.sub: line 75: `!!': not a valid identifier
+!! is a function
+!! () 
+{ 
+    fc -s "$@"
+}
+!! is a function
+function !! () 
+{ 
+    fc -s "$@"
+}
 5
+rfunc () 
+{ 
+    local -;
+    local var;
+    local -p
+}
+declare -fr rfunc
index 2c0746cf959238de707760cdd6457fbedabb328f..1a753af7832bc1cfec6c363dfb95143c3c1b8c5d 100644 (file)
@@ -199,4 +199,15 @@ segv()
 segv
 echo $?
 
+# functions can have attributes
+rfunc()
+{
+       local -
+       local var
+
+       local -p
+}
+readonly -f rfunc
+readonly -f
+
 exit 0
index ef43de21f22abe236b6d96ca5af89a65d45351d2..43e2c5226de14dd31e5c696d1eb0f15fe9aba356 100644 (file)
@@ -37,6 +37,13 @@ set +o posix
 
 a\=2
 
+<(:) ()
+{
+       echo $FUNCNAME
+}
+\<\(:\)
+type '<(:)'
+
 break()
 {
        echo FUNCNAME: $FUNCNAME
@@ -44,11 +51,32 @@ break()
 
 type break
 \break
+# you can print them in posix mode
+set -o posix
+# posix mode should find special builtins first
+type break
+declare -F break
+set +o posix
 unset -f break
 
-# but in posix mode, declaring such a function is an error
-set -o posix
+# but in posix mode, declaring such a function is a fatal error
+set -o posix
 break()
 {
         echo FUNCNAME: $FUNCNAME
 }
+echo after
+)
+
+# in posix mode, functions whose names are invalid identifiers are fatal errors
+( set -o posix
+!! () { fc -s "$@" ; }
+type \!\!
+)
+
+# but you can create such functions and print them in posix mode
+!! () { fc -s "$@" ; }
+type '!!'
+set -o posix
+type '!!'
+set +o posix
index 7402bacde47c346f97a97b26bc00fcf43149d866..46b12ed331a5a53ac9dd035cc881041a5385597e 100644 (file)
@@ -97,7 +97,7 @@ line 2 for history
 6       HISTFILE=$TMPDIR/newhistory
 7       echo displaying \$HISTFILE after history -a
 8       cat $HISTFILE
-./history.tests: line 90: fc: no command found
+./history.tests: line 91: fc: no command found
    15  echo line 2 for history
    16  unset HISTSIZE
    17  unset HISTFILE
@@ -107,7 +107,7 @@ echo xx xb xc
 xx xb xc
 echo 44 48 4c
 44 48 4c
-./history.tests: line 105: fc: no command found
+./history.tests: line 106: fc: no command found
 aa
 bb
 cc
@@ -180,6 +180,8 @@ i
     4  echo g
     5  echo h
 
+./history3.sub: line 48: history: @42: invalid number
+./history3.sub: line 49: history: @42: numeric argument required
 
 0
 1
@@ -266,6 +268,22 @@ out of range 3
 12      echo out of range 3
 out of range 4
 13      fc -l 1 99
+a
+b
+c
+# out of range specs aren't errors
+echo a
+a
+d
+e
+1       echo a
+2       echo b
+3       echo c
+4       # out of range specs aren't errors
+5       # out of range specs aren't errors
+6       echo a
+7       echo d
+8       echo e
 1
 2
 3
index 4cc078ddb1d9920ea68ea34552329fff954b4484..baa835d53d1d8b262b8e7ed3d0c229ecf3d289a0 100644 (file)
@@ -50,6 +50,7 @@ history -s "echo line for history"
 history
 
 history -p '!!'
+history -p     # this succeeds silently
 
 fc -nl
 
index d8a2203822e4c023ad88e74d2810644848ecb843..6bc067572aa65129fbbc3587cc663d428d0db549 100644 (file)
@@ -45,5 +45,8 @@ history -d 5-0xaf
 
 history ; echo
 
+history -d @42
+history @42
+
 unset HISTFILE
 exit 0
index 245c28d0d90fb83b7006eaf32e5139c02861e433..5a89c79fc5f0ab2d806b95f43424be1a76247a55 100644 (file)
@@ -54,4 +54,20 @@ fc -l 1 99
 echo out of range 4
 fc -l -20 -40
 
+HISTSIZE=10
+history -c
+
+echo a
+echo b
+echo c
+
+# out of range specs aren't errors
+fc -e - 48
+fc -s -- -42
+
+echo d
+echo e
+
+fc -l
+
 unset HISTFILE # suppress writing history file
index 885a4df141254144bb099c5f8fe6cb78f7d2b168..6f2a3d7fbdf8fb294b81786a74f561ea57c8aa61 100644 (file)
@@ -83,7 +83,21 @@ hashall:interactive-comments
 braceexpand:hashall:interactive-comments:noglob
 braceexpand:hashall:interactive-comments:noglob
 ./invocation2.sub: line 50: SHELLOPTS: readonly variable
+for i in 1 2 3;
+do
+    select var in a b c;
+    do
+        echo $REPLY;
+    done <<< a; echo answer was $REPLY;
+done
+
+for ((i=1; i <= 3; i++ ))
+do
+    echo $(( 2**$i ));
+done
+
 a
 a
 bad-interp
 ./invocation.tests: ./x23: nosuchfile: bad interpreter: No such file or directory
+cannot execute binary file
index 84c908ea37e0e3f881262848dde19a19c9ca069b..4f9cab37f83636aabb8eb779723675894c450503 100644 (file)
@@ -38,6 +38,11 @@ ${THIS_SH} ./invocation1.sub
 # SHELLOPTS
 ${THIS_SH} ./invocation2.sub
 
+# rudimentary pretty-print tests
+${THIS_SH} ./invocation3.sub
+
+${THIS_SH} --login -c 'logout'
+
 : ${TMPDIR:=/tmp}
 TDIR=$TMPDIR/invocation-$$
 mkdir $TDIR || exit 1
@@ -63,5 +68,9 @@ command cd -L $TDIR
 # but this results in a bad-interpreter error
 ./x23
 
+# this should result in a cannot execute binary file error since ls is in $PATH
+PATH=/bin:/usr/bin
+${THIS_SH} ls |& sed 's|^.*: ||'
+
 cd $SAVEPWD
 rm -rf $TDIR
diff --git a/tests/invocation3.sub b/tests/invocation3.sub
new file mode 100644 (file)
index 0000000..d764a1e
--- /dev/null
@@ -0,0 +1,25 @@
+: ${THIS_SH:=./bash} ${TMPDIR:=/tmp}
+
+# start at tests for pretty-print mode
+# so far these are cases that aren't handled by the printing code anywhere
+# else in the test suite
+
+SCRIPT=$TMPDIR/pretty-print-$$
+
+cat >$SCRIPT <<\EOF
+for i in 1 2 3
+{
+       select var in a b c; { echo $REPLY; } <<<a
+       echo answer was $REPLY
+}
+
+for (( i=1; i <= 3; i++ ))
+{
+       echo $(( 2**$i ))
+}
+EOF
+
+${THIS_SH} --pretty-print $SCRIPT
+
+rm -f $SCRIPT
+       
index 9a12a88456673e9b9cdbd035e3dff77d8f47b172..173743aea501b60256367f53edecfb38b74b3f96 100644 (file)
@@ -39,13 +39,14 @@ child1 exit status 0
 [1]+ Running sleep 20 &
 ./jobs7.sub: line 5: fg: no current jobs
 [1]+ Running sleep 20 &
+got USR1
 0
-./jobs.tests: line 42: wait: %1: no such job
-./jobs.tests: line 47: fg: no job control
+./jobs.tests: line 45: wait: %1: no such job
+./jobs.tests: line 50: fg: no job control
 wait-for-pid
 wait-errors
-./jobs.tests: line 60: wait: `1-1': not a pid or valid job spec
-./jobs.tests: line 61: wait: `-4': not a pid or valid job spec
+./jobs.tests: line 70: wait: `1-1': not a pid or valid job spec
+./jobs.tests: line 71: wait: `-4': not a pid or valid job spec
 wait-for-background-pids
 async list wait-for-background-pids
 async list wait for child
@@ -54,7 +55,7 @@ wait-when-no-children
 posix jobs output
 [1]+  Done                    sleep 1
 wait-for-job
-./jobs.tests: line 86: wait: %2: no such job
+./jobs.tests: line 96: wait: %2: no such job
 127
 async list wait-for-job
 forked
@@ -67,20 +68,20 @@ sleep 2
 fg-bg 4
 sleep 2
 fg-bg 5
-./jobs.tests: line 113: fg: %2: no such job
-./jobs.tests: line 114: bg: job 1 already in background
+./jobs.tests: line 123: fg: %2: no such job
+./jobs.tests: line 124: bg: job 1 already in background
 fg-bg 6
-./jobs.tests: line 121: fg: -s: invalid option
+./jobs.tests: line 131: fg: -s: invalid option
 fg: usage: fg [job_spec]
-./jobs.tests: line 122: bg: -s: invalid option
+./jobs.tests: line 132: bg: -s: invalid option
 bg: usage: bg [job_spec ...]
-./jobs.tests: line 127: disown: -s: invalid option
+./jobs.tests: line 137: disown: -s: invalid option
 disown: usage: disown [-h] [-ar] [jobspec ... | pid ...]
-./jobs.tests: line 131: disown: %1: no such job
-./jobs.tests: line 134: disown: %2: no such job
-./jobs.tests: line 137: disown: @12: no such job
+./jobs.tests: line 141: disown: %1: no such job
+./jobs.tests: line 144: disown: %2: no such job
+./jobs.tests: line 147: disown: @12: no such job
 wait-for-non-child
-./jobs.tests: line 140: wait: pid 1 is not a child of this shell
+./jobs.tests: line 150: wait: pid 1 is not a child of this shell
 127
 3 -- 1 2 3 -- 1 - 2 - 3
 [1]   Running                 sleep 300 &
@@ -90,8 +91,8 @@ running jobs:
 [1]   Running                 sleep 300 &
 [2]-  Running                 sleep 350 &
 [3]+  Running                 sleep 400 &
-./jobs.tests: line 157: kill: %4: no such job
-./jobs.tests: line 159: jobs: %4: no such job
+./jobs.tests: line 167: kill: %4: no such job
+./jobs.tests: line 169: jobs: %4: no such job
 current job:
 [3]+  Running                 sleep 400 &
 previous job:
@@ -121,3 +122,9 @@ done
 after KILL -STOP, foregrounding %1
 sleep 4
 done
+./jobs.tests: line 229: jobs: -q: invalid option
+jobs: usage: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
+./jobs.tests: line 231: suspend: -z: invalid option
+suspend: usage: suspend [-f]
+./jobs.tests: line 232: suspend: cannot suspend: no job control
+./jobs.tests: line 233: suspend: cannot suspend: no job control
index 605449aad7b1cc1ad47b6f5ea1331276cc15bd8b..4fa19b7cc45c0a858b6642d6c6df335b878ee1e2 100644 (file)
@@ -35,6 +35,9 @@ ${THIS_SH} ./jobs7.sub
 # more disown -h tests
 ${THIS_SH} ./jobs8.sub
 
+# wait interrupted by signal for which a trap has been set
+${THIS_SH} ./jobs9.sub
+
 jobs
 echo $?
 
@@ -42,16 +45,23 @@ echo $?
 wait %1
 
 # make sure we can't fg a job started when job control was not active
-sleep 30 &
+sleep 20 &
 pid=$!
 fg %1
 # make sure the killed processes don't cause a message
 exec 5>&2
 exec 2>/dev/null
-kill -n 9 $pid
-wait    # make sure we reap the processes while stderr is still redirected
+kill -n9 $pid
+wait $pid   # make sure we reap the processes while stderr is still redirected
+
+sleep 30 &
+pid2=$!
+kill -sHUP $pid2
+wait $pid2
 exec 2>&5
+unset -v pid pid2
 
+# 
 echo wait-for-pid
 sleep 4 &
 wait $!
@@ -210,5 +220,14 @@ kill -STOP %1
 sleep 2        # give time for the shell to get the stop notification
 echo after KILL -STOP, foregrounding %1
 fg %1
-
 echo done
+
+# these are all errors
+
+set +m
+
+jobs -q
+
+suspend -z
+suspend
+suspend --
diff --git a/tests/jobs9.sub b/tests/jobs9.sub
new file mode 100644 (file)
index 0000000..74d2d2c
--- /dev/null
@@ -0,0 +1,14 @@
+# When the shell is waiting, by means of the wait utility, for asynchronous
+# commands to complete, the reception of a signal for which a trap has been
+# set shall cause the wait utility to return immediately with an exit status
+# >128, immediately after which the trap associated with that signal shall be
+# taken. 
+
+trap 'echo got $(kill -l $BASH_TRAPSIG)' USR1
+
+sleep 10 &
+( sleep 2 ; kill -USR1 $$ ) &
+
+# should be interrupted by the signal
+wait
+[[ $? -gt 128 ]] || echo 'wait status not greater than 128'
index f9d669ddc07cf1daca35740009572be4c51f363c..2fc5e8e6440f3c1c5acc1270b3276b3e0e872379 100644 (file)
@@ -65,6 +65,9 @@ echo $? -- ${PIPESTATUS[@]}
 
 true | binfalse | true
 echo $? -- ${PIPESTATUS[@]}
+
+binfalse | true | true | VAR=42
+echo $? $VAR
 set +o pipefail
 
 ${THIS_SH} ./lastpipe1.sub
index 419bbe1408697385777c4c23aea2c58df1dd656e..31b84afd321e30f42cbfb9e087982daa2b589193 100644 (file)
@@ -533,17 +533,18 @@ declare -a array=([0]="zero")
 declare -a array=([0]="one" [1]="two" [2]="three")
 declare -ai a=([0]="5")
 declare -ai a=([0]="6")
+declare -ai a=([0]="42")
 declare -ai a=([0]="1")
-./nameref23.sub: line 15: declare: b: not found
+./nameref23.sub: line 16: declare: b: not found
 declare -ai a=([0]="1")
 declare -- b="1"
 declare -ai a=([0]="1")
 declare -- b="11"
 declare -ai a=([0]="1")
 declare -- b="110"
-./nameref23.sub: line 25: declare: `1': invalid variable name for name reference
+./nameref23.sub: line 26: declare: `1': invalid variable name for name reference
 declare -ai a=([0]="1")
-./nameref23.sub: line 27: declare: b: not found
+./nameref23.sub: line 28: declare: b: not found
 declare -ai a=([0]="4")
 declare -in b="a[0]"
 declare -ai a=([0]="6")
index 358c381e1bc22c3bc6f7ec7d7e94cef66e4fed1b..f751bb6ea3bbf9699ca9066a5c0c594f1b6fdbf3 100644 (file)
@@ -5,6 +5,7 @@ declare -n b='a[0]'
 b+=1 ; declare -p a
 
 declare b+=1 ; declare -p a
+declare b=42 ; declare -p a
 
 unset a b
 unset -n b
index 8aa4b32489cf4fabf66d552ab10218cd97b91192..971bba34cfbd814c1cef75905d887a0ac7eb8797 100644 (file)
@@ -626,7 +626,6 @@ bash: line 1: ${x@C}: bad substitution
 <'ab cd'> 
 <'4'> <'ab cd'> 
 <> 
-argv[1] = <host(2)[5.3]$ >
 <      
 >
 <' \t\n'>
@@ -649,7 +648,15 @@ i
 declare -i foo
 A
 declare -A foo
-./new-exp10.sub: line 118: ${V@}: bad substitution
+LOWER
+Lower
+argv[1] = <host(2)[5.3]$ >
+argv[1] = <~$ >
+argv[1] = <^A[0]~$ >
+argv[1] = <^A^G^B[0:1]~\$ >
+argv[1] = </ bash$ >
+argv[1] = <1^J/ bash$ >
+./new-exp10.sub: line 149: ${V@}: bad substitution
 abcxxxdef
 abcÃ¥def
 ḅć
index 5b199d4f5c943df04542da8dc0a1b04eb1f0605f..03f1b695b04c8d5042aeb6f4a2c687b5612d0e77 100644 (file)
@@ -42,13 +42,6 @@ printf "<%s> " "${z@Q}"      ; echo  # empty string?
 
 recho ${z@Q}           # this disappears
 
-#
-HOST=host
-SHELL_LEVEL=2
-NPS1='\[\]${HOST}($SHELL_LEVEL)[\v]\$ '
-
-recho "${NPS1@P}"
-
 #
 D=' \t\n'
 printf "<%s>" "${D@E}" ; echo
@@ -114,5 +107,43 @@ echo ${foo@a}
 
 declare -p foo
 
+unset -v foo
+foo=lower
+echo ${foo@U}
+echo ${foo@u}
+
+# framework for testing prompt expansions using @P transformation
+cd /tmp
+
+HOST=host
+SHELL_LEVEL=2
+HOME=$PWD
+
+NPS1='\[\]${HOST}($SHELL_LEVEL)[\v]\$ '
+recho "${NPS1@P}"
+
+NPS1='\[\]\W\$\040'
+recho "${NPS1@P}"
+
+NPS1='\[\001\][\j]\w\$\040'
+recho "${NPS1@P}"
+
+NPS1='\[\a\][\j:\!]\w\\\$\040'
+set -o emacs
+recho "${NPS1@P}"
+set +o emacs
+
+cd /
+# no longer abbreviate as ~
+NPS1='\W \s\$\040'
+recho "${NPS1@P}"
+
+set -o posix
+NPS1='!\n\W \s\$\040'
+recho "${NPS1@P}"
+
+cd $OLDPWD
+
+# this must be last, fatal error
 V=42
 echo ${V@}     # error
index b5765c918a81535da085dc1189752ee2cb9f2178..9253ef6159b83765e6e9b37779a717a6fb636d23 100644 (file)
@@ -1,5 +1,10 @@
 printf: usage: printf [-v var] format [arguments]
 printf: usage: printf [-v var] format [arguments]
+./printf.tests: line 26: printf: -x: invalid option
+printf: usage: printf [-v var] format [arguments]
+./printf.tests: line 29: printf: `invalid-var': not a valid identifier
+abc
+./printf.tests: line 30: printf: `invalid-var': not a valid identifier
 10
        one
 one\ctwo
@@ -33,7 +38,7 @@ A7
 --\"abcd\"--
 --\'abcd\'--
 --a\x--
-./printf.tests: line 105: printf: missing hex digit for \x
+./printf.tests: line 112: printf: missing hex digit for \x
 --\x--
 ----
 ----
@@ -94,12 +99,12 @@ A7
 26
 26
 26
-./printf.tests: line 229: printf: `%10': missing format character
-./printf.tests: line 230: printf: `M': invalid format character
-ab./printf.tests: line 233: printf: `y': invalid format character
-./printf.tests: line 236: printf: GNU: invalid number
+./printf.tests: line 236: printf: `%10': missing format character
+./printf.tests: line 237: printf: `M': invalid format character
+ab./printf.tests: line 240: printf: `y': invalid format character
+./printf.tests: line 243: printf: GNU: invalid number
 0
-./printf.tests: line 237: printf: GNU: invalid number
+./printf.tests: line 244: printf: GNU: invalid number
 0
 -
 (foo )(bar )
@@ -152,9 +157,9 @@ b
 xx
 xx
 <   ><   >
-./printf.tests: line 341: printf: 9223372036854775825: Result too large
+./printf.tests: line 348: printf: 9223372036854775825: Result too large
 9223372036854775807
-./printf.tests: line 342: printf: -9223372036854775815: Result too large
+./printf.tests: line 349: printf: -9223372036854775815: Result too large
 -9223372036854775808
        one
 one\ctwo
@@ -325,3 +330,15 @@ hello  --
 hello --
 123 --
 6 --
+à²M-^Gಳಿà²M-^Uà³M-^Fà²M-^Wಳà³M-^A
+à²M-^Gಳ
+à²M-^G
+à²M-^Gಳ
+  à²M-^Gಳ
+à²M-^Gಳ  ---
+à²M-^G
+à²M-^G
+à²M-^G
+à²M-^G
+   à²M-^G
+à²M-^G   ---
index ee668cc9455dfcdab1df039462b9bc06d2d58984..f334f8b1e0ad0c9b759ca3db63f1130b2dba1bd2 100644 (file)
@@ -22,6 +22,13 @@ printf --
 printf ""
 printf -- ""
 
+# this is an error
+printf -x
+
+# these are errors
+printf -v invalid-var 'abc\n'
+printf '%s\n%n' abc invalid-var
+
 # in the future this may mean to put the output into VAR, but for
 # now it is an error
 # 2005-03-15 no longer an error
@@ -341,9 +348,13 @@ TOOSMALL=-9223372036854775815
 printf '%d\n' "$TOOBIG"
 printf '%d\n' "$TOOSMALL"
 
+# invalid variable name
+
 # tests variable assignment with -v
 ${THIS_SH} ./printf1.sub
 ${THIS_SH} ./printf2.sub
 ${THIS_SH} ./printf3.sub
 ${THIS_SH} ./printf4.sub
 ${THIS_SH} ./printf5.sub
+# multibyte characters with %ls/%S and %lc/%C
+${THIS_SH} ./printf6.sub
index 7a18a5c6c84296b0eb830a8fe2819e4c6a554d15..38c5c4e4138ae49269e8dec884498229cc2808c5 100644 (file)
@@ -162,7 +162,7 @@ printf "%s"  "$vv"
 printf -v vv "%*b\n" 6 4.4BSD
 printf "%s"  "$vv"
 
-# we handle this crap with homemade code in printf -v vv.def
+# we handle this crap with homemade code in printf
 printf -v vv "%10b\n" 4.4BSD
 printf "%s"  "$vv"
 printf -v vv -- "--%-10b--\n" 4.4BSD
@@ -228,7 +228,7 @@ printf "%s"  "$vv"
 printf -v vv "%6.2g\n" 4.2
 printf "%s"  "$vv"
 
-# test some of the more esoteric features of POSIX.1 printf -v vv
+# test some of the more esoteric features of POSIX.1 printf
 printf -v vv "%d\n" "'string'"
 printf "%s"  "$vv"
 printf -v vv "%d\n" '"string"'
@@ -297,7 +297,7 @@ printf "%s"  "$vv"
 printf -v vv "%10"
 printf -v vv "ab%Mcd\n"
 
-# this caused an infinite loop in older versions of printf -v vv
+# this caused an infinite loop in older versions of printf
 printf -v vv "%y" 0
 
 # these should print a warning and `0', according to POSIX.2
diff --git a/tests/printf6.sub b/tests/printf6.sub
new file mode 100644 (file)
index 0000000..09ee689
--- /dev/null
@@ -0,0 +1,21 @@
+# test %ls and %lc with multibyte characters
+
+V=ಇಳಿಕೆಗಳು
+V2=${V:0:2}
+V3=${V:0:1}
+
+printf "%ls\n" "$V"
+printf "%ls\n" "$V2"
+printf "%lc\n" "$V"
+printf "%.2ls\n" "$V"
+
+printf "%4.2ls\n" "$V"
+printf "%-4.2ls---\n" "$V"
+
+printf "%ls\n" "$V3"
+printf "%S\n" "$V3"
+printf "%lc\n" "$V3"
+printf "%C\n" "$V3"
+
+printf "%4.2lc\n" "$V3"
+printf "%-4.2lc---\n" "$V3"
index 5f672679452d0d69ffa70f73f3d5724f814fe241..557d47e63113a6438ab00550a81b06fbde73154e 100644 (file)
@@ -45,6 +45,7 @@ unset or null 3
 ./read2.sub: line 45: read: -3: invalid timeout specification
 1
 
+abcde
 abcde
 abcde
 ./read3.sub: line 17: read: -1: invalid number
@@ -53,6 +54,7 @@ defg
 ab
 abc
 #
+0
 while read -u 3 var
 do
 echo "$var"
index 9d666c4be13a03606dd7d2b3ac58061e9ee68f14..bc26ac6d6d09dfdd9af6f9710a4018b7314d9b8e 100644 (file)
@@ -70,3 +70,8 @@ done
 
 cd $OLDPWD
 rm -f $TMPDIR/a.pipe           # paranoia
+
+TMOUT=.001
+read a <<<abcde
+echo $a
+
index 8a24040138c65dc1086b9d62b697387415b2809d..7bd3d0e084e7ff196e43f582efcf89c685512a42 100644 (file)
@@ -36,3 +36,7 @@ echo abc | {
 
 read -n 1 < $0
 echo "$REPLY"
+
+# succeed if fd is valid
+read -n 0 var <<<'abc'
+echo $?
index d836f0850929d489f17a33f7a72c3994cb3561d4..b54efeb30372d208484742baba05e743bcefd190 100644 (file)
@@ -1,13 +1,13 @@
 abc
-./redir.tests: line 28: /tmp/redir-test: cannot overwrite existing file
+./redir.tests: line 31: /tmp/redir-test: cannot overwrite existing file
 abc
 def
 def
 ghi
-./redir.tests: line 49: -1: ambiguous redirect
-./redir.tests: line 50: exec: -1: invalid option
+./redir.tests: line 52: -1: ambiguous redirect
+./redir.tests: line 53: exec: -1: invalid option
 exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
-./redir.tests: line 55: $z: ambiguous redirect
+./redir.tests: line 58: $z: ambiguous redirect
 Point 1
 Point 2
 to a
@@ -48,7 +48,7 @@ kl
 ab
 cd
 cd
-./redir.tests: line 181: redir1.*: No such file or directory
+./redir.tests: line 184: redir1.*: No such file or directory
 #   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
 #   the Free Software Foundation, either version 3 of the License, or
@@ -167,3 +167,18 @@ foo
 foo
 ./redir11.sub: line 75: 42: No such file or directory
 42
+./redir12.sub: line 27: unwritable-file: Permission denied
+1 x =
+./redir12.sub: line 31: unwritable-file: cannot overwrite existing file
+1 x =
+./redir12.sub: line 34: unwritable-file: Permission denied
+1 x =
+./redir12.sub: line 38: unreadable-file: Permission denied
+./redir12.sub: line 44: unwritable-file: Permission denied
+got error ERR
+after ERR trap: 1
+./redir12.sub: line 48: unwritable-file: Permission denied
+./redir12.sub: line 53: unreadable-file: Permission denied
+got error ERR
+./redir12.sub: line 56: unreadable-file: Permission denied
+/tmp
index ca9eba9d0a3fd96f518661091e946479b00ba030..a17da0fc367cf8e8f50e0653eee10ec514318ede 100644 (file)
@@ -19,6 +19,9 @@ export LANG=C
 # catch-all for remaining untested redirection stuff
 set +o posix
 
+# this should succeed silently
+cat </dev/null >/dev/null 2>&1
+
 echo abc > /tmp/redir-test
 cat /tmp/redir-test
 
@@ -205,7 +208,7 @@ ${THIS_SH} ./redir7.sub
 ${THIS_SH} ./redir8.sub
 
 exec 9>&2
-command exec 2>$TMPDIR/foo-$$
+command exec 2>>$TMPDIR/foo-$$
 echo whatsis >&2
 echo cat /tmp/foo
 cat $TMPDIR/foo-$$
@@ -214,7 +217,8 @@ exec 2>&9
 exec 9>&-
 
 ${THIS_SH} ./redir9.sub
-
 ${THIS_SH} ./redir10.sub
-
 ${THIS_SH} ./redir11.sub
+${THIS_SH} ./redir12.sub
+
+${THIS_SH} < ./redir13.in
index 66376235a8fa8ec9a41c5b58431371cc7dfafad5..7e1f3eea287e54fa4114332d92708e3d1b496efd 100644 (file)
@@ -1,5 +1,59 @@
-umask 0777
-cat <<'  HERE'
-look ma, no permissions
-HERE
-cat <<<"it's a miracle"
+#   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
+#   the Free Software Foundation, either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# failing redirections with various compound commands and their effect on
+# set -e and the ERR trap
+
+: ${TMPDIR:=/tmp}
+TDIR=$TMPDIR/redir-fail-$$
+mkdir $TDIR
+cd $TDIR || exit 1
+
+touch unwritable-file unreadable-file
+chmod a-w unwritable-file
+chmod a-r unreadable-file
+
+while [ -z "x" ]; do x=4; done > unwritable-file
+echo $? x = $x
+
+set -o noclobber
+while [ -z "x" ]; do x=4; done > unwritable-file
+echo $? x = $x
+# test priority of noclobber and permission denied
+while [ -z "x" ]; do x=4; done >| unwritable-file
+echo $? x = $x
+set +o noclobber
+
+while [ -z "x" ]; do x=4; done < unreadable-file
+
+# ERR trap is not fatal unless set -e is also enabled
+(trap 'echo got error ERR' ERR
+# have to undo redirections on redirection error
+while [ -z "x" ]; do x=4; done </dev/null > unwritable-file
+echo after ERR trap: $?)
+
+(set -e
+for f in 1 2; do x=4; done > unwritable-file
+echo after set -e: $?)
+
+(set -e
+trap 'echo got error ERR' ERR
+for f in 1 2; do x=4; done < unreadable-file
+echo after set -e with ERR trap: $?)
+
+# the subshell never gets executed
+( echo wow this is bad ) < unreadable-file
+
+cd $OLDPWD
+rm -rf $TDIR
diff --git a/tests/redir13.in b/tests/redir13.in
new file mode 100644 (file)
index 0000000..bbcf84c
--- /dev/null
@@ -0,0 +1,5 @@
+# this should be used as standard input to the shell
+exec 4<&0
+cd /tmp
+command pwd
+exec 4<&-
index 5f64049b69c88af693db3033a7022d46e276c0a8..e9a4ae6a144b997b8781ae9a410a7a50913b0447 100644 (file)
@@ -8,12 +8,13 @@
 ./rsh.tests: line 26: PATH: readonly variable
 ./rsh.tests: line 27: SHELL: readonly variable
 ./rsh.tests: line 28: /bin/sh: restricted: cannot specify `/' in command names
-./rsh.tests: line 30: .: ./source.sub3: restricted
-./rsh.tests: line 33: /tmp/restricted: restricted: cannot redirect output
-./rsh.tests: line 37: /tmp/restricted: restricted: cannot redirect output
-./rsh.tests: line 42: command: -p: restricted
-./rsh.tests: line 44: set: +r: invalid option
+./rsh.tests: line 29: /bin/cat: restricted: cannot specify `/' in command names
+./rsh.tests: line 31: .: ./source.sub3: restricted
+./rsh.tests: line 34: /tmp/restricted: restricted: cannot redirect output
+./rsh.tests: line 38: /tmp/restricted: restricted: cannot redirect output
+./rsh.tests: line 43: command: -p: restricted
+./rsh.tests: line 45: set: +r: invalid option
 set: usage: set [-abefhkmnptuvxBCEHPT] [-o option-name] [--] [-] [arg ...]
-./rsh.tests: line 45: set: restricted: invalid option name
-./rsh.tests: line 47: exec: restricted
+./rsh.tests: line 46: set: restricted: invalid option name
+./rsh.tests: line 48: exec: restricted
 ./rsh.tests: after exec
index 0d06fa1e5c5fa472a101ee8afae5363dc999da04..491608bffd519cea0f27cb13a87a40a5bfa450c8 100644 (file)
@@ -26,6 +26,7 @@ cd /
 PATH=$PATH:/usr/local/bin
 SHELL=/bin/sh
 /bin/sh -c 'echo /bin/sh executed'
+/bin/cat foo | cat
 
 . ./source.sub3
 
index b999e6980776eb73e480dc10530669009f9b9e0e..e6e2c49f8c45545eb0bd8d1bd2f6a0274c9eeaec 100644 (file)
@@ -2,7 +2,7 @@
 #$Id: run-set-x,v 1.1 2002/12/09 13:12:37 rockyb Exp $
 
 TEST_NAME='set-x'
-TEST_FILE="/tmp/${TEST_NAME}.check"
+TEST_FILE="${BASH_TSTOUT}"
 ${THIS_SH} ./${TEST_NAME}.tests > $TEST_FILE 2>&1 < /dev/null
 set -f
 diff $TEST_FILE ${TEST_NAME}.right && rm -f $TEST_FILE
index 230b1df118d09171e8d2c7bf025112f34af91709..7b14626d24118a0e2e3a6f0d780fcde3991dbbd5 100644 (file)
@@ -34,10 +34,12 @@ onetwo
 + echo onetwo
 onetwo
 + set +x
+./set-x1.sub: line 18: BASH_XTRACEFD: 4: invalid value for trace file descriptor
 1
 2
 3
 4
++ exec
 + for f in a b c d e
 + echo a
 a
@@ -61,3 +63,10 @@ TRACEFILE:
 + echo 4
 + unset BASH_XTRACEFD
 =====
++ metas=(\| \& \; \( \) \< \> ' ' '    ' '
+')
++ n=($@)
++ : '|' '&' ';' '(' ')' '<' '>' ' ' $'\t' $'\n'
++ DEFAULT_IFS=$' \t\n'
++ set +x
+declare -a metas=([0]="|" [1]="&" [2]=";" [3]="(" [4]=")" [5]="<" [6]=">" [7]=" " [8]=$'\t' [9]=$'\n')
index 74523bd48c5a106319be142ed4e16c5c70c77ce8..b0b2cccacfc7290ec15b8a6a41ed54bd848d61e7 100644 (file)
@@ -38,3 +38,6 @@ set +x
 
 # test BASH_XTRACEFD
 ${THIS_SH} ./set-x1.sub
+
+# compound assignment printing
+${THIS_SH} ./set-x2.sub
index cb7fa8270f467d41b0265a7c5c44831807de0495..0426526830fc35e5ba74bce9b8a184561703ae22 100644 (file)
@@ -15,6 +15,8 @@
 TRACEFILE=$TMPDIR/bash-trace-$$
 trap 'rm -f $TRACEFILE' 0 1 2 3 6 15
 
+BASH_XTRACEFD=4                # error, invalid FD
+
 exec 4>$TRACEFILE
 BASH_XTRACEFD=4
 
@@ -26,6 +28,7 @@ echo 3
 echo 4
 
 unset BASH_XTRACEFD
+exec 4<&-              # no unset hooks yet
 
 for f in a b c d e; do echo $f ; done
 
diff --git a/tests/set-x2.sub b/tests/set-x2.sub
new file mode 100644 (file)
index 0000000..ca27cb3
--- /dev/null
@@ -0,0 +1,15 @@
+declare -a metas
+set a b c
+
+set -x
+# some time we will have better compound assignment printing (after expansion)
+metas=( \|  \& \; \( \) \< \> $' ' $'\t' $'\n' )
+n=( $@ )
+
+# like regular expansions
+: "${metas[@]}"
+
+DEFAULT_IFS=$' \t\n'
+
+set +x
+declare -p metas
index 1301c0b07d5c570fb56c01d068d6ffde372ff0bd..dc7dcb578856cdda5362066eb80a3c3dd1023848 100644 (file)
@@ -1,4 +1,5 @@
 ~chet
+~chet/foo
 /usr/xyz/foo
 ~chet/foo
 ~chet/foo
index 20268a731bdfd43280c9d08d3d5f8739fbf5758e..f3228b085b75ea78b0503d8e6107281973877677 100644 (file)
@@ -21,6 +21,7 @@ set +o posix
 HOME=/usr/xyz
 SHELL=~/bash
 echo ~ch\et
+echo ~ch\et/foo
 echo ~/"foo"
 echo "~chet"/"foo"
 echo \~chet/"foo"
index f47cfc02985a89176ca9b8077c207efe2c269ebc..9c4e4a34db35c235ec65c96dfb6fb4df28433a9f 100644 (file)
 #   You should have received a copy of the GNU General Public License
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
+: ${THIS_SH:=./bash}
+
+printf "time -c : :\n"
+time ${THIS_SH} -c :
+
 printf "time /dev/null:\n"
 time ${THIS_SH} /dev/null
 
@@ -27,10 +32,17 @@ time ${THIS_SH} /dev/null
 
 printf "\nksh time /dev/null:\n"
 TIMEFORMAT=$'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS'
-time ${THIS_SH} /dev/null
+time ${THIS_SH} < /dev/null
+
+time (:)
+(time :)
+
+times -x
 
 printf "\ntimes:\n"
 times
+echo
+times --
 
 printf "\ntime standalone:\n"
 { time ; echo after; } |& wc -l
index 7eab47520a4e7b5322adfd42bc46b05f4ea9d656..4f32253494eedba44261b104ca242fa976bc968f 100644 (file)
@@ -132,4 +132,6 @@ trap: usage: trap [-Plp] [[action] signal_spec ...]
 trap -- 'echo exiting' EXIT
 trap -- 'echo aborting' SIGABRT
 trap -- 'echo caught a child death' SIGCHLD
+trap: usage: trap [-Plp] [[action] signal_spec ...]
+echo exiting
 exiting
index 8f4a09559da36e725eb6e929da7d82ce55284f72..8e38cb359448573ee163dcb7512eeb175f2f995c 100644 (file)
@@ -128,3 +128,12 @@ trap
 
 trap - SIGCHLD
 wait
+
+trap 512       # error
+trap 0         # revert
+trap -p EXIT
+
+trap 'echo exiting' 0
+trap -P EXIT
+
+exit
index a3fd4b9b552f0b278f09dbd6870db6e433a0601f..e7ecbe24963a6f87e6aeeee4e117eefc35507306 100644 (file)
@@ -139,3 +139,4 @@ cat is aliased to `echo cat'
 /bin/cat
 break is a shell builtin
 break is a special shell builtin
+./e
index 1bd879e09619ea59ad795ea9f068e48a69e31356..42489b055e1b6bf13e4db3b53f7bc549a6cb20f9 100644 (file)
@@ -14,6 +14,7 @@
 
 # make sure . is not in $PATH
 PATH=/bin:/usr/bin:/usr/local/bin
+OPATH=$PATH
 
 # test type -P
 
@@ -37,5 +38,22 @@ type -P cat
 type break
 set -o posix; type break; set +o posix
 
+# test with PATH empty and unset
+realdir=$(pwd -P)
+touch e ; chmod +x e
+
+PATH=
+type -p e
+unset PATH
+z=$(type -p e)
+
+case $z in
+*/e)   ;;
+*)     echo 'type: unset PATH does not prefix with physical path to $PWD' ;;
+esac
+PATH=$OPATH
+
+rm -f e
+
 cd "$OLDPWD"
 rm -rf "$TDIR"
index 48b0abd28c780958f01e927a4fcef13d970a7c11..f1af2ab17886220ebd2f3d0ddb3bdbc219dbf267 100644 (file)
@@ -186,6 +186,12 @@ declare -a a=([0]="X" [1]="Y")
 declare -a s=([0]="X" [1]="Y")
 declare -a a=([0]="XY")
 declare -a s=([0]="XY")
+declare -A v=([1]="one" [0]="7" )
+declare -a v=([0]="7" [1]="1")
+./varenv14.sub: line 77: declare: array: cannot convert indexed to associative array
+declare -a array=([0]="1" [1]="2" [2]="3" [3]="list" [4]="of" [5]="four" [6]="words")
+./varenv14.sub: line 85: declare: assoc: cannot convert associative to indexed array
+declare -A assoc=([four]="words" [two]="2" [three]="3" [one]="1" [list]="of" )
 f: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
 f1: after: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 done: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
@@ -263,6 +269,7 @@ ignoreeof           on
 ignoreeof              off
 ignoreeof              on
 10
+local -
 match 1
 trap -- 'echo trap:$FUNCNAME' EXIT
 trap:f
index 091c47004a684035fa2b282bf7aebd3fcec8f36b..f943d6e17222488563ecd178b8b45ae0c2f53f5f 100644 (file)
@@ -44,3 +44,46 @@ f
 
 f() { local -a a+=Y s+=Y; declare -p a s; }
 f
+
+# inherit from different array types/variable types
+unset -v v
+unset -f f
+
+v=7
+
+f()
+{
+       declare -A v
+       v+=(1 one)
+       declare -p v
+}
+f
+
+f()
+{
+       declare -a v
+       v+=(1)
+       declare -p v
+}
+f
+
+unset -v array assoc
+
+declare -a array=(1 2 3)
+declare -A assoc=(one 1 two 2 three 3)
+
+f()
+{
+       declare -A array
+       array+=(list of four words)
+       declare -p array
+}
+f
+
+f()
+{
+       declare -a assoc
+       assoc+=(list of four words)
+       declare -p assoc
+}
+f
index 613e475924f565e95e01c39766e2a1a221d2591d..45d2d86c1ff59cbce1ba3842600afd0760f91080 100644 (file)
@@ -34,6 +34,7 @@ f()
        local -
        set -m -H +B
        set -u
+       local -p        # make sure it prints `local -'
 }
 
 before="$-|$SHELLOPTS"
index f14fa5eff78c24424f7f53f87f69b7f20afe0f8e..d0a76a48aa65dd4875acb17e509a255c20ae996c 100644 (file)
@@ -5,7 +5,7 @@ foo 3
 bar is a function
 bar () 
 { 
-    exec {v}> $TMPFILE;
+    exec {v}>> $TMPFILE;
     echo $v
 }
 ./vredir.tests: line 19: v: readonly variable
@@ -16,7 +16,7 @@ bar ()
 bar is a function
 bar () 
 { 
-    exec {v}> $TMPFILE;
+    exec {v}>> $TMPFILE;
     echo $v
 }
 10
@@ -34,6 +34,21 @@ EOF
 
     echo $v
 }
+11
+line 1
+line 2
+line 3
+bar is a function
+bar () 
+{ 
+    exec {v}<<-EOF
+line 1
+line 2
+line 3
+EOF
+
+    echo $v
+}
 10
 foo 1
 foo 2
@@ -74,6 +89,9 @@ swizzle ()
     exec {stdin}<&$fd0;
     exec {stdout}>&$fd1
 }
+10 11
+10 11
+./vredir4.sub: line 51: ${output}: Bad file descriptor
 12 10
 a
 a
index 2a6cc18a3e9d60acd001e88d6fde722d5b3e4856..f2c5e4dd4fa8b9c82b66ecf250977bc13c651dd7 100644 (file)
@@ -16,7 +16,7 @@ TMPFILE=$TMPDIR/foo
 
 bar()
 {
-exec {v}>$TMPFILE
+exec {v}>>$TMPFILE
 echo $v
 }
 
index 484f313b4a26b0034ccb84fa9081041b54d7d801..d09a01569e28437d09100229b2c584e03ce2855c 100644 (file)
@@ -25,6 +25,23 @@ bar
 
 cat <&$v
 
+type bar
+unset -f bar
+
+bar()
+{
+exec {v}<<-EOF
+       line 1
+       line 2
+       line 3
+EOF
+echo $v
+}
+
+bar
+
+cat <&$v
+
 type bar
 
 exit 0
index f861bcfc8d02c3cf235619664804776f088c3da5..7a4b091b87b4132371413f09688fb8b8a3be6e77 100644 (file)
@@ -32,4 +32,22 @@ echo $line >&$stdout
 
 type swizzle
 
+exec {stdin}<&-
+exec {stdout}>&-
+
+stdin=-1 stdout=-1
+
+declare -n stdin=input
+declare -n stdout=output
+
+swizzle
+echo ${input} ${output}
+echo ${stdin} ${stdout}
+
+exec {stdin}<&-
+exec {stdout}>&-
+
+# this should be an error
+echo invalid fd >&${output}
+
 exit 0
index 0f76f404b075ca7f641fbb9468dd176190a96345..bd402d48e9b08184d8585d1f3762e9aa96b951f2 100644 (file)
@@ -33,4 +33,10 @@ echo $line >&$stdout
 
 type swizzle
 
+exec {fd[0]}<&-
+exec {fd[1]}<&-
+
+exec {stdin}<&-
+exec {stdout}>&-
+
 exit 0