mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-16 00:20:49 +02:00
new shell option to force globbing never to return .' and ..' as matches
This commit is contained in:
+16
-6
@@ -253,12 +253,12 @@ declare -A dict=(["?"]="quest" ["*"]="star" ["'"]="squote" ["\$"]="dol" ["\""]="
|
||||
dict=( "?" "quest" "*" "star" "'" "squote" "\$" "dol" "\"" "dquote" "\\" "bslash" "@" "at" "}" "rbrace" "{" "lbrace" "\`" "bquote" )
|
||||
declare -A foo=([two]="" [one]="1" )
|
||||
foo=( two "" one "1" )
|
||||
rparen dquote rbrace bs
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
|
||||
")" "rparen" "\"" "dquote" "]" "rbrace" "\\" "bs"
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbrace" ["\\"]="bs" )
|
||||
rparen dquote rbracket bs
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbracket" ["\\"]="bs" )
|
||||
")" "rparen" "\"" "dquote" "]" "rbracket" "\\" "bs"
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbracket" ["\\"]="bs" )
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbracket" ["\\"]="bs" )
|
||||
declare -A a=([")"]="rparen" ["\""]="dquote" ["]"]="rbracket" ["\\"]="bs" )
|
||||
declare -Arx foo=([two]="2" [three]="3" [one]="1" )
|
||||
./assoc11.sub: line 90: foo: readonly variable
|
||||
declare -A v1=(["1 2"]="3" )
|
||||
@@ -383,3 +383,13 @@ set
|
||||
stderr
|
||||
42
|
||||
42
|
||||
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
|
||||
declare -A A=()
|
||||
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
|
||||
declare -A A=()
|
||||
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
|
||||
declare -A A=()
|
||||
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
|
||||
declare -A A=()
|
||||
declare -A A=(["]"]="rbracket" ["["]="lbracket" )
|
||||
declare -A A=()
|
||||
|
||||
@@ -259,3 +259,6 @@ ${THIS_SH} ./assoc15.sub
|
||||
|
||||
# tests with subscripts being expanded more than one in ${xxx} word expansions
|
||||
${THIS_SH} ./assoc16.sub
|
||||
|
||||
# tests with `[' and `]' subscripts and `unset'
|
||||
${THIS_SH} ./assoc17.sub
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ foo=(one 1 two)
|
||||
declare -p foo
|
||||
echo foo=\( ${foo[@]@K} \)
|
||||
|
||||
typeset -A a=( [\\]=bs [\"]=dquote [\)]=rparen [\]]=rbrace )
|
||||
typeset -A a=( [\\]=bs [\"]=dquote [\)]=rparen [\]]=rbracket )
|
||||
echo ${a[@]}
|
||||
declare -p a
|
||||
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
declare -A assoc=(hello world "key with spaces" "value with spaces" one 1 foo bar)
|
||||
declare -p assoc
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
# 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/>.
|
||||
#
|
||||
# test behavior with `unset' and `[' and ']' subscripts
|
||||
|
||||
declare -A A
|
||||
rkey=']'
|
||||
lkey='['
|
||||
|
||||
A[$rkey]=rbracket
|
||||
A[$lkey]=lbracket
|
||||
declare -p A
|
||||
|
||||
unset A[$rkey]
|
||||
unset A[$lkey]
|
||||
declare -p A
|
||||
|
||||
A["$rkey"]=rbracket
|
||||
A["$lkey"]=lbracket
|
||||
declare -p A
|
||||
|
||||
unset A["$rkey"]
|
||||
unset A["$lkey"]
|
||||
declare -p A
|
||||
|
||||
A[\]]=rbracket
|
||||
A[\[]=lbracket
|
||||
declare -p A
|
||||
|
||||
unset A[\]]
|
||||
unset A[\[]
|
||||
declare -p A
|
||||
|
||||
A[']']=rbracket
|
||||
A['[']=lbracket
|
||||
declare -p A
|
||||
|
||||
unset A[']']
|
||||
unset A['[']
|
||||
declare -p A
|
||||
|
||||
A["]"]=rbracket
|
||||
A["["]=lbracket
|
||||
declare -p A
|
||||
|
||||
unset A["]"]
|
||||
unset A["["]
|
||||
declare -p A
|
||||
+14
-14
@@ -92,16 +92,16 @@ a ab
|
||||
a ab
|
||||
a ab
|
||||
a
|
||||
. ..
|
||||
. .. a.log
|
||||
*(.)
|
||||
a.log
|
||||
*(foo)
|
||||
*(foo|bar)
|
||||
a.log
|
||||
?(foo)
|
||||
a.log
|
||||
a.log
|
||||
. ..
|
||||
. ..
|
||||
*(foo).*
|
||||
*(foo|bar).*
|
||||
a.log
|
||||
a.log
|
||||
.x .y .z
|
||||
@@ -114,16 +114,16 @@ a b c
|
||||
.x .y .z a b c
|
||||
.x .y .z a b c
|
||||
*
|
||||
.. .b a
|
||||
.. .b a
|
||||
a .. .b
|
||||
. .. .b
|
||||
. .. .b
|
||||
.. .b a
|
||||
.. .b a
|
||||
a .. .b
|
||||
. .. .b
|
||||
. .. .b
|
||||
.b a
|
||||
.b a
|
||||
a .b
|
||||
.b
|
||||
.b
|
||||
.b a
|
||||
.b a
|
||||
a .b
|
||||
.b
|
||||
.b
|
||||
dotglob: .a .foo bar
|
||||
@(.foo)
|
||||
.foo
|
||||
|
||||
@@ -12,6 +12,7 @@ cd $TESTDIR || {
|
||||
|
||||
LC_CTYPE=C LC_COLLATE=C
|
||||
shopt -s extglob dotglob
|
||||
shopt -u globskipdots # XXX - backwards compatibility
|
||||
touch .foo bar .a
|
||||
|
||||
echo dotglob: .a .foo bar
|
||||
|
||||
+5
-1
@@ -121,6 +121,10 @@ a\*b
|
||||
a\*b*
|
||||
é/*
|
||||
é/*
|
||||
a aa b bb
|
||||
.a .aa .b .bb a aa b bb
|
||||
.a .aa .b .bb
|
||||
. .. .a .aa .b .bb
|
||||
argv[1] = <a>
|
||||
argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
@@ -135,7 +139,7 @@ argv[2] = <abc>
|
||||
argv[3] = <abd>
|
||||
argv[4] = <abe>
|
||||
tmp/l1 tmp/l2 tmp/*4 tmp/l3
|
||||
./glob.tests: line 65: no match: tmp/*4
|
||||
./glob.tests: line 66: no match: tmp/*4
|
||||
argv[1] = <bdir/>
|
||||
argv[1] = <*>
|
||||
argv[1] = <a*>
|
||||
|
||||
@@ -30,6 +30,7 @@ ${THIS_SH} ./glob6.sub
|
||||
${THIS_SH} ./glob7.sub
|
||||
${THIS_SH} ./glob8.sub
|
||||
${THIS_SH} ./glob9.sub
|
||||
${THIS_SH} ./glob10.sub
|
||||
|
||||
MYDIR=$PWD # save where we are
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
# test basic behavior of globskipdots
|
||||
TDIR=/tmp/dotglob-$$
|
||||
|
||||
{ mkdir $TDIR && cd $TDIR; } || exit 1
|
||||
|
||||
touch a b aa bb .a .b .aa .bb
|
||||
|
||||
echo *
|
||||
shopt -s dotglob
|
||||
echo *
|
||||
|
||||
shopt -s globskipdots
|
||||
echo .*
|
||||
shopt -u globskipdots
|
||||
echo .*
|
||||
|
||||
cd $OLDPWD
|
||||
rm -rf $TDIR
|
||||
@@ -28,6 +28,7 @@ shopt -s extquote
|
||||
shopt -u failglob
|
||||
shopt -s force_fignore
|
||||
shopt -s globasciiranges
|
||||
shopt -s globskipdots
|
||||
shopt -u globstar
|
||||
shopt -u gnu_errfmt
|
||||
shopt -u histappend
|
||||
@@ -69,6 +70,7 @@ shopt -s expand_aliases
|
||||
shopt -s extquote
|
||||
shopt -s force_fignore
|
||||
shopt -s globasciiranges
|
||||
shopt -s globskipdots
|
||||
shopt -s hostcomplete
|
||||
shopt -s interactive_comments
|
||||
shopt -s patsub_replacement
|
||||
@@ -302,5 +304,9 @@ xtrace off
|
||||
--
|
||||
./shopt.tests: line 106: shopt: xyz1: invalid shell option name
|
||||
./shopt.tests: line 107: shopt: xyz1: invalid option name
|
||||
28c28
|
||||
< globskipdots off
|
||||
---
|
||||
> globskipdots on
|
||||
expand_aliases on
|
||||
expand_aliases on
|
||||
|
||||
Reference in New Issue
Block a user