revision 1.32

date: 2009/02/07 07:24:37;  author: guenther;  state: Exp;  lines: +24 -17
Make built-in echo behave according to POSIX when set -o posix is in effect:
the only option is -n, and only one of those is parsed.

diff from Ingo Schwarze
ok otto@ kili@; manpage changes ok jmc@
This commit is contained in:
tg 2009-03-22 17:52:48 +00:00
parent b20f49adae
commit f4b24be7e1
1 changed files with 26 additions and 19 deletions

15
funcs.c
View File

@ -1,11 +1,11 @@
/* $OpenBSD: c_ksh.c,v 1.31 2008/05/17 23:31:52 sobrado Exp $ */ /* $OpenBSD: c_ksh.c,v 1.32 2009/02/07 07:24:37 guenther Exp $ */
/* $OpenBSD: c_sh.c,v 1.39 2009/01/29 23:27:26 jaredy Exp $ */ /* $OpenBSD: c_sh.c,v 1.39 2009/01/29 23:27:26 jaredy Exp $ */
/* $OpenBSD: c_test.c,v 1.17 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: c_test.c,v 1.17 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.17 2008/03/21 12:51:19 millert Exp $ */ /* $OpenBSD: c_ulimit.c,v 1.17 2008/03/21 12:51:19 millert Exp $ */
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.96 2009/03/22 17:47:36 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.97 2009/03/22 17:52:48 tg Exp $");
/* A leading = means assignments before command are kept; /* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin; * a leading * means a POSIX special builtin;
@ -332,6 +332,12 @@ c_print(const char **wp)
* by default. * by default.
*/ */
wp += 1; wp += 1;
if (Flag(FPOSIX)) {
if (strcmp(*wp, "-n") == 0) {
flags &= ~PO_NL;
wp++;
}
} else
while ((s = *wp) && *s == '-' && s[1]) { while ((s = *wp) && *s == '-' && s[1]) {
while (*++s) while (*++s)
if (*s == 'n') if (*s == 'n')
@ -341,8 +347,9 @@ c_print(const char **wp)
else if (*s == 'E') else if (*s == 'E')
nflags &= ~PO_EXPAND; nflags &= ~PO_EXPAND;
else else
/* bad option: don't use nflags, print /*
* argument * bad option: don't use
* nflags, print argument
*/ */
break; break;
if (*s) if (*s)