From 91edfa3b258cfd90854eb50e1a2ad74fe95043ed Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 17 Apr 2002 17:17:42 +0000 Subject: Alexandre Duret-Lutz: 16930: Src/cond.c, Test/C02cond.ztst: Careful with long filenames in internal condition test; fix block file test for `-f'. --- ChangeLog | 6 ++++++ Src/cond.c | 6 +++++- Test/C02cond.ztst | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04732bc06..89d29e708 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-04-17 Peter Stephenson + + * Alexandre Duret-Lutz: 16930: Src/cond.c, Test/C02cond.ztst: + Careful with long filenames in internal condition test; fix block + file test for `-f'. + 2002-04-17 Sven Wischnowsky * 16998: Src/Zle/computil.c: make compvalues unquote the string diff --git a/Src/cond.c b/Src/cond.c index b34a14be1..4a4dc24ed 100644 --- a/Src/cond.c +++ b/Src/cond.c @@ -324,6 +324,8 @@ static struct stat st; static struct stat * getstat(char *s) { + char *us; + /* /dev/fd/n refers to the open file descriptor n. We always use fstat * * in this case since on Solaris /dev/fd/n is a device special file */ if (!strncmp(s, "/dev/fd/", 8)) { @@ -332,7 +334,9 @@ getstat(char *s) return &st; } - if (stat(unmeta(s), &st)) + if (!(us = unmeta(s))) + return NULL; + if (stat(us, &st)) return NULL; return &st; } diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst index eafda1b5c..6c6aea4f6 100644 --- a/Test/C02cond.ztst +++ b/Test/C02cond.ztst @@ -52,7 +52,12 @@ [[ -e zerolength && ! -e nonexistent ]] 0:-e cond - [[ -f zerolength && ! -f cond && ! -f $char && ! -f $block && ! -f . ]] + if [[ -n $block ]]; then + [[ -f zerolength && ! -f cond && ! -f $char && ! -f $block[(f)1] && ! -f . ]] + else + print -u8 'Warning: Not testing [[ -f blockdevice ]] (no devices found)' + [[ -f zerolength && ! -f cond && ! -f $char && ! -f . ]] + fi 0:-f cond [[ -g modish && ! -g zerolength ]] -- cgit 1.4.1