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.
This commit is contained in:
tg 2004-12-10 16:01:38 +00:00
parent 2aaea3d8d2
commit e2c4bce569
3 changed files with 13 additions and 15 deletions

6
eval.c
View File

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

View File

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

View File

@ -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> <> <b> <> <>
<3> <> <b> <>
<4> <:b::>
5: [a] [b] []
<6> <a> <b> <>
5: [a] [b]
<6> <a> <b>
7: [a] [] [c]
<8> <a> <> <c>
9: [h] [ith] [ere]