NetBSD Problem Report #50896

From kre@munnari.OZ.AU  Sat Mar  5 13:18:30 2016
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 076D27ABDC
	for <gnats-bugs@www.NetBSD.org>; Sat,  5 Mar 2016 13:18:30 +0000 (UTC)
Message-Id: <201603051317.u25DHZaM018886@andromeda.noi.kre.to>
Date: Sat, 5 Mar 2016 20:17:35 +0700 (ICT)
From: kre@munnari.OZ.AU
To: gnats-bugs@www.NetBSD.org
Subject: sloppy usage checking in shell builtin 'shift'
X-Send-Pr-Version: 3.95

>Number:         50896
>Category:       bin
>Synopsis:       sloppy usage checking in shell builtin 'shift'
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 05 13:20:00 +0000 2016
>Closed-Date:    Mon Apr 04 12:38:32 +0000 2016
>Last-Modified:  Mon Apr 04 12:38:32 +0000 2016
>Originator:     Robert Elz
>Release:        NetBSD 7.99.26 (all versions up to today (at least))
>Organization:
>Environment:
System: NetBSD andromeda.noi.kre.to 7.99.26 NetBSD 7.99.26 (VBOX64-1.1-20160128) #43: Thu Jan 28 16:09:08 ICT 2016 kre@onyx.coe.psu.ac.th:/usr/obj/current/kernels/amd64/VBOX64 amd64
Architecture: x86_64
Machine: amd64
>Description:

	The shell builtin "shift" takes an optional single numeric
	argument.  Our shell correctly tests whether that arg (if
	given) is in fact numeric, and errors (as it should) if not.
	It also checks it is in range, and errors (as it is allowed
	to do - optional behavior is for shift to return a non-zero
	status) if not.  (It also sub-optimally handles the weird
	case of "shift 0" but that's so rare it isn't worth putting
	in special code to optimize it.)

	What it doesn't do (and no do most other shells it seems,
	though bash does) is object if there is more than 1 arg.

>How-To-Repeat:

	sh -c "set -- a b c; shift 1 foo; echo this output should not appear"

	Since shift is a special builtin, in a non-interactive shell
	the erroneous shift should cause the shell to exit (with an
	error message).

>Fix:
	I have a fix for this (it is trivial), it will be in one of
	the next set of patches that get applied to sh.  This PR is
	really just a placeholder to the cvs commit log can refer to it.

	It is also supremely unimportant, so there will be no great rush
	to get the patch applied... it can wait until there are more to
	happen at the same time.

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50896 CVS commit: src/bin/sh
Date: Tue, 8 Mar 2016 09:08:39 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Tue Mar  8 14:08:39 UTC 2016

 Modified Files:
 	src/bin/sh: options.c

 Log Message:
 PR bin/50896: make shift with more than 1 arg give a usage message, from kre


 To generate a diff of this commit:
 cvs rdiff -u -r1.44 -r1.45 src/bin/sh/options.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 12:38:32 +0000
State-Changed-Why:
Fixed, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.