mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
Fix for PR#1287. This makes sh behave sensibly in case statements in the
face of aliases. Note, bash doesn't do aliases while running scripts, but "real" ksh does.. Also: Reduce redundant .Nm macros in (unused) bltin/echo.1 nuke error2, it's hardly used. More -Wall cleanups dont do certain history operations if NO_HISTORY defined handle quad_t's from resource limits Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)
This commit is contained in:
parent
b30b117473
commit
4417f6297d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18018
@ -34,7 +34,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)echo.1 8.2 (Berkeley) 5/4/95
|
||||
.\" $Id: echo.1,v 1.2 1994/09/24 02:58:27 davidg Exp $
|
||||
.\" $Id: echo.1,v 1.3 1996/09/01 10:22:15 peter Exp $
|
||||
.\"
|
||||
.Dd May 4, 1995
|
||||
.Dt ECHO 1
|
||||
@ -43,11 +43,11 @@
|
||||
.Nm echo
|
||||
.Nd produce message in a shell script
|
||||
.Sh SYNOPSIS
|
||||
.Nm echo
|
||||
.Nm
|
||||
.Op Fl n | Fl e
|
||||
.Ar args...
|
||||
.Sh DESCRIPTION
|
||||
.Nm Echo
|
||||
.Nm
|
||||
prints its arguments on the standard output, separated by spaces.
|
||||
Unless the
|
||||
.Fl n
|
||||
@ -55,7 +55,7 @@ option is present, a newline is output following the arguments.
|
||||
The
|
||||
.Fl e
|
||||
option causes
|
||||
.Nm echo
|
||||
.Nm
|
||||
to treat the escape sequences specially, as described in the following
|
||||
paragraph.
|
||||
The
|
||||
@ -77,7 +77,7 @@ A backspace character is output.
|
||||
.It Li \ec
|
||||
Subsequent output is suppressed. This is normally used at the end of the
|
||||
last argument to suppress the trailing newline that
|
||||
.Nm echo
|
||||
.Nm
|
||||
would otherwise output.
|
||||
.It Li \ef
|
||||
Output a form feed.
|
||||
@ -107,6 +107,6 @@ differs from the
|
||||
C language mechanism.
|
||||
.Pp
|
||||
There is no way to force
|
||||
.Nm echo
|
||||
.Nm
|
||||
to treat its arguments literally, rather than interpreting them as
|
||||
options and escape sequences.
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: error.c,v 1.3 1995/05/30 00:07:10 rgrimes Exp $
|
||||
* $Id: error.c,v 1.4 1996/09/01 10:19:53 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -112,14 +112,6 @@ onint() {
|
||||
|
||||
|
||||
|
||||
void
|
||||
error2(a, b)
|
||||
char *a, *b;
|
||||
{
|
||||
error("%s: %s", a, b);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Error is called to raise the error exception. If the first argument
|
||||
* is not NULL then error prints an error message using printf style
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)error.h 8.2 (Berkeley) 5/4/95
|
||||
* $Id: error.h,v 1.2 1994/09/24 02:57:28 davidg Exp $
|
||||
* $Id: error.h,v 1.3 1996/09/01 10:19:55 peter Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -90,7 +90,6 @@ extern char *commandname; /* name of command--printed on error */
|
||||
|
||||
void exraise __P((int));
|
||||
void onint __P((void));
|
||||
void error2 __P((char *, char *));
|
||||
void error __P((char *, ...));
|
||||
char *errmsg __P((int, int));
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: exec.c,v 1.4 1995/05/30 00:07:12 rgrimes Exp $
|
||||
* $Id: exec.c,v 1.5 1996/09/01 10:20:02 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -132,7 +132,7 @@ shellexec(argv, envp, path, index)
|
||||
stunalloc(cmdname);
|
||||
}
|
||||
}
|
||||
error2(argv[0], errmsg(e, E_EXEC));
|
||||
error("%s: %s", argv[0], errmsg(e, E_EXEC));
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: input.c,v 1.4 1995/11/03 18:50:14 peter Exp $
|
||||
* $Id: input.c,v 1.5 1996/09/01 10:20:18 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -178,14 +178,13 @@ pread()
|
||||
retry:
|
||||
if (parsefile->fd == 0 && el) {
|
||||
const char *rl_cp;
|
||||
int len;
|
||||
|
||||
rl_cp = el_gets(el, &nr);
|
||||
if (rl_cp == NULL)
|
||||
nr = 0;
|
||||
else {
|
||||
/* XXX - BUFSIZE should redesign so not necessary */
|
||||
strcpy(parsenextc, rl_cp);
|
||||
(void)strcpy(parsenextc, rl_cp);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -286,13 +285,13 @@ preadbuffer() {
|
||||
savec = *q;
|
||||
*q = '\0';
|
||||
|
||||
|
||||
#ifndef NO_HISTORY
|
||||
if (parsefile->fd == 0 && hist && something) {
|
||||
INTOFF;
|
||||
history(hist, whichprompt == 1 ? H_ENTER : H_ADD, parsenextc);
|
||||
INTON;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (vflag) {
|
||||
out2str(parsenextc);
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: jobs.c,v 1.5 1996/09/01 10:20:24 peter Exp $
|
||||
* $Id: jobs.c,v 1.6 1996/09/03 13:35:09 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -52,6 +52,7 @@ static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "shell.h"
|
||||
#if JOBS
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: memalloc.c,v 1.2 1994/09/24 02:57:50 davidg Exp $
|
||||
* $Id: memalloc.c,v 1.3 1996/09/01 10:20:42 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -207,7 +207,7 @@ popstackmark(mark)
|
||||
void
|
||||
growstackblock() {
|
||||
char *p;
|
||||
int newlen = stacknleft * 2 + 100;
|
||||
int newlen = ALIGN(stacknleft * 2 + 100);
|
||||
char *oldspace = stacknxt;
|
||||
int oldlen = stacknleft;
|
||||
struct stack_block *sp;
|
||||
@ -226,7 +226,7 @@ growstackblock() {
|
||||
p = stalloc(newlen);
|
||||
memcpy(p, oldspace, oldlen);
|
||||
stacknxt = p; /* free the space */
|
||||
stacknleft += ALIGN(newlen); /* we just allocated */
|
||||
stacknleft += newlen; /* we just allocated */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: miscbltin.c,v 1.5 1996/09/01 10:20:46 peter Exp $
|
||||
* $Id: miscbltin.c,v 1.6 1996/09/03 13:35:10 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -51,6 +51,7 @@ static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "shell.h"
|
||||
#include "options.h"
|
||||
@ -292,7 +293,7 @@ ulimitcmd(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register int c;
|
||||
quad_t val;
|
||||
quad_t val = 0;
|
||||
enum { SOFT = 0x1, HARD = 0x2 }
|
||||
how = SOFT | HARD;
|
||||
const struct limits *l;
|
||||
@ -365,7 +366,7 @@ ulimitcmd(argc, argv)
|
||||
else
|
||||
{
|
||||
val /= l->factor;
|
||||
out1fmt("%ld\n", (long) val);
|
||||
out1fmt("%qd\n", (quad_t) val);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -393,7 +394,7 @@ ulimitcmd(argc, argv)
|
||||
else
|
||||
{
|
||||
val /= l->factor;
|
||||
out1fmt("%ld\n", (long) val);
|
||||
out1fmt("%qd\n", (quad_t) val);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mystring.c,v 1.2 1994/09/24 02:57:59 davidg Exp $
|
||||
* $Id: mystring.c,v 1.3 1996/09/01 10:21:03 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -117,7 +117,7 @@ number(s)
|
||||
{
|
||||
|
||||
if (! is_number(s))
|
||||
error2("Illegal number", (char *)s);
|
||||
error("Illegal number: %s", (char *)s);
|
||||
return atoi(s);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: output.c,v 1.2 1994/09/24 02:58:06 davidg Exp $
|
||||
* $Id: output.c,v 1.3 1996/09/01 10:21:23 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -52,6 +52,7 @@ static char sccsid[] = "@(#)output.c 8.2 (Berkeley) 5/4/95";
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h> /* quad_t */
|
||||
|
||||
#include <stdio.h> /* defines BUFSIZ */
|
||||
#include <string.h>
|
||||
@ -337,7 +338,7 @@ fmtstr(va_alist)
|
||||
* Formatted output. This routine handles a subset of the printf formats:
|
||||
* - Formats supported: d, u, o, X, s, and c.
|
||||
* - The x format is also accepted but is treated like X.
|
||||
* - The l modifier is accepted.
|
||||
* - The l and q modifiers is accepted.
|
||||
* - The - and # flags are accepted; # only works with the o format.
|
||||
* - Width and precision may be specified with any format except c.
|
||||
* - An * may be given for the width or precision.
|
||||
@ -349,7 +350,7 @@ fmtstr(va_alist)
|
||||
#define TEMPSIZE 24
|
||||
|
||||
#ifdef __STDC__
|
||||
static const char digit[16] = "0123456789ABCDEF";
|
||||
static const char digit[] = "0123456789ABCDEF";
|
||||
#else
|
||||
static const char digit[17] = "0123456789ABCDEF";
|
||||
#endif
|
||||
@ -368,10 +369,11 @@ doformat(dest, f, ap)
|
||||
int width;
|
||||
int prec;
|
||||
int islong;
|
||||
int isquad;
|
||||
char *p;
|
||||
int sign;
|
||||
long l;
|
||||
unsigned long num;
|
||||
quad_t l;
|
||||
u_quad_t num;
|
||||
unsigned base;
|
||||
int len;
|
||||
int size;
|
||||
@ -387,6 +389,7 @@ doformat(dest, f, ap)
|
||||
width = 0;
|
||||
prec = -1;
|
||||
islong = 0;
|
||||
isquad = 0;
|
||||
for (;;) {
|
||||
if (*f == '-')
|
||||
flushleft++;
|
||||
@ -418,11 +421,16 @@ doformat(dest, f, ap)
|
||||
if (*f == 'l') {
|
||||
islong++;
|
||||
f++;
|
||||
} else if (*f == 'q') {
|
||||
isquad++;
|
||||
f++;
|
||||
}
|
||||
switch (*f) {
|
||||
case 'd':
|
||||
if (islong)
|
||||
l = va_arg(ap, long);
|
||||
else if (isquad)
|
||||
l = va_arg(ap, quad_t);
|
||||
else
|
||||
l = va_arg(ap, int);
|
||||
sign = 0;
|
||||
@ -447,6 +455,8 @@ doformat(dest, f, ap)
|
||||
sign = 0;
|
||||
if (islong)
|
||||
num = va_arg(ap, unsigned long);
|
||||
else if (isquad)
|
||||
num = va_arg(ap, u_quad_t);
|
||||
else
|
||||
num = va_arg(ap, unsigned int);
|
||||
number: /* process a number */
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: parser.c,v 1.11 1996/02/03 13:27:55 joerg Exp $
|
||||
* $Id: parser.c,v 1.12 1996/09/01 10:21:31 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -95,6 +95,8 @@ struct heredoc *heredoc;
|
||||
int quoteflag; /* set if (part of) last token was quoted */
|
||||
int startlinno; /* line # where last token started */
|
||||
|
||||
/* XXX When 'noaliases' is set to one, no alias expansion takes place. */
|
||||
static int noaliases = 0;
|
||||
|
||||
#define GDB_HACK 1 /* avoid local declarations which gdb can't handle */
|
||||
#ifdef GDB_HACK
|
||||
@ -414,6 +416,7 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
|
||||
if (lasttoken != TWORD || ! equal(wordtext, "in"))
|
||||
synerror("expecting \"in\"");
|
||||
cpp = &n1->ncase.cases;
|
||||
noaliases = 1; /* turn off alias expansion */
|
||||
checkkwd = 2, readtoken();
|
||||
do {
|
||||
*cpp = cp = (union node *)stalloc(sizeof (struct nclist));
|
||||
@ -431,18 +434,19 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
|
||||
}
|
||||
ap->narg.next = NULL;
|
||||
if (lasttoken != TRP)
|
||||
synexpect(TRP);
|
||||
noaliases = 0, synexpect(TRP);
|
||||
cp->nclist.body = list(0);
|
||||
|
||||
checkkwd = 2;
|
||||
if ((t = readtoken()) != TESAC) {
|
||||
if (t != TENDCASE)
|
||||
synexpect(TENDCASE);
|
||||
noaliases = 0, synexpect(TENDCASE);
|
||||
else
|
||||
checkkwd = 2, readtoken();
|
||||
}
|
||||
cpp = &cp->nclist.next;
|
||||
} while(lasttoken != TESAC);
|
||||
noaliases = 0; /* reset alias expansion */
|
||||
*cpp = NULL;
|
||||
checkkwd = 1;
|
||||
break;
|
||||
@ -712,7 +716,8 @@ readtoken() {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if ((ap = lookupalias(wordtext, 1)) != NULL) {
|
||||
if (noaliases == 0 &&
|
||||
(ap = lookupalias(wordtext, 1)) != NULL) {
|
||||
pushstring(ap->val, strlen(ap->val), ap);
|
||||
checkkwd = savecheckkwd;
|
||||
goto top;
|
||||
|
@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
|
||||
.\" $Id: sh.1,v 1.6 1996/08/29 18:06:10 wosch Exp $
|
||||
.\" $Id: sh.1,v 1.7 1996/09/01 10:21:39 peter Exp $
|
||||
.\"
|
||||
.na
|
||||
.TH SH 1
|
||||
@ -1281,7 +1281,7 @@ resets trapped (but not ignored) signals to the
|
||||
default action. The trap command has no effect on
|
||||
signals that were ignored on entry to the shell.
|
||||
.TP
|
||||
ulimit [ -HSacdflmnpst ] [ limit ]
|
||||
ulimit [ -HSacdflmnust ] [ limit ]
|
||||
Set or display resource limits (see getrlimit(2)).
|
||||
If ``limit'' is specified, the named resource will be set;
|
||||
otherwise the current resource value will be displayed.
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: show.c,v 1.2 1994/09/24 02:58:16 davidg Exp $
|
||||
* $Id: show.c,v 1.3 1996/09/01 10:21:43 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -341,6 +341,7 @@ trputs(s)
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
trstring(s)
|
||||
char *s;
|
||||
@ -348,7 +349,6 @@ trstring(s)
|
||||
register char *p;
|
||||
char c;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (tracefile == NULL)
|
||||
return;
|
||||
putc('"', tracefile);
|
||||
@ -380,8 +380,8 @@ backslash: putc('\\', tracefile);
|
||||
}
|
||||
}
|
||||
putc('"', tracefile);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
@ -405,13 +405,13 @@ trargs(ap)
|
||||
|
||||
void
|
||||
opentrace() {
|
||||
#ifdef DEBUG
|
||||
char s[100];
|
||||
char *getenv();
|
||||
#ifdef O_APPEND
|
||||
int flags;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!debug)
|
||||
return;
|
||||
#ifdef not_this_way
|
||||
|
Loading…
Reference in New Issue
Block a user