diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 7c664727..2e2fb9cf 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -7600,3 +7600,22 @@ variables.c affected by posix mode so we can restore them when we restore the old value of the variable after the command executes. Suggested by Martijn Dekker + + 3/20 + ---- +syntax.h + - slashify_in_here_document: add `"' to this list, since POSIX says + that backslashes in here documents behave like backslashes in + double quotes, and backslash can quote a double quote in a double- + quoted string. This means that given P=A, + + cat < back in 1/2019. diff --git a/MANIFEST b/MANIFEST index 554f6816..fcbd53fc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1244,6 +1244,7 @@ tests/posixexp4.sub f tests/posixexp5.sub f tests/posixexp6.sub f tests/posixexp7.sub f +tests/posixexp8.sub f tests/posixexp2.tests f tests/posixexp2.right f tests/posixpat.tests f @@ -1439,6 +1440,8 @@ tests/varenv14.sub f tests/varenv15.sub f tests/varenv15.in f tests/varenv16.sub f +tests/varenv17.sub f +tests/varenv18.sub f tests/version f tests/version.mini f tests/vredir.tests f diff --git a/syntax.h b/syntax.h index 9a9a2fa7..b808d60d 100644 --- a/syntax.h +++ b/syntax.h @@ -1,6 +1,6 @@ /* syntax.h -- Syntax definitions for the shell */ -/* Copyright (C) 2000, 2001, 2005, 2008,2009 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2005, 2008, 2009-2020 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -24,7 +24,7 @@ /* Defines for use by mksyntax.c */ #define slashify_in_quotes "\\`$\"\n" -#define slashify_in_here_document "\\`$" +#define slashify_in_here_document "\\`$\"" #define shell_meta_chars "()<>;&|" #define shell_break_chars "()<>;&| \t\n" diff --git a/tests/glob4.sub b/tests/glob4.sub index c7f51223..779c8540 100644 --- a/tests/glob4.sub +++ b/tests/glob4.sub @@ -11,7 +11,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -trap "rm 'a?' aa" EXIT +: ${TMPDIR:=/var/tmp} + +FN=$TMPDIR/bash-glob.$$ +mkdir $FN || { echo "glob4.sub: cannot mkdir $FN" >&2 ; exit 1; } +builtin cd $FN || { echo "glob4.sub: cannot change directory to $FN" >&2 ; exit 1; } +rm -f * + touch 'a?' aa set -- a \?; IFS=\\; var=$*; @@ -30,3 +36,6 @@ printf "%s\n" ${var} PRE='\/' printf '<%s>\n' 'define'${PRE}'\ /' + +builtin cd $OLDPWD +rm -rf $FN diff --git a/tests/glob5.sub b/tests/glob5.sub index dfedb9dd..5735715d 100644 --- a/tests/glob5.sub +++ b/tests/glob5.sub @@ -14,9 +14,9 @@ ORIGD=$PWD : ${TMPDIR:=/var/tmp} -SD=$TMPDIR/scratch-$$ +SD=$TMPDIR/bash-glob-$$ [ -d $SD ] || mkdir $SD -cd $SD +builtin cd $SD || { echo "glob5.sub: cannot change directory to $SD" >&2 ; exit 1; } mkdir tmp D=./tmp/a diff --git a/tests/glob6.sub b/tests/glob6.sub index 5d06a91d..f26ae4d6 100644 --- a/tests/glob6.sub +++ b/tests/glob6.sub @@ -17,7 +17,8 @@ ORIG=$PWD GLOBDIR=$TMPDIR/bash-glob-$$ -mkdir $GLOBDIR && cd $GLOBDIR +mkdir $GLOBDIR || { echo "glob6.sub: cannot make directory $GLOBDIR" >&2 ; exit 1; } +builtin cd $GLOBDIR || { echo "glob6.sub: cannot change directory to $GLOBDIR" >&2 ; exit 1; } # does the pattern matcher allow backslashes as escape characters and remove # them as part of matching? diff --git a/tests/glob8.sub b/tests/glob8.sub index 4ee5f7a0..dca54fcc 100644 --- a/tests/glob8.sub +++ b/tests/glob8.sub @@ -11,6 +11,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # +: ${TMPDIR:=/var/tmp} + TESTDIR=${TMPDIR}/glob-test-$$ mkdir ${TESTDIR} cd $TESTDIR || { diff --git a/tests/posixexp.right b/tests/posixexp.right index 329c9822..e6bdbf4b 100644 --- a/tests/posixexp.right +++ b/tests/posixexp.right @@ -279,5 +279,10 @@ argv[2] = OK OK 5: $'not\ttoo\nbad' -./posixexp.tests: line 96: unexpected EOF while looking for matching `}' -./posixexp.tests: line 97: syntax error: unexpected end of file +"A" +A +argv[1] = <"A"> +argv[1] = +argv[1] = +./posixexp.tests: line 97: unexpected EOF while looking for matching `}' +./posixexp.tests: line 98: syntax error: unexpected end of file diff --git a/tests/posixexp.tests b/tests/posixexp.tests index b992c303..d8f66441 100644 --- a/tests/posixexp.tests +++ b/tests/posixexp.tests @@ -90,6 +90,7 @@ ${THIS_SH} ./posixexp4.sub ${THIS_SH} ./posixexp5.sub ${THIS_SH} ./posixexp6.sub ${THIS_SH} ./posixexp7.sub +${THIS_SH} ./posixexp8.sub # this will be an error foo=bar diff --git a/tests/posixexp8.sub b/tests/posixexp8.sub new file mode 100644 index 00000000..383851c4 --- /dev/null +++ b/tests/posixexp8.sub @@ -0,0 +1,11 @@ +P=A + +cat << EOF +${P+\"$P\"} +${P+"$P"} +EOF + +recho "${P+\"$P\"}" + +recho "${P+"$P"}" +recho ${P+"$P"} diff --git a/tests/varenv.right b/tests/varenv.right index 35739dac..4c8ef220 100644 --- a/tests/varenv.right +++ b/tests/varenv.right @@ -237,6 +237,22 @@ outside 2.0: foo= foo=foo environment foo=foo foo= environment foo= outside 2.1: foo= +declare -- var="global" +declare -- var +declare -- var="local" +declare -- var="global" +declare -- var="local" +declare -- var +declare -- var="local" +declare -- var +declare -- var="local" +declare -- var +declare -- var="local" +declare -- var="f1" +declare -- var="local" +declare -a arr=([0]="zero" [1]="one" [2]="two") +declare -a arr=([0]="three" [1]="four" [2]="five") +declare -a arr=([0]="zero" [1]="one" [2]="two") a=z a=b a=z diff --git a/tests/varenv.tests b/tests/varenv.tests index b92c8766..495fe7ed 100644 --- a/tests/varenv.tests +++ b/tests/varenv.tests @@ -252,10 +252,10 @@ ${THIS_SH} ./varenv13.sub # localvar_inherit ${THIS_SH} ./varenv14.sub - ${THIS_SH} ./varenv15.sub - ${THIS_SH} ./varenv16.sub +${THIS_SH} ./varenv17.sub +${THIS_SH} ./varenv18.sub # make sure variable scoping is done right tt() { typeset a=b;echo a=$a; };a=z;echo a=$a;tt;echo a=$a diff --git a/tests/varenv17.sub b/tests/varenv17.sub new file mode 100644 index 00000000..1f9278cf --- /dev/null +++ b/tests/varenv17.sub @@ -0,0 +1,44 @@ +# 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 . +# + +# testing -I and local variable inheritance +var=global + +f() +{ + local $1 var + declare -p var + + var=local + declare -p var +} + +declare -I var +declare -p var + +f +f -I +unset var +f +f -I + +f1() +{ + var=$FUNCNAME + + f + f -I +} + +f1 diff --git a/tests/varenv18.sub b/tests/varenv18.sub new file mode 100644 index 00000000..4500c39e --- /dev/null +++ b/tests/varenv18.sub @@ -0,0 +1,43 @@ +# 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 . +# + +# this uses value inheritance internally so that the self-reference in the +# local variable declaration works right + +arr=(zero one two) +four=four + +f() +{ + local -a arr=( "${arr[@]}" ) + declare -p arr +} + +f + +f1() +{ + local -a arr=(three $four five) + declare -p arr +} +f1 + +set -u +name='arr[@]' +f2() +{ + local -a arr=("${!name}") + declare -p arr +} +f2