Hello Jonathan,

  I was reading through your release notes (blog entry) here:
http://www.perkin.org.uk/posts/whats-new-in-pkgsrc-2013Q2.html
and stumbled upon this bit of information:

  : Also on OmniOS 'od' is located in a different location
  $ sed -i -e 's,/usr/bin/od,/usr/gnu/bin/od,' /opt/local/bin/startx

  I believe (didn't try yet) that /opt/local/bin/startx is a script;
wouldn't it be more correct to have it handle setting the proper
environment - either as force-prepending its PATH defaults (and
not using full paths to commands), or perhaps defining variables
for the full paths to binaries?

  A pattern like this might be used for this particular example:



### Note we don't preset an OD="" so that one can be inherited from env
for F in /usr/bin/od /usr/gnu/bin/od ; do
        [ x"$OD" = x -a -x "$F" ] && OD="$F"
        ### An ultimate test might be to try executing the program with
        ### an expected zero-return, like "$OD < /dev/null > /dev/null"
        ### to filter out broken binaries, missing dynamic libs, etc.
done
### The "which" command can be used to fall back to a binary in PATH:
[ x"$OD" = x ] && F="`which od`" && case "$F" in
        /*) [ -x "$F" ] && OD="$F" ;;
esac
### Sanity check: we have a good variable
[ x"$OD" = x -o ! -x "$OD" ] && \
        echo "ERROR: OD not available: '$OD'" >&2 && exit 1

This way you have your $OD set to a sane value, detection of which
you might further enhance by logic that would consider per-distro
nuances. And this would be a least-surprise (and less manual work)
for users on various platforms.

With some "eval" trickery this pattern can be turned into a shell
function (Bourne sh, bash, maybe others) to set the provided shell
variable to the matched one of provided binaries.

HTH,
//Jim Klimov


-------------------------------------------
illumos-discuss
Archives: https://www.listbox.com/member/archive/182180/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182180/21175430-2e6923be
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=21175430&id_secret=21175430-6a77cda4
Powered by Listbox: http://www.listbox.com

Reply via email to