From bff14f8dfa345981cccd9f0503479c322439b7f5 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 8 Mar 2016 14:08:39 +0000 Subject: [PATCH] PR bin/50896: make shift with more than 1 arg give a usage message, from kre --- bin/sh/options.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/sh/options.c b/bin/sh/options.c index 7879769f4920..341c8261e0e3 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.44 2016/02/24 14:38:40 christos Exp $ */ +/* $NetBSD: options.c,v 1.45 2016/03/08 14:08:39 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: options.c,v 1.44 2016/02/24 14:38:40 christos Exp $"); +__RCSID("$NetBSD: options.c,v 1.45 2016/03/08 14:08:39 christos Exp $"); #endif #endif /* not lint */ @@ -335,6 +335,8 @@ shiftcmd(int argc, char **argv) int n; char **ap1, **ap2; + if (argc > 2) + error("Usage: shift [n]"); n = 1; if (argc > 1) n = number(argv[1]); @@ -347,7 +349,8 @@ shiftcmd(int argc, char **argv) ckfree(*ap1); } ap2 = shellparam.p; - while ((*ap2++ = *ap1++) != NULL); + while ((*ap2++ = *ap1++) != NULL) + continue; shellparam.optnext = NULL; INTON; return 0;