Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 2008 19:52:49 +0200
From:      "Alexey Shuvaev" <shuvaev@physik.uni-wuerzburg.de>
To:        Jeremy Messenger <mezz7@cox.net>
Cc:        freebsd-ports@freebsd.org
Subject:   x11-wm/fluxbox fluxbox-generate_menu lists all available programs.
Message-ID:  <20080922175249.GA43367@wep4035.physik.uni-wuerzburg.de>

next in thread | raw e-mail | index | archive | help

--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello!

The script fluxbox-generate_menu shipped with current versions of
fluxbox (fluxbox-1.1.0.1_1 and 1.1.1 too, I think) produces
menu with all known programs. The reason for it is find_it* family
of functions used to determine if the program exists (see attached test.sh).
It expects that 'hash' will return non-zero exit code when it cannot find
the command and it is true on linix (some Ubuntu with 'dash', surprisingly
enough, man says it is BSD sh), but not here:

~> uname -a
FreeBSD wep4035.physik.uni-wuerzburg.de 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sun Sep 21 18:51:53 CEST 2008     root@wep4035.physik.uni-wuerzburg.de:/usr/obj/usr/src/sys/GENERIC  amd64

~> ./test.sh ls
Found ls

~> ./test.sh bla-bla-non-existent
Found bla-bla-non-existent

Substituting 'hash' with 'which' solves the problem more or less,
but I am not a sh guru to claim it is 100% correct.

It could be also a sh(1) bug...

Alexey.

--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.sh"

#!/bin/sh
find_it() {
    [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@"
}

find_it $1 echo "Found $1"
exit 0

--8t9RHnE3ZwKMSgU+--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080922175249.GA43367>