6 Nov
2009
6 Nov
'09
8:01 p.m.
Forgot to point out that the 'type -p anything' tests might not work as intended.
- if [ ! "$(type -p xdelta3)" ]; then + if ! type xdelta3 &>/dev/null; then
$ type asdf bash: type: asdf: not found $ type -p asdf; echo $? 1 $ $ $ touch ~/bin/asdf; chmod +x ~/bin/asdf $ type asdf asdf is /home/makepkg/bin/asdf $ type -p asdf; echo $? /home/makepkg/bin/asdf 0 $ rm ~/bin/asdf $ $ $ asdf() {
echo 1 } $ type asdf asdf is a function asdf () { echo 1 } $ type -p asdf; echo $? 0
That means you cannot rely on the return code when you want to emulate which. You have to test the length of the resulting string instead.