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: shamrin@gmail.com
This commit is contained in:
Avery Pennarun 2019-07-24 02:45:47 -04:00
commit b08b5efcef
2 changed files with 10 additions and 1 deletions

View file

@ -196,7 +196,7 @@ _normpath()
fi fi
set -f set -f
IFS=/ IFS=/
for d in $path; do for d in ${path%/}; do
#echo "NP out='$out' d='$d'" >&2 #echo "NP out='$out' d='$d'" >&2
if [ "$d" = ".." ]; then if [ "$d" = ".." ]; then
out=$(_updir "${out%/}")/ out=$(_updir "${out%/}")/

View file

@ -46,6 +46,15 @@ quiet_stderr()
fi fi
} }
(
x="/a/b/c/"
IFS=/
f() {
[ "$2" = "a" ] || fail 2
[ "$#" = "4" ] || warn 2a
}
f $x
)
name=foo.o.o name=foo.o.o
ext=.o ext=.o