]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20141226 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 12 Jan 2015 15:57:11 +0000 (10:57 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 12 Jan 2015 15:57:11 +0000 (10:57 -0500)
18 files changed:
CWRU/CWRU.chlog
MANIFEST
builtins/common.h
builtins/declare.def
builtins/read.def
builtins/setattr.def
jobs.c
po/._fr.po
shell.c
tests/appendop.right
tests/array.right
tests/array.tests
tests/array19.sub [new file with mode: 0644]
tests/assoc.right
tests/builtins.right
tests/dollar.right
tests/herestr.right
tests/varenv.right

index b431ea1ddac54210444de52079cc5df417b89250..2491bd5734e46612d625d461c6e50ec282225775 100644 (file)
@@ -7613,7 +7613,7 @@ builtins/declare.def
          is of the form (word) and is assigned to an array variable like so:
          declare -x var=$value.  Bug reported by Stephane Chazelas
          <stephane.chazelas@gmail.com>. Will eventually be contingent on
-         compatibility level > 43, but not there yet
+         compatibility level > 43, but not there yet. TENTATIVE
 
                                   12/15
                                   -----
@@ -7637,6 +7637,8 @@ execute_cmd.c
          like `declare -al foo=(UPONE UPTWO UPTHREE)' not being lowercased on
          assignment reported by Linda Walsh <bash@tlinx.org>
 
+
+
                                   12/18
                                   -----
 lib/readline/readline.c
@@ -7654,3 +7656,46 @@ lib/readline/readline.c
          most recently identified by Jiri Kukacka <jiri.kukacka@orcle.com>,
          it has come up in the past
 
+                                  12/21
+                                  -----
+builtins/declare.def
+       - declare_internal: keep track of whether or not an assignment statement
+         argument to declare is an array subscript assignment; need to
+         differentiate assignments from straight declarations (declare a[4])
+         which are accepted for backwards compatibility
+       - assignment statements like declare a[2]=foo are now treated as
+         straight subscript assignment statements if a already exists as an
+         array variable
+       - declare foo='(1 2 3)' is treated as an assignment to foo[0] if foo
+         exists and is an array, just as it would be if it were an assignment
+         statement and `declare' was not present.  All this from a proposal
+         by Stephane Chazelas <stephane.chazelas@gmail.com>
+
+                                  12/22
+                                  -----
+builtins/read.def
+       - read_tty_modified: function to tell the rest of the shell if the
+         read builtin has modified the tty
+       - read_builtin: make sure to initialize terminating signals before
+         installing a SIGALRM signal handler in case we modify the tty as
+         well as ask for a timeout; the subsequent call to
+         initialize_terminating_signals would overwrite the read-builtin-
+         local SIGALRM handler
+
+builtins/common.h
+       - read_tty_modified: new extern declaration
+
+shell.c
+       - exit_shell: if read_tty_modified() returns true, call read_tty_cleanup
+         to undo the terminal modifications. Extension of previous fixes;
+         fixes bug with read -s reported by Richard W. Marsden
+         <richard@marsden.nu>
+
+
+                                  12/23
+                                  -----
+builtins/setattr.def
+       - show_var_attributes: call print_array_assignment and print_assoc_assignment
+         with a `not quoted' flag so the assignment statements are not
+         surrounded by single quotes.  Caused changes to a lot of test output
+
index 30b82598e11d76e1a7dfea423df62ceed13f069c..cef374f8f825ee8df17d42dfb4fd286375fef934 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -833,6 +833,7 @@ tests/array15.sub   f
 tests/array16.sub      f
 tests/array17.sub      f
 tests/array18.sub      f
+tests/array19.sub      f
 tests/array-at-star    f
 tests/array2.right     f
 tests/assoc.tests      f
index aa08e5050a7e58acca6fb0197df76e2f92e04f92..35403cbf224cb57330067e0ae2a5b1b19ba5bfcd 100644 (file)
@@ -145,6 +145,7 @@ extern void builtin_help __P((void));
 
 /* Functions from read.def */
 extern void read_tty_cleanup __P((void));
+extern int read_tty_modified __P((void));
 
 /* Functions from set.def */
 extern int minus_o_option_value __P((char *));
index 639fa4e22b1ed81f8eaadf62427ce48758e8d4c4..53eaced333c2217e130942566aa4065df77a44b5 100644 (file)
@@ -558,12 +558,7 @@ declare_internal (list, local_var)
 #if 0  /* bash-4.4 */
              if (value[0] == '(' && value[vlen-1] == ')' && (shell_compatibility_level <= 43 || (wflags & W_COMPASSIGN)))
 #else
-#  if 0
-             if (value[0] == '(' && value[vlen-1] == ')' && (wflags & W_COMPASSIGN))
-#  else
-             /* This is the code as in bash-4.3 */
              if (array_exists == 0 && value[0] == '(' && value[vlen-1] == ')')
-#  endif
 #endif
                compound_array_assign = 1;
              else
index 6e7b6b4623cfd0ce52fa8306ad932c3f1647e042..56c23010bbe89c16e2511b672f39f5cac2c0e234 100644 (file)
@@ -439,6 +439,8 @@ read_builtin (list)
          retval = 128+SIGALRM;
          goto assign_vars;
        }
+      if (interactive_shell == 0)
+       initialize_terminating_signals ();
       old_alrm = set_signal_handler (SIGALRM, sigalrm);
       add_unwind_protect (reset_alarm, (char *)NULL);
 #if defined (READLINE)
@@ -997,6 +999,12 @@ read_tty_cleanup ()
     ttyrestore (&termsave);
 }
 
+int
+read_tty_modified ()
+{
+  return (tty_modified);
+}
+
 #if defined (READLINE)
 static rl_completion_func_t *old_attempted_completion_function = 0;
 static rl_hook_func_t *old_startup_hook;
index 24abf3d198bc3737a23edc049f40c3890b8b54f4..c5fe32ee92ff6d566d47f3fd028c4ad54998a95b 100644 (file)
@@ -1,7 +1,7 @@
 This file is setattr.def, from which is created setattr.c.
 It implements the builtins "export" and "readonly", in Bash.
 
-Copyright (C) 1987-2012 Free Software Foundation, Inc.
+Copyright (C) 1987-2014 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -452,9 +452,9 @@ show_var_attributes (var, pattr, nodefs)
   if (invisible_p (var) && (array_p (var) || assoc_p (var)))
     printf ("%s\n", var->name);
   else if (array_p (var))
-    print_array_assignment (var, 1);
+    print_array_assignment (var, 0);
   else if (assoc_p (var))
-    print_assoc_assignment (var, 1);
+    print_assoc_assignment (var, 0);
   else
 #endif
   /* force `readonly' and `export' to not print out function definitions
diff --git a/jobs.c b/jobs.c
index 681ec5bfe982480efa1dc0d37dcb452700ec86a9..56444e89d4000fa08586f12e67a2063ff5e0f54e 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -2492,7 +2492,7 @@ wait_for (pid)
         job to finish.  Otherwise, we are waiting for the child to finish.
         We check for JDEAD in case the job state has been set by waitchld
         after receipt of a SIGCHLD. */
-      if (job == NO_JOB)
+      if (job == NO_JOB)               /* XXX -- && pid != ANY_PID ? */
        job = find_job (pid, 0, NULL);
 
       /* waitchld() takes care of setting the state of the job.  If the job
index bac4217f65b1e771c27ac6253c6ca9732e75043d..9d1ac500a7fe78ddfd74dfd455452c49758627c0 100644 (file)
Binary files a/po/._fr.po and b/po/._fr.po differ
diff --git a/shell.c b/shell.c
index 5c19190723ee42a9887fc1d2cb6478db26e3474a..2382f773e4084de41118181608890d083c21a396 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -911,10 +911,13 @@ exit_shell (s)
   fflush (stdout);             /* XXX */
   fflush (stderr);
 
+  /* Clean up the terminal if we are in a state where it's been modified. */
 #if defined (READLINE)
   if (RL_ISSTATE (RL_STATE_TERMPREPPED) && rl_deprep_term_function)
     (*rl_deprep_term_function) ();
 #endif
+  if (read_tty_modified ())
+    read_tty_cleanup ();
 
   /* Do trap[0] if defined.  Allow it to override the exit status
      passed to us. */
index 2f1babe2db8525cd3680fd1b75b32814636cb570..f9609f841f1d9001c8a42005faab4edcf6326cb9 100644 (file)
 9
 16
 ./appendop.tests: line 84: x: readonly variable
-declare -A foo='([two]="baz" [three]="quux" [one]="bar" )'
-declare -A foo='([two]="baz" [0]="zero" [three]="quux" [one]="bar" )'
-declare -A foo='([two]="baz" [0]="zero" [three]="quux" [four]="four" [one]="bar" )'
-declare -ai iarr='([0]="3" [1]="2" [2]="3")'
-declare -ai iarr='([0]="3" [1]="2" [2]="3" [3]="4" [4]="5" [5]="6")'
+declare -A foo=([two]="baz" [three]="quux" [one]="bar" )
+declare -A foo=([two]="baz" [0]="zero" [three]="quux" [one]="bar" )
+declare -A foo=([two]="baz" [0]="zero" [three]="quux" [four]="four" [one]="bar" )
+declare -ai iarr=([0]="3" [1]="2" [2]="3")
+declare -ai iarr=([0]="3" [1]="2" [2]="3" [3]="4" [4]="5" [5]="6")
 25 25
 7 7
 14
index 9c17579b482000a3073b2e9f996bd293beba2e62..40e38b1021ce2894eb42e34bfc914a281f44ec3e 100644 (file)
@@ -6,13 +6,13 @@ abcde
 abcde
 abcde bdef
 abcde bdef
-declare -a BASH_ARGC='()'
-declare -a BASH_ARGV='()'
-declare -a BASH_LINENO='([0]="0")'
-declare -a BASH_SOURCE='([0]="./array.tests")'
-declare -a DIRSTACK='()'
+declare -a BASH_ARGC=()
+declare -a BASH_ARGV=()
+declare -a BASH_LINENO=([0]="0")
+declare -a BASH_SOURCE=([0]="./array.tests")
+declare -a DIRSTACK=()
 declare -a FUNCNAME
-declare -a a='([0]="abcde" [1]="" [2]="bdef")'
+declare -a a=([0]="abcde" [1]="" [2]="bdef")
 declare -a b
 declare -ar c
 abcde bdef
@@ -27,25 +27,25 @@ hello world
 3
 bdef hello world test expression test 2
 ./array.tests: line 76: readonly: `a[5]': not a valid identifier
-declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
+declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
 declare -ar c
-declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
+declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
 declare -ar c
-readonly -a a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
+readonly -a a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
 readonly -a c
 a test
-declare -a BASH_ARGC='()'
-declare -a BASH_ARGV='()'
-declare -a BASH_LINENO='([0]="0")'
-declare -a BASH_SOURCE='([0]="./array.tests")'
-declare -a DIRSTACK='()'
+declare -a BASH_ARGC=()
+declare -a BASH_ARGV=()
+declare -a BASH_LINENO=([0]="0")
+declare -a BASH_SOURCE=([0]="./array.tests")
+declare -a DIRSTACK=()
 declare -a FUNCNAME
-declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
-declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
+declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
+declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
 declare -ar c
-declare -a d='([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")'
-declare -a e='([0]="test")'
-declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
+declare -a d=([1]="" [2]="bdef" [5]="hello world" [6]="test" [9]="ninth element")
+declare -a e=([10]="(test)")
+declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
 ./array.tests: line 100: a: readonly variable
 ./array.tests: line 102: b[]: bad array subscript
 ./array.tests: line 103: b[*]: bad array subscript
@@ -57,35 +57,35 @@ declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element
 ./array.tests: line 111: []=abcde: bad array subscript
 ./array.tests: line 111: [*]=last: cannot assign to non-numeric index
 ./array.tests: line 111: [-65]=negative: bad array subscript
-declare -a BASH_ARGC='()'
-declare -a BASH_ARGV='()'
-declare -a BASH_LINENO='([0]="0")'
-declare -a BASH_SOURCE='([0]="./array.tests")'
-declare -a DIRSTACK='()'
+declare -a BASH_ARGC=()
+declare -a BASH_ARGV=()
+declare -a BASH_LINENO=([0]="0")
+declare -a BASH_SOURCE=([0]="./array.tests")
+declare -a DIRSTACK=()
 declare -a FUNCNAME
-declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
-declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
+declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
+declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
 declare -ar c
-declare -a d='([1]="test test")'
-declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
+declare -a d=([1]="test test")
+declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
 ./array.tests: line 119: unset: ps1: not an array variable
 ./array.tests: line 123: declare: c: cannot destroy array variables in this way
 this of
 this is a test of read using arrays
 this test
 this is a test of arrays
-declare -a BASH_ARGC='()'
-declare -a BASH_ARGV='()'
-declare -a BASH_LINENO='([0]="0")'
-declare -a BASH_SOURCE='([0]="./array.tests")'
-declare -a DIRSTACK='()'
+declare -a BASH_ARGC=()
+declare -a BASH_ARGV=()
+declare -a BASH_LINENO=([0]="0")
+declare -a BASH_SOURCE=([0]="./array.tests")
+declare -a DIRSTACK=()
 declare -a FUNCNAME
-declare -ar a='([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")'
-declare -a b='([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")'
+declare -ar a=([1]="" [2]="bdef" [5]="hello world" [6]="test expression" [15]="test 2")
+declare -a b=([0]="this" [1]="is" [2]="a" [3]="test" [4]="" [5]="/etc/passwd")
 declare -ar c
-declare -a d='([1]="test test")'
-declare -a f='([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")'
-declare -a rv='([0]="this" [1]="is" [2]="a" [3]="test" [4]="of" [5]="read" [6]="using" [7]="arrays")'
+declare -a d=([1]="test test")
+declare -a f=([0]="" [1]="bdef" [2]="hello world" [3]="test" [4]="ninth element")
+declare -a rv=([0]="this" [1]="is" [2]="a" [3]="test" [4]="of" [5]="read" [6]="using" [7]="arrays")
 abde
 abde
 bbb
@@ -364,22 +364,22 @@ bar
 main main
 function function
 function function
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
-declare -a x='([0]="0" [1]="1" [2]="2" [4]="4")'
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
+declare -a x=([0]="0" [1]="1" [2]="2" [4]="4")
 ./array14.sub: line 11: [-10]: bad array subscript
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="foo")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
-declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4four" [5]="5")'
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="foo")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")
+declare -a x=([0]="0" [1]="1" [2]="2" [3]="3" [4]="4four" [5]="5")
 strlen(4four) = 5
-1 2 xx 3
 1 2 0 3
-1 2 xx 3
 1 2 0 3
-1 2 xx 3
+1 2 0 3
+1 2 0 3
+1 2 0 3
 foo index 1: ok
 foo index 2: ok
 foo: implicit reference to element 0: ok
@@ -432,3 +432,51 @@ argv[1] = <qux>
 argv[1] = <->
 argv[2] = <->
 argv[1] = <  >
+declare -a foo=([0]="( zeroind )")
+declare -a foo=([0]="zeroind")
+declare -a foo=([0]="zeroind")
+declare -a foo=([0]="[0]=bar")
+declare -a foo=([0]="[0]=bar")
+declare -a foo=([0]="[0]=bar")
+declare -- a="(1 2 3)"
+declare -a a=([0]="(1 2 3)")
+declare -A a=([0]="(1 2 3)" )
+declare -- a="([0]=a [1]=b)"
+declare -a a=([0]="([0]=a [1]=b)")
+declare -A a=([0]="([0]=a [1]=b)" )
+declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
+declare -a var=([0]="[\$(echo total 0)]=1 [2]=2]")
+declare -a var=([0]="[\$(echo" [1]="total" [2]="0)]=1" [3]="[2]=2]")
+./array19.sub: line 81: total 0: syntax error in expression (error token is "0")
+declare -a var=()
+declare -al foo=([0]="abcde" [1]="two" [2]="three")
+declare -al foo=([0]="(abcde)" [1]="two" [2]="three")
+declare -al ar=([0]="one" [1]="two" [2]="three")
+declare -a a=([2]="foo")
+declare -a a=([2]="foo")
+declare -a a=([1]="(var)" [2]="foo")
+declare -a a=([0]="var")
+declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
+declare -a a=([0]="1" [1]="2" [2]="(1 2 3)")
+declare -a a=([0]="(1 2 3)" [1]="2" [2]="3")
+declare -a a=([0]="(1 2 3)" [1]="2" [2]="3")
+declare -a a=([0]="1" [1]="2" [2]="3")
+declare -- a="a b"
+declare -- b="/scratch/bash"
+declare -- c="(1 2)"
+declare -- d="(\$a)"
+declare -- e="(\$(echo Darwin))"
+declare -a a=([0]="a b")
+declare -a b=([0]="/scratch/bash")
+declare -a c=([0]="1" [1]="2")
+declare -a d=([0]="a" [1]="b")
+declare -a e=([0]="Darwin")
+./array19.sub: line 166: c: 1: must use subscript when assigning associative array
+./array19.sub: line 166: c: 2: must use subscript when assigning associative array
+./array19.sub: line 166: d: $a: must use subscript when assigning associative array
+./array19.sub: line 166: e: $(echo Darwin): must use subscript when assigning associative array
+declare -A a=([0]="a b" )
+declare -A b=([0]="/scratch/bash" )
+declare -A c=()
+declare -A d=()
+declare -A e=()
index 34953492bf47ce4ea3bcd0c62ce50ae175f6a696..82d9c34d9a940e0435f86a614cd152117bd4914c 100644 (file)
@@ -404,3 +404,5 @@ ${THIS_SH} ./array16.sub
 ${THIS_SH} ./array17.sub
 
 ${THIS_SH} ./array18.sub
+
+${THIS_SH} ./array19.sub
diff --git a/tests/array19.sub b/tests/array19.sub
new file mode 100644 (file)
index 0000000..adfad82
--- /dev/null
@@ -0,0 +1,167 @@
+# tests for changes to declare and assignment statement arguments post-bash-4.3
+
+unset foo l a b
+
+l="( zeroind )"
+
+unset foo
+declare -a foo
+foo="$l"
+declare -p foo
+
+unset foo
+declare -a foo="$l"
+declare -p foo
+
+unset foo
+declare -a foo=$l
+declare -p foo
+
+b='[0]=bar'
+
+unset foo
+declare -a foo="$b"
+declare -p foo
+
+unset foo
+declare -a foo=("$b")
+declare -p foo
+
+unset foo
+declare -a foo=($b)
+declare -p foo
+
+unset a
+
+declare a='(1 2 3)'
+declare -p a
+unset a
+
+declare -a a
+declare a='(1 2 3)'
+declare -p a
+unset a
+
+declare -A a
+declare a='(1 2 3)'
+declare -p a
+unset a
+
+declare a='([0]=a [1]=b)'
+declare -p a
+unset a
+
+declare -a a
+declare a='([0]=a [1]=b)'
+declare -p a
+unset a
+
+declare -A a
+declare a='([0]=a [1]=b)'
+declare -p a
+unset a
+unset var value
+
+value='[$(echo total 0)]=1 [2]=2]'
+
+unset var
+declare -a var
+var=($value)
+declare -p var
+
+unset var
+declare -a var=("$value")
+declare -p var
+
+unset var
+declare -a var=($value)
+declare -p var
+
+unset var
+declare -a var="($value)"
+declare -p var
+unset foo value
+
+value="AbCdE"
+
+declare -a foo
+foo=( one two three )
+
+declare -l foo="$value"
+declare -p foo
+
+unset foo
+value='(AbCdE)'
+
+declare -a foo
+foo=( one two three )
+
+declare -l foo="$value"
+declare -p foo
+unset ar
+declare -a ar=(ONE TWO THREE)
+declare -al ar=(${ar[@]})
+declare -p ar 
+unset a
+
+declare -a a
+a[2]=foo
+declare -p a
+
+unset a
+declare -a a
+declare a[2]=foo
+declare -p a
+
+declare a[1]='(var)'
+declare -p a
+
+unset a
+declare a[1]='(var)'
+declare -p a
+unset a
+
+a=(1 2 3)
+a[2]='(1 2 3)'
+
+declare -p a
+
+unset a
+a=(1 2 3)
+declare a[2]='(1 2 3)'
+
+declare -p a
+
+unset a
+a=(1 2 3)
+declare a='(1 2 3)'
+
+declare -p a
+
+unset a
+a=(1 2 3)
+declare 'a=(1 2 3)'
+
+declare -p a
+
+unset a
+declare -a a='(1 2 3)'
+
+declare -p a
+unset a b c d e x y
+
+HOME=/scratch/bash
+x='a b'
+y='($(echo Darwin))'
+
+declare a=$x b=~ c='(1 2)' d='($a)' e=$y
+
+declare -p a b c d e
+
+unset a b c d e
+declare -a a=$x b=~ c='(1 2)' d='($a)' e=$y
+declare -p a b c d e
+
+unset a b c d e
+declare -A a=$x b=~ c='(1 2)' d='($a)' e=$y
+declare -p a b c d e
index 9dd028cb4d09d67a7ce02a95a938b04790f9fb2f..315b0cec4250dd23fb987efb40c50dec6937213d 100644 (file)
@@ -1,23 +1,23 @@
-declare -A BASH_ALIASES='()'
-declare -A BASH_CMDS='()'
+declare -A BASH_ALIASES=()
+declare -A BASH_CMDS=()
 declare -A fluff
-declare -A BASH_ALIASES='()'
-declare -A BASH_CMDS='()'
-declare -A fluff='([bar]="two" [foo]="one" )'
-declare -A fluff='([bar]="two" [foo]="one" )'
-declare -A fluff='([bar]="two" )'
-declare -A fluff='([bar]="newval" [qux]="assigned" )'
+declare -A BASH_ALIASES=()
+declare -A BASH_CMDS=()
+declare -A fluff=([bar]="two" [foo]="one" )
+declare -A fluff=([bar]="two" [foo]="one" )
+declare -A fluff=([bar]="two" )
+declare -A fluff=([bar]="newval" [qux]="assigned" )
 ./assoc.tests: line 26: chaff: four: must use subscript when assigning associative array
-declare -A BASH_ALIASES='()'
-declare -A BASH_CMDS='()'
-declare -Ai chaff='([one]="10" [zero]="5" )'
-declare -Ar waste='([version]="4.0-devel" [source]="./assoc.tests" [lineno]="28" [pid]="42134" )'
-declare -A wheat='([two]="b" [three]="c" [one]="a" [zero]="0" )'
-declare -A chaff='([one]="10" ["hello world"]="flip" [zero]="5" )'
+declare -A BASH_ALIASES=()
+declare -A BASH_CMDS=()
+declare -Ai chaff=([one]="10" [zero]="5" )
+declare -Ar waste=([version]="4.0-devel" [source]="./assoc.tests" [lineno]="28" [pid]="42134" )
+declare -A wheat=([two]="b" [three]="c" [one]="a" [zero]="0" )
+declare -A chaff=([one]="10" ["hello world"]="flip" [zero]="5" )
 ./assoc.tests: line 38: unset: waste: cannot unset: readonly variable
 ./assoc.tests: line 39: chaff[*]: bad array subscript
 ./assoc.tests: line 40: [*]=12: invalid associative array key
-declare -A chaff='([one]="a" ["hello world"]="flip" )'
+declare -A chaff=([one]="a" ["hello world"]="flip" )
 flip
 argv[1] = <a>
 argv[2] = <flip>
@@ -34,11 +34,11 @@ argv[1] = <a flip multiple words>
 ./assoc.tests: line 57: declare: chaff: cannot destroy array variables in this way
 ./assoc.tests: line 59: chaff[*]: bad array subscript
 ./assoc.tests: line 60: [*]=12: invalid associative array key
-declare -A wheat='([six]="6" ["foo bar"]="qux qix" )'
+declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
 argv[1] = <qux>
 argv[2] = <qix>
 argv[1] = <qux qix>
-declare -A wheat='([six]="6" ["foo bar"]="qux qix" )'
+declare -A wheat=([six]="6" ["foo bar"]="qux qix" )
 argv[1] = <2>
 argv[1] = <7>
 argv[1] = <qux>
@@ -101,9 +101,9 @@ argv[2] = </usr/sbin/foo>
 argv[3] = <cd /blat ; echo $PWD>
 argv[4] = </usr/local/bin/qux -l>
 outside: outside
-declare -A BASH_ALIASES='()'
-declare -A BASH_CMDS='()'
-declare -A afoo='([six]="six" ["foo bar"]="foo quux" )'
+declare -A BASH_ALIASES=()
+declare -A BASH_CMDS=()
+declare -A afoo=([six]="six" ["foo bar"]="foo quux" )
 argv[1] = <inside:>
 argv[2] = <six>
 argv[3] = <foo quux>
@@ -144,49 +144,49 @@ myarray=(["a]=test1;#a"]="123" [foo]="bleh" ["a]a"]="abc" ["]"]="def" )
 myarray=(["a]=test1;#a"]="123" [foo]="bleh" ["a]a"]="abc" ["a]=test2;#a"]="def" ["]"]="def" )
 bar"bie
 doll
-declare -A foo='(["bar\"bie"]="doll" )'
+declare -A foo=(["bar\"bie"]="doll" )
 bar"bie
 doll
-declare -A foo='(["bar\"bie"]="doll" )'
+declare -A foo=(["bar\"bie"]="doll" )
 bar"bie
 doll
-declare -A foo='(["bar\"bie"]="doll" )'
+declare -A foo=(["bar\"bie"]="doll" )
 bar"bie
 doll
-declare -A foo='(["bar\"bie"]="doll" )'
+declare -A foo=(["bar\"bie"]="doll" )
 bar"bie
 doll
-declare -A foo='(["bar\"bie"]="doll" )'
+declare -A foo=(["bar\"bie"]="doll" )
 bar'bie
 doll
-declare -A foo='(["bar'\''bie"]="doll" )'
+declare -A foo=(["bar'bie"]="doll" )
 bar'bie
 doll
-declare -A foo='(["bar'\''bie"]="doll" )'
+declare -A foo=(["bar'bie"]="doll" )
 bar'bie
 doll
-declare -A foo='(["bar'\''bie"]="doll" )'
+declare -A foo=(["bar'bie"]="doll" )
 bar'bie
 doll
-declare -A foo='(["bar'\''bie"]="doll" )'
+declare -A foo=(["bar'bie"]="doll" )
 bar'bie
 doll
-declare -A foo='(["bar'\''bie"]="doll" )'
+declare -A foo=(["bar'bie"]="doll" )
 bar$bie
 doll
-declare -A foo='(["bar\$bie"]="doll" )'
+declare -A foo=(["bar\$bie"]="doll" )
 bar[bie
 doll
-declare -A foo='(["bar[bie"]="doll" )'
+declare -A foo=(["bar[bie"]="doll" )
 bar`bie
 doll
-declare -A foo='(["bar\`bie"]="doll" )'
+declare -A foo=(["bar\`bie"]="doll" )
 bar\]bie
 doll
