Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Converting relative paths to full
- X-seq: zsh-users 26900
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Gürkan <seqizz@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Converting relative paths to full
- Date: Tue, 10 Aug 2021 13:44:51 -0700
- Archived-at: <https://zsh.org/users/26900>
- In-reply-to: <CAG3b68EvH4eehWYEi5_PgwQF+LG1=tXObYbzOgUv==6Xx77sSQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAG3b68EvH4eehWYEi5_PgwQF+LG1=tXObYbzOgUv==6Xx77sSQ@mail.gmail.com>
On Tue, Aug 10, 2021 at 12:53 PM Gürkan <seqizz@xxxxxxxxx> wrote:
>
> I'm trying to create a function to catch relative paths of
> files/directories and converting those to full paths
The hard part is identifying what argument strings are meant to be
interpreted as file names.
Assuming you've done that, you can convert to an absolute path pretty
easily. Suppose for example that you know $3 is a file name.
3=${3:P}
See also :a and :A for slightly different interpretations of a fully
elucidated file path.
In cases where you have an argument like "--file=name" you can do:
3=${3%=*}=${${3#*=}:P}
If it's just "-fname" and you want a result like "-f$PWD/name" you're
on your own ... there's no generic way to know which commands have
that sort of argument format or which option letters introduce it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author