summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAjaykumar Venkatesulu <Ajaykumar.Venkatesulu@Sun.COM>2010-06-28 10:51:27 +0530
committerAjaykumar Venkatesulu <Ajaykumar.Venkatesulu@Sun.COM>2010-06-28 10:51:27 +0530
commit8944aeb298aecab3a877e11eb26f324d29fc0f6b (patch)
tree2a8f57a41c60ff0a8ab1a9cff24ee8c83160e2a5
parenta9b510629bb89d580bb11ce66254ff44bf4959d1 (diff)
downloadillumos-gate-8944aeb298aecab3a877e11eb26f324d29fc0f6b.tar.gz
6879678 bourne shell echo built-in misinterprets arguments beginning with -n if /usr/ucb is before /usr/bin
-rw-r--r--usr/src/cmd/sh/echo.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/usr/src/cmd/sh/echo.c b/usr/src/cmd/sh/echo.c
index d9717c0006..7d7b62bf84 100644
--- a/usr/src/cmd/sh/echo.c
+++ b/usr/src/cmd/sh/echo.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -21,15 +20,13 @@
*/
/*
- * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
@@ -65,7 +62,8 @@ echo(int argc, unsigned char **argv)
#endif /* _iBCS2 */
nflg = 0;
- if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'n') {
+ if (argc > 1 && argv[1][0] == '-' &&
+ argv[1][1] == 'n' && !argv[1][2]) {
nflg++;
argc--;
argv++;
@@ -93,7 +91,7 @@ echo(int argc, unsigned char **argv)
#ifdef _iBCS2
if (do_sysv3) {
if (argc > 1 && argv[1][0] == '-' &&
- argv[1][1] == 'n') {
+ argv[1][1] == 'n' && !argv[1][2]) {
nflg++;
/* Step past the -n */
argc--;
@@ -106,7 +104,7 @@ echo(int argc, unsigned char **argv)
sigchk();
for (cp = argv[i]; *cp; cp++) {
if ((len = mbtowc(&wc, (char *)cp,
- MB_LEN_MAX)) <= 0) {
+ MB_LEN_MAX)) <= 0) {
prc_buff(*cp);
continue;
}
@@ -145,7 +143,7 @@ echo(int argc, unsigned char **argv)
case '0':
j = wd = 0;
while ((*++cp >= '0' &&
- *cp <= '7') && j++ < 3) {
+ *cp <= '7') && j++ < 3) {
wd <<= 3;
wd |= (*cp - '0');
}