Skip to content

Commit b08b5ef

Browse files
committed
t/shelltest.od: Add a new preliminary test for IFS= behaviour.
Apparently in zsh (when in sh compatibility mode), IFS=/ will split "/a/b/c/" into 5 parts ("", "a", "b", "c", ""). Other shells all seem to agree that it's 4 parts ("", "a", "b", "c"). zsh seems maybe more correct to me, but the majority rules, so we'll warn on it. Meanwhile, we'll also fix the one place in minimal/do that failed due to this oddity, since it's relatively easy to avoid. Reported-by: [email protected]
1 parent 262d272 commit b08b5ef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

minimal/do

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ _normpath()
196196
fi
197197
set -f
198198
IFS=/
199-
for d in $path; do
199+
for d in ${path%/}; do
200200
#echo "NP out='$out' d='$d'" >&2
201201
if [ "$d" = ".." ]; then
202202
out=$(_updir "${out%/}")/

t/shelltest.od

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ quiet_stderr()
4646
fi
4747
}
4848

49+
(
50+
x="/a/b/c/"
51+
IFS=/
52+
f() {
53+
[ "$2" = "a" ] || fail 2
54+
[ "$#" = "4" ] || warn 2a
55+
}
56+
f $x
57+
)
4958

5059
name=foo.o.o
5160
ext=.o

0 commit comments

Comments
 (0)