zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Gürkan <seqizz@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Converting relative paths to full
Date: Tue, 10 Aug 2021 13:44:51 -0700	[thread overview]
Message-ID: <CAH+w=7Ygc0+gXvCeVw+1Q0B_1X3P2OwCBjw2XjQBJPa8UwK4iw@mail.gmail.com> (raw)
In-Reply-To: <CAG3b68EvH4eehWYEi5_PgwQF+LG1=tXObYbzOgUv==6Xx77sSQ@mail.gmail.com>

On Tue, Aug 10, 2021 at 12:53 PM Gürkan <seqizz@gmail.com> 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.


  reply	other threads:[~2021-08-10 20:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 19:53 Gürkan
2021-08-10 20:44 ` Bart Schaefer [this message]
2021-08-10 21:39   ` Gürkan
2021-08-10 21:53     ` Gürkan
2021-08-10 22:36       ` Bart Schaefer
2021-08-11  6:24         ` Gürkan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Ygc0+gXvCeVw+1Q0B_1X3P2OwCBjw2XjQBJPa8UwK4iw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=seqizz@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).