On Sun, 2 Nov 2003, Muli Ben-Yehuda wrote:
> On Sun, Nov 02, 2003 at 03:50:25AM -0500, Behdad Esfahbod wrote:
>
> > > APP=`which app`
> > > DIR=`dirname $APP`
> > > cd $DIR && echo $DIR && $APP
> >
> > Unfortunately fails almost all the time, unless APP is something
> > like X or Java or some huge other thing that has its own share in
> > $PATH.
>
> Huh? if app is a standalone executable, it works. If app needs an
> interpreter to run (i.e. 'java foo' or '/bin/bash myscript'), you will
> need to adapt the snippet above to it.
An standalone executable works, but I can't see why would you
want to set your CWD to /usr/bin. It happens many times to me to
create /usr/local/myapp, and do ln -s /usr/local/myapp/bin/*
/usr/local/bin/, which is when my script works (to find
/usr/local/myapp perhaps).
> >Otherwise, perhaps you are trying a symlink is a public
> > bin directory (/usr/bin) which points to your own bin
> > (/usr/MyApp/bin). I probably would suggest (and actually use)
> > this one:
> >
> > APP="myApp"
> > BASEAPP=`\which "$APP" 2>/dev/null`
>
> people who alias 'which' to something else deserve what they get ;-)
What do you do when redhat does that? BTW, it seems to me like
a bug in which(1), either in code, or documentation:
####
[EMAIL PROTECTED] behdad]$ man which | tail -54 | head -2
--tty-only
Stop processing options on the right if not on tty.
[EMAIL PROTECTED] behdad]$ alias | grep which
alias which='alias | /usr/bin/which --tty-only --read-alias
--show-dot --show-tilde'
[EMAIL PROTECTED] behdad]$ which giveaway
~/bin/giveaway
[EMAIL PROTECTED] behdad]$ echo "`which giveaway`"
/home/behdad/bin/giveaway
[EMAIL PROTECTED] behdad]$ which ls
alias ls='ls --color=tty'
/bin/ls
[EMAIL PROTECTED] behdad]$ echo "`which ls`"
alias ls='ls --color=tty'
/bin/ls
[EMAIL PROTECTED] behdad]$ echo "`\which ls`"
/bin/ls
[EMAIL PROTECTED] behdad]$
###
But isn't it supposed to ignore --read-alias like it ignoring
--show-tilde??
> > BASEAPP=`readlink -f "$APP"`
>
> interesing twist, but I'm not sure it's necessary.
The clean way of setting home dirs etc is perhaps through
configure (no runtime then :( ).
> Cheers,
> Muli
Cheers,
behdad
PS. Perhaps it's too soon, but: "Everybody, come to Ottawa Linux
Symposium '2004 http://www.linuxsymposium/. It's a great event".
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]