zsh-users
 help / color / mirror / code / Atom feed
From: Jim <linux.tech.guy@gmail.com>
To: dana <dana@dana.is>, zsh <zsh-users@zsh.org>
Subject: Re: Using script to find location of global rcs files.
Date: Sun, 27 Jan 2019 07:11:40 -0600	[thread overview]
Message-ID: <CA+rB6GLaRGztigZG3gYqHp=g1-n6d1qNgn5N6q6tYM54gtuR_w@mail.gmail.com> (raw)
In-Reply-To: <B79CD6E7-D834-4BC0-A8C2-C2D77EC8FA96@dana.is>

[-- Attachment #1: Type: text/plain, Size: 2021 bytes --]

Thanks.  Hadn´t used that combination of options before, but learned
something new.  To bad zsh doesn´t have an option to display
the build information, but I leave it to others more qualified to say if
that
is possible or practical.

On Sat, Jan 26, 2019 at 12:38 PM dana <dana@dana.is> wrote:

> On 26 Jan 2019, at 12:10, Peter Stephenson <p.w.stephenson@ntlworld.com>
> wrote:
> >No, I'm afraid I can't see a better way --- the value is baked into the
> >shell but without exposing the value at the shell language level
>
> I was also going to point out that zsh itself doesn't even know anything
> about
> the 'etcdir' configure variable — the configure script uses that to build
> the
> default paths for the global rc files, all of which can be overridden
> independently, and only those complete file paths are used by zsh itself.
> So
> you can't actually trust that there's just one directory that all of them
> live
> in — though i assume that's usually the case in practice.
>
> *If* you're OK with making the following assumptions...
>
> * the files *do* all live in the same directory
> * at least one of the files exists on the system
> * the zsh in your PATH is the shell you're actually running (zsh itself
>   doesn't provide a reliable way to find the path to the running shell
> binary;
>   in some cases $ZSH_ARGZERO works well enough, but not in a script)



> ... then i guess you could do this?
>
>   etcdir=${${${(f)"$( ZDOTDIR=/dev/null zsh --source-trace -ilnpc : 2>&1
> )"}[1]#+}:h}
>

Had some trouble with the above line of code when there is only one global
file,
It only returned a ¨.¨. Assuming I typed it correctly.
The following appears to work for one or more global files.

etcdir=${${${(z)${${(f)"$( ZDOTDIR=/dev/null zsh --source-trace -ilnpc :
2>&1 )"}#+}}[1]}:h}

Hopefully no typos here either. Not sure I transitioned correctly between
array
and scalar.

It's not great though
>
> dana
>

 Again, thanks.

Jim

  reply	other threads:[~2019-01-27 13:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-26 12:55 Jim
2019-01-26 18:10 ` Peter Stephenson
2019-01-26 18:38   ` dana
2019-01-27 13:11     ` Jim [this message]
2019-01-27 14:32       ` dana

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='CA+rB6GLaRGztigZG3gYqHp=g1-n6d1qNgn5N6q6tYM54gtuR_w@mail.gmail.com' \
    --to=linux.tech.guy@gmail.com \
    --cc=dana@dana.is \
    --cc=linuxtechguy@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).