[zsh] full path of a script
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > [zsh] full path of a script




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    [zsh] full path of a script  
Martin Krischik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-07 06: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





[ Post a follow-up to this message ]



    Re: [zsh] full path of a script  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-07 06: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





[ Post a follow-up to this message ]



    Re: [zsh] full path of a script  
Martin Krischik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-24-07 06: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





[ Post a follow-up to this message ]



    Re: [zsh] full path of a script  
Bill Seivert


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-25-07 06: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] an
d 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





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:40 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register