NetBSD-Bugs archive

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

bin/56491: /bin/sh hash command "hash foobar" says foobar not found, and exit(1)

>Number:         56491
>Category:       bin
>Synopsis:       /bin/sh hash command "hash foobar" says foobar not found, and exit(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 09 15:20:01 +0000 2021
>Originator:     Robert Elz
>Release:        NetBSD 9.99.88
System: NetBSD 9.99.88 NetBSD 9.99.88 (1.1-20210916) #60: Thu Sep 16 23:18:32 UTC 2021 amd64
Architecture: x86_64
Machine: amd64
	The hash builtin utiliity in /bin/sh when run naming a utility
	to be added to the hash table, and the utility is not found,
	writes an error message to stderr indicating that the utility
	was not found, but goes on to exit(0).

	POSIX (for most standard utilities, including this one) specifies that
	when stderr is used, the utility must not exit(0) (sometimes more
	specific exit status conditions, but never 0 in that case.

	It isn't clear (yet) whether the correct fix is to exit(1) when
	a utility was not found, or to suppress the error message.

	All ksh variants simply ignore "not found" - no error message,
	and the exit status is 0.   All other (known and relevant) shells
	(bash dash, freebsd, yash, zsh, bosh) write an error message,
	and eventually exit(1).

	Assuming there is o foobar command in any directory in PATH

		hash foobar
		echo $?

	TBD (either way is a trivial change).

Home | Main Index | Thread Index | Old Index