From: bsh on
On Jul 19, 12:44 pm, gaze...(a)shell.xmission.com (Kenny McCormack)
wrote:
> Outer problem: I have an app that only works if fed a full path to the file.
> It will not work with a relative path (known, documented limitation in
> the app)
>
> So, I setup a shell alias to call the app, prepending the value of $PWD
> to the filename argument passed.  This works fine - especially in the most
> common use case, which is passing in a simple file name (to invoke the
> app on a file in the current directory) - but I have a couple of niggling
> issues with this:
>
>     1) It won't work right if I happen to invoke the alias with an absolute
>         path.  Because then, the app would get something like:
>             /path/to/here/path/from/root/file
>         So, it would be nice to plug this small hole.

Search on this group for my script "resolvepath". It's robust,
reasonably
portable, and has additional options, such as resolving symlinks and
path lookups.

Resolvepath "canonicizes" resultant pathnames, and does the "obvious"
if given an absolute path as an argument.

>     2) I'm just curious if there is a better, more built-in way to do
>         this - some shell tool (something along the lines of basename)
>         maybe.

Not in canonical Unix. Which is the reason I wrote resolvelink.

=Brian
From: John Kelly on
On Sun, 1 Aug 2010 14:49:04 -0700 (PDT), bsh
<brian_hiles(a)rocketmail.com> wrote:

>On Jul 19, 12:44�pm, gaze...(a)shell.xmission.com (Kenny McCormack)
>wrote:
>> Outer problem: I have an app that only works if fed a full path to the file.
>> It will not work with a relative path (known, documented limitation in
>> the app)
>>
>> So, I setup a shell alias to call the app, prepending the value of $PWD
>> to the filename argument passed. �This works fine - especially in the most
>> common use case, which is passing in a simple file name (to invoke the
>> app on a file in the current directory) - but I have a couple of niggling
>> issues with this:
>>
>> � � 1) It won't work right if I happen to invoke the alias with an absolute
>> � � � � path. �Because then, the app would get something like:
>> � � � � � � /path/to/here/path/from/root/file
>> � � � � So, it would be nice to plug this small hole.
>
>Search on this group for my script "resolvepath". It's robust,
>reasonably
>portable, and has additional options, such as resolving symlinks and
>path lookups.
>
>Resolvepath "canonicizes" resultant pathnames, and does the "obvious"
>if given an absolute path as an argument.
>
>> � � 2) I'm just curious if there is a better, more built-in way to do
>> � � � � this - some shell tool (something along the lines of basename)
>> � � � � maybe.
>
>Not in canonical Unix. Which is the reason I wrote resolvelink.
>
>=Brian

I think the bash dist has a loadable builtin called realpath in
examples. But you have to roll you own installation from the tarball
for that.



--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php