Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Converting relative paths to full



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