Browse Source

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
pull/31/head redo-0.42
Avery Pennarun 1 year ago
parent
commit
b08b5efcef
2 changed files with 10 additions and 1 deletions
  1. +1
    -1
      minimal/do
  2. +9
    -0
      t/shelltest.od

+ 1
- 1
minimal/do View File

@ -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%/}")/


+ 9
- 0
t/shelltest.od View File

@ -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


Loading…
Cancel
Save