|
Home > Archive > Unix Shell > September 2007 > [zsh] full path of a script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[zsh] full path of a script
|
|
| Martin Krischik 2007-09-24, 1:26 pm |
| Hello.
currently use the following code to get the full path of the currently
running script:
pushd "$(dirname ${0})";
typeset -r My_Dir=$(pwd);
popd;
But somehow I think there must be a better way. So is there?
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
| |
| Bill Marcum 2007-09-24, 1:26 pm |
| On Mon, 24 Sep 2007 15:11:51 +0200, Martin Krischik
<krischik@users.sourceforge.net> wrote:
>
>
> Hello.
>
> currently use the following code to get the full path of the currently
> running script:
>
> pushd "$(dirname ${0})";
> typeset -r My_Dir=$(pwd);
> popd;
>
> But somehow I think there must be a better way. So is there?
>
> Martin
I think the better way in Unix is not to make your script depend on
knowing its own location, but some ideas on this topic were discussed
recently in this newsgroup.
--
Romance, like alcohol, should be enjoyed, but should not be allowed to
become necessary.
-- Edgar Friedenberg
| |
| Martin Krischik 2007-09-24, 1:26 pm |
| Bill Marcum wrote:
> On Mon, 24 Sep 2007 15:11:51 +0200, Martin Krischik
> <krischik@users.sourceforge.net> wrote:
>
> I think the better way in Unix is not to make your script depend on
> knowing its own location, but some ideas on this topic were discussed
> recently in this newsgroup.
There are additional support files in same directory. Now that alone would
not be a problem. The script also make a pushd into another place from
where it tries to access the named file.
As said: I have a working solution. I was just wonder if there is a better
way. On windows I would use either %@FULL [1] or %@TRUENAME [2] and I am
kind of supprised that Unix has nothing in that direction.
Martin
[1] http://www.jpsoft.com/help/index.htm?f_full.htm
[2] http://www.jpsoft.com/help/index.htm?f_truename.htm
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
| |
| Bill Seivert 2007-09-25, 1:29 am |
| Martin Krischik wrote:
> Bill Marcum wrote:
>
>
>
>
> There are additional support files in same directory. Now that alone would
> not be a problem. The script also make a pushd into another place from
> where it tries to access the named file.
>
> As said: I have a working solution. I was just wonder if there is a better
> way. On windows I would use either %@FULL [1] or %@TRUENAME [2] and I am
> kind of supprised that Unix has nothing in that direction.
>
> Martin
>
> [1] http://www.jpsoft.com/help/index.htm?f_full.htm
> [2] http://www.jpsoft.com/help/index.htm?f_truename.htm
>
Check out the ksh type command and dirname its results.
Bill Seivert
|
|
|
|
|