-declare -A foo='(["bar\\]bie"]="doll" )'
+declare -A foo=(["bar\\]bie"]="doll" )
 bar${foo}bie
 doll
-declare -A foo='(["bar\${foo}bie"]="doll" )'
+declare -A foo=(["bar\${foo}bie"]="doll" )
 bar
 after printf
 after use: 0
index 6b6b4dcde8df65744f7c56f70950b9f2b74141ec..63e5605fb1959b7de31d0dfd1e4e2818a58fa630 100644 (file)
@@ -160,12 +160,12 @@ inside
 after: f = 8 bar = 4
 declare -a c
 declare -A d
-declare -a c='([0]="4")'
-declare -A c='([0]="4" )'
-declare -a c='([0]="1" [1]="2" [2]="3")'
-declare -A c='([two]="2" [three]="3" [one]="1" )'
-declare -a c='([0]="1" [1]="2" [2]="3")'
-declare -a c='([0]="1" [1]="2" [2]="3")'
+declare -a c=([0]="4")
+declare -A c=([0]="4" )
+declare -a c=([0]="1" [1]="2" [2]="3")
+declare -A c=([two]="2" [three]="3" [one]="1" )
+declare -a c=([0]="1" [1]="2" [2]="3")
+declare -a c=([0]="1" [1]="2" [2]="3")
 unset
 unset
 ./builtins.tests: line 260: exit: status: numeric argument required
