NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/48312: sh(1)'s unset returns error for nonexising variables/functions



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 15 20:05:00 +0000 2013
>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@localhost:/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);



Home | Main Index | Thread Index | Old Index