NetBSD Problem Report #48312
From dieter.r@pandora.be Tue Oct 15 20:04:48 2013
Return-Path: <dieter.r@pandora.be>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id BB5547130E
for <gnats-bugs@gnats.NetBSD.org>; Tue, 15 Oct 2013 20:04:48 +0000 (UTC)
Message-Id: <20131015200415.8038ABEEBC@simult.amelgem.be>
Date: Tue, 15 Oct 2013 22:04:15 +0200 (CEST)
From: dieter.NetBSD@pandora.be
Reply-To: dieter.NetBSD@pandora.be
To: gnats-bugs@NetBSD.org
Subject: sh(1)'s unset returns error for nonexising variables/functions
X-Send-Pr-Version: 3.95
>Number: 48312
>Category: bin
>Synopsis: sh(1)'s unset returns error for nonexising variables/functions
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 15 20:05:00 +0000 2013
>Closed-Date: Sat Nov 02 17:45:12 +0000 2013
>Last-Modified: Wed Nov 16 17:55:01 +0000 2016
>Originator: dieter roelants
>Release: NetBSD 6.99.23
>Organization:
>Environment:
System: NetBSD simult.amelgem.be 6.99.23 NetBSD 6.99.23 (SIMULT) #87: Sat Sep 21 13:29:24 CEST 2013 dieter@simult.amelgem.be:/build/obj.amd64.current/sys/arch/amd64/compile/SIMULT amd64
Architecture: x86_64
Machine: amd64
>Description:
The usnet special builtin command, as specified on
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
should not return an error and cause the shell to abort
when trying to unset a variable or a function that was not
prviously set. The unset command in /bin/sh currently does.
>How-To-Repeat:
/bin/sh -e -c 'unset -v unset; echo ok'
/bin/sh -e -c 'unset -f unsetfunc; echo ok'
>Fix:
Index: bin/sh/exec.c
===================================================================
RCS file: /cvsroot/src/bin/sh/exec.c,v
retrieving revision 1.44
diff -p -u -r1.44 exec.c
--- bin/sh/exec.c 31 Dec 2012 14:10:15 -0000 1.44
+++ bin/sh/exec.c 15 Oct 2013 19:49:55 -0000
@@ -943,9 +943,8 @@ unsetfunc(char *name)
cmdp->cmdtype == CMDFUNCTION) {
freefunc(cmdp->param.func);
delete_cmd_entry();
- return (0);
}
- return (1);
+ return (0);
}
/*
Index: bin/sh/var.c
===================================================================
RCS file: /cvsroot/src/bin/sh/var.c,v
retrieving revision 1.42
diff -p -u -r1.42 var.c
--- bin/sh/var.c 13 Dec 2012 19:33:23 -0000 1.42
+++ bin/sh/var.c 15 Oct 2013 19:49:55 -0000
@@ -754,7 +754,7 @@ unsetvar(const char *s, int unexport)
vp = find_var(s, &vpp, NULL);
if (vp == NULL)
- return 1;
+ return 0;
if (vp->flags & VREADONLY)
return (1);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48312 CVS commit: src/bin/sh
Date: Fri, 1 Nov 2013 12:49:02 -0400
Module Name: src
Committed By: christos
Date: Fri Nov 1 16:49:02 UTC 2013
Modified Files:
src/bin/sh: exec.c var.c
Log Message:
PR/48312: Dieter Roelands: According to TOG, unset should not return an error
for functions are variables that were not previously set:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/bin/sh/exec.c
cvs rdiff -u -r1.42 -r1.43 src/bin/sh/var.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: dholland@NetBSD.org
State-Changed-When: Sat, 02 Nov 2013 17:45:12 +0000
State-Changed-Why:
christos fixed it, thanks
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48312 CVS commit: [netbsd-6] src/bin/sh
Date: Wed, 16 Nov 2016 17:53:57 +0000
Module Name: src
Committed By: snj
Date: Wed Nov 16 17:53:57 UTC 2016
Modified Files:
src/bin/sh [netbsd-6]: exec.c var.c
Log Message:
Pull up following revision(s) (requested by dholland in ticket #1412):
bin/sh/exec.c: revision 1.45
bin/sh/var.c: revision 1.43
PR/48312: Dieter Roelants: According to TOG, unset should not return an error
for functions are variables that were not previously set:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.20.1 src/bin/sh/exec.c
cvs rdiff -u -r1.40 -r1.40.4.1 src/bin/sh/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(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-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.