index 5f6fa7f2cd405f32229d178703485a188527116d..689f550deaeb66b9ae85762bbac6183c46499acb 100644 (file)
@@ -348,17 +348,17 @@ third set:
 "${@:2}a3 a2" a$1    #works as long as $1 and 3 are swapped
 set y za3 a2 ax
 0
-declare -a a='([0]="y" [1]="za3 a2" [2]="ax")'
+declare -a a=([0]="y" [1]="za3 a2" [2]="ax")
 
 "${@:2}b$1 b2" b3    #fails!  why?
 set y zbx b2 b3
 0
-declare -a b='([0]="y" [1]="zbx b2" [2]="b3")'
+declare -a b=([0]="y" [1]="zbx b2" [2]="b3")
 
 ${@:2}c$1 c2 c3     #works as long as quoting omitted
 set y zcx c2 c3
 0
-declare -a c='([0]="y" [1]="zcx" [2]="c2" [3]="c3")'
+declare -a c=([0]="y" [1]="zcx" [2]="c2" [3]="c3")
 argv[1] = <>
 argv[2] = <x>
 argv[1] = <>
index 80b01cf7ec045d1fe4729e4810060116038950b6..473e12346066f845353c2c8cf2860b7d9c8ff860 100644 (file)
@@ -24,5 +24,5 @@ f3 ()
 echo $(echo hi)
 echo ho
 echo off to work we go
