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:
6
eval.c
6
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 $ */
|
/* $OpenBSD: eval.c,v 1.16 2004/12/08 21:23:18 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#include "ksh_dir.h"
|
#include "ksh_dir.h"
|
||||||
#include "ksh_stat.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
|
* string expansion
|
||||||
@ -556,7 +556,7 @@ expand(char *cp, XPtrV *wp, int f)
|
|||||||
* doesn't do this, but POSIX does).
|
* doesn't do this, but POSIX does).
|
||||||
*/
|
*/
|
||||||
if (word == IFS_WORD
|
if (word == IFS_WORD
|
||||||
|| (!ctype(c, C_IFSWS) && word == IFS_NWS))
|
|| (!ctype(c, C_IFSWS) && c && word == IFS_NWS))
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
|
14
ksh.1tbl
14
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: 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 $
|
.\" $OpenBSD: sh.1tbl,v 1.52 2004/11/09 21:56:54 jmc Exp $
|
||||||
.\"
|
.\"
|
||||||
@ -1015,14 +1015,12 @@ whitespace
|
|||||||
characters, delimit a field.
|
characters, delimit a field.
|
||||||
As a special case, leading and trailing
|
As a special case, leading and trailing
|
||||||
.Ev IFS
|
.Ev IFS
|
||||||
whitespace is stripped (i.e., no leading or trailing empty field is created by
|
whitespace and trailing
|
||||||
it); leading or 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
|
.Pf non- Ev IFS
|
||||||
whitespace as well as leading or trailing
|
whitespace does create an empty field.
|
||||||
.Ev IFS
|
|
||||||
non-whitespace (after stripping
|
|
||||||
.Ev IFS
|
|
||||||
whitespace) does create an empty field.
|
|
||||||
.Pp
|
.Pp
|
||||||
Example: If
|
Example: If
|
||||||
.Ev IFS
|
.Ev IFS
|
||||||
|
@ -147,12 +147,12 @@ stdin:
|
|||||||
showargs 10 ${FOO-`echo -n h:i`th:ere}
|
showargs 10 ${FOO-`echo -n h:i`th:ere}
|
||||||
showargs 11 "${FOO-`echo -n h:i`th:ere}"
|
showargs 11 "${FOO-`echo -n h:i`th:ere}"
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
1: [] [b] [] []
|
1: [] [b] []
|
||||||
2: [:b::]
|
2: [:b::]
|
||||||
<3> <> <b> <> <>
|
<3> <> <b> <>
|
||||||
<4> <:b::>
|
<4> <:b::>
|
||||||
5: [a] [b] []
|
5: [a] [b]
|
||||||
<6> <a> <b> <>
|
<6> <a> <b>
|
||||||
7: [a] [] [c]
|
7: [a] [] [c]
|
||||||
<8> <a> <> <c>
|
<8> <a> <> <c>
|
||||||
9: [h] [ith] [ere]
|
9: [h] [ith] [ere]
|
||||||
|
Reference in New Issue
Block a user