sh: Remove remnants of '!!' to negate pattern.
This Almquist extension was disabled long ago. In pathname generation, components starting with '!!' were treated as containing wildcards, causing unnecessary readdir (which could fail, causing pathname generation to fail while it should not).
This commit is contained in:
parent
46ef223895
commit
44306000bd
@ -109,7 +109,6 @@ STATIC void expmeta(char *, char *);
|
||||
STATIC void addfname(char *);
|
||||
STATIC struct strlist *expsort(struct strlist *);
|
||||
STATIC struct strlist *msort(struct strlist *, int);
|
||||
STATIC int pmatch(const char *, const char *, int);
|
||||
STATIC char *cvtnum(int, char *);
|
||||
STATIC int collate_range_cmp(int, int);
|
||||
|
||||
@ -1101,7 +1100,7 @@ expandmeta(struct strlist *str, int flag __unused)
|
||||
for (;;) { /* fast check for meta chars */
|
||||
if ((c = *p++) == '\0')
|
||||
goto nometa;
|
||||
if (c == '*' || c == '?' || c == '[' || c == '!')
|
||||
if (c == '*' || c == '?' || c == '[')
|
||||
break;
|
||||
}
|
||||
savelastp = exparg.lastp;
|
||||
@ -1168,8 +1167,6 @@ expmeta(char *enddir, char *name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (*p == '!' && p[1] == '!' && (p == name || p[-1] == '/')) {
|
||||
metaflag = 1;
|
||||
} else if (*p == '\0')
|
||||
break;
|
||||
else if (*p == CTLQUOTEMARK)
|
||||
@ -1352,18 +1349,6 @@ msort(struct strlist *list, int len)
|
||||
|
||||
int
|
||||
patmatch(const char *pattern, const char *string, int squoted)
|
||||
{
|
||||
#ifdef notdef
|
||||
if (pattern[0] == '!' && pattern[1] == '!')
|
||||
return 1 - pmatch(pattern + 2, string);
|
||||
else
|
||||
#endif
|
||||
return pmatch(pattern, string, squoted);
|
||||
}
|
||||
|
||||
|
||||
STATIC int
|
||||
pmatch(const char *pattern, const char *string, int squoted)
|
||||
{
|
||||
const char *p, *q;
|
||||
char c;
|
||||
@ -1406,7 +1391,7 @@ pmatch(const char *pattern, const char *string, int squoted)
|
||||
}
|
||||
}
|
||||
do {
|
||||
if (pmatch(p, q, squoted))
|
||||
if (patmatch(p, q, squoted))
|
||||
return 1;
|
||||
if (squoted && *q == CTLESC)
|
||||
q++;
|
||||
|
28
tools/regression/bin/sh/expansion/pathname4.0
Normal file
28
tools/regression/bin/sh/expansion/pathname4.0
Normal file
@ -0,0 +1,28 @@
|
||||
# $FreeBSD$
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
testcase=$1
|
||||
expect=$2
|
||||
eval "set -- $testcase"
|
||||
actual="$*"
|
||||
if [ "$actual" != "$expect" ]; then
|
||||
failures=$((failures+1))
|
||||
printf '%s\n' "For $testcase, expected $expect actual $actual"
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
|
||||
trap 'rm -rf $T' 0
|
||||
cd -P $T
|
||||
|
||||
mkdir !!a
|
||||
touch !!a/fff
|
||||
|
||||
chmod u-r .
|
||||
check '!!a/ff*' '!!a/fff'
|
||||
chmod u+r .
|
||||
|
||||
exit $((failures != 0))
|
Loading…
Reference in New Issue
Block a user