-declare -a uu='([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i
-")'
+declare -a uu=([0]="" [1]="kghfjk" [2]="jkfzuk" [3]="i
+")
index 1c7fb64476db73b8b4c09d3ffac9bfc4fb86988b..a1a9540097d2d54ac93e8676de99349010ae0aed 100644 (file)
@@ -60,17 +60,17 @@ FIN: asdf fdsa, asdf fdsa
 g: v = , w =
 f: v = , w =
 FIN: v = two, w = one
-declare -Ar FOOBAR='([foo]="bar" )'
-declare -Ar FOOBAR='([foo]="bar" )'
-declare -ar FOOBAR2='([0]="bar")'
-declare -ar FOOBAR2='([0]="bar")'
+declare -Ar FOOBAR=([foo]="bar" )
+declare -Ar FOOBAR=([foo]="bar" )
+declare -ar FOOBAR2=([0]="bar")
+declare -ar FOOBAR2=([0]="bar")
 F OUTSIDE
 F OUTSIDE
-declare -ar outside='()'
+declare -ar outside=()
 declare -ir outside1="1"
 tempenv = foo
 0
-declare -ar myvar='([0]="0")'
+declare -ar myvar=([0]="0")
 1
 declare -ir myvar="1"
 declare -rx tempvar1='foo'