Subject: bin/31252: which does not set an exit status
To: None <,>
From: None <>
List: netbsd-bugs
Date: 09/09/2005 07:57:51
>Number:         31252
>Category:       bin
>Synopsis:       /usr/bin/which does not set a proper exit status
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 09 07:57:51 +0000 2005
>Originator:     Stephane Bortzmeyer
>Release:        NetBSD 2.0.1
System: NetBSD preston 2.0.1 NetBSD 2.0.1 (GENERIC) #1: Thu Feb 3 23:32:19 CET 2005 stephane@preston:/usr/obj/sys/arch/sparc64/compile/GENERIC sparc64
Architecture: sparc64
Machine: sparc64
        /usr/bin/which does not set an exit status, it always return zero. This 
        prevents from using which in shell scripts to see if a given command exists.
        Debian or FreeBSD does not have the problem, it seems specific to NetBSD.
        Note: again, I talk about /usr/bin/which not the built-in which in some 

       if /usr/bin/which doesnotexist > /dev/null 2>&1; then echo FOUND;  else echo NOT FOUND; fi  

       On Debian or FreeBSD, it displays (rightly) NOT FOUND but on NetBSD, it 
       displays FOUND.
--- which.csh.orig      2005-09-08 08:54:33.000000000 +0200
+++ which.csh   2005-09-08 08:54:41.000000000 +0200
@@ -77,5 +77,6 @@
     if ( ! $?found ) then
        echo no $arg in $path
+        exit 1