zsh-users
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: zsh <zsh-users@zsh.org>, linuxtechguy@gmail.com
Subject: Re: Using script to find location of global rcs files.
Date: Sat, 26 Jan 2019 12:38:32 -0600	[thread overview]
Message-ID: <B79CD6E7-D834-4BC0-A8C2-C2D77EC8FA96@dana.is> (raw)
In-Reply-To: <f13f8a7bce03b94b0a3cce202548b952c61241e8.camel@ntlworld.com>

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}

It's not great though

dana


  reply	other threads:[~2019-01-26 18:38 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 [this message]
2019-01-27 13:11     ` Jim
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=B79CD6E7-D834-4BC0-A8C2-C2D77EC8FA96@dana.is \
    --to=dana@dana.is \
    --cc=linuxtechguy@gmail.com \
    --cc=p.w.stephenson@ntlworld.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).