Skip to content

Commit

Permalink
t/shelltest.od: Add a new preliminary test for IFS= behaviour.
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
apenwarr committed Jul 24, 2019
1 parent 262d272 commit b08b5ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion minimal/do
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ _normpath()
fi
set -f
IFS=/
for d in $path; do
for d in ${path%/}; do
#echo "NP out='$out' d='$d'" >&2
if [ "$d" = ".." ]; then
out=$(_updir "${out%/}")/
Expand Down
9 changes: 9 additions & 0 deletions t/shelltest.od
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ quiet_stderr()
fi
}

(
x="/a/b/c/"
IFS=/
f() {
[ "$2" = "a" ] || fail 2
[ "$#" = "4" ] || warn 2a
}
f $x
)

name=foo.o.o
ext=.o
Expand Down

0 comments on commit b08b5ef

Please sign in to comment.