From b08b5efcef8ab9cf9d532fdd50994e1092144924 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 24 Jul 2019 02:45:47 -0400 Subject: [PATCH] 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 --- minimal/do | 2 +- t/shelltest.od | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/minimal/do b/minimal/do index 258a25e..557c433 100755 --- a/minimal/do +++ b/minimal/do @@ -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%/}")/ diff --git a/t/shelltest.od b/t/shelltest.od index 948a36c..c911b89 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -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