From e2c4bce5694336c052a16c7f42b76dbd76dbfec9 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 10 Dec 2004 16:01:38 +0000 Subject: [PATCH] behaviour change: jaredy@openbsd informs me they strip trailing IFS non-whitespace "because many sh-derived shells have this behavious", and me checking for ksh88 on Solaris confirms it. So, for the sake of compatibility to AT&T ksh, change it and document the change. --- eval.c | 6 +++--- ksh.1tbl | 14 ++++++-------- tests/ifs.t | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/eval.c b/eval.c index 485de46..a004578 100644 --- a/eval.c +++ b/eval.c @@ -1,4 +1,4 @@ -/** $MirBSD: eval.c,v 1.9 2004/12/09 16:32:09 tg Exp $ */ +/** $MirBSD: eval.c,v 1.10 2004/12/10 16:01:34 tg Exp $ */ /* $OpenBSD: eval.c,v 1.16 2004/12/08 21:23:18 millert Exp $ */ /* @@ -10,7 +10,7 @@ #include "ksh_dir.h" #include "ksh_stat.h" -__RCSID("$MirBSD: eval.c,v 1.9 2004/12/09 16:32:09 tg Exp $"); +__RCSID("$MirBSD: eval.c,v 1.10 2004/12/10 16:01:34 tg Exp $"); /* * string expansion @@ -556,7 +556,7 @@ expand(char *cp, XPtrV *wp, int f) * doesn't do this, but POSIX does). */ if (word == IFS_WORD - || (!ctype(c, C_IFSWS) && word == IFS_NWS)) + || (!ctype(c, C_IFSWS) && c && word == IFS_NWS)) { char *p; diff --git a/ksh.1tbl b/ksh.1tbl index 8832ee9..ac652c0 100644 --- a/ksh.1tbl +++ b/ksh.1tbl @@ -1,4 +1,4 @@ -.\" $MirBSD: ksh.1tbl,v 1.44 2004/12/07 18:01:50 tg Exp $ +.\" $MirBSD: ksh.1tbl,v 1.45 2004/12/10 16:01:34 tg Exp $ .\" $OpenBSD: ksh.1tbl,v 1.79 2004/12/04 07:05:13 jaredy Exp $ .\" $OpenBSD: sh.1tbl,v 1.52 2004/11/09 21:56:54 jmc Exp $ .\" @@ -1015,14 +1015,12 @@ whitespace characters, delimit a field. As a special case, leading and trailing .Ev IFS -whitespace is stripped (i.e., no leading or trailing empty field is created by -it); leading or trailing +whitespace and trailing +.Ev IFS +non-whitespace is stripped (i.e., no leading or trailing +empty field is created by it); leading or trailing .Pf non- Ev IFS -whitespace as well as leading or trailing -.Ev IFS -non-whitespace (after stripping -.Ev IFS -whitespace) does create an empty field. +whitespace does create an empty field. .Pp Example: If .Ev IFS diff --git a/tests/ifs.t b/tests/ifs.t index 387020b..c6be027 100644 --- a/tests/ifs.t +++ b/tests/ifs.t @@ -147,12 +147,12 @@ stdin: showargs 10 ${FOO-`echo -n h:i`th:ere} showargs 11 "${FOO-`echo -n h:i`th:ere}" expected-stdout: - 1: [] [b] [] [] + 1: [] [b] [] 2: [:b::] - <3> <> <> <> + <3> <> <> <4> <:b::> - 5: [a] [b] [] - <6> <> + 5: [a] [b] + <6> 7: [a] [] [c] <8> <> 9: [h] [ith] [ere]