Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] ZSH_EXEPATH: improve documentation, add test
- X-seq: zsh-workers 54424
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] ZSH_EXEPATH: improve documentation, add test
- Date: Wed, 29 Apr 2026 23:09:05 -0500
- Archived-at: <https://zsh.org/workers/54424>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
i haven't confirmed myself but by all accounts this should work on
solaris via /proc/self/path/a.out and under cygwin via /proc/self/exe,
so i've documented that
also added a test. i only tried it on macos so lmk if it's bad for
anyone
dana
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index ecedc3862..8fdc7353f 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1175,6 +1175,9 @@ the argument passed to the option. Otherwise it is not set.
vindex(ZSH_EXEPATH)
item(tt(ZSH_EXEPATH))(
Full pathname of the executable file of the current zsh process.
+This value should be accurate on Linux, macOS, FreeBSD, DragonflyBSD,
+NetBSD, Solaris, Cygwin, and their derivatives. On other systems, it is
+determined from tt(argv[0]), which is not always accurate.
)
vindex(ZSH_NAME)
item(tt(ZSH_NAME))(
diff --git a/NEWS b/NEWS
index 952071dbe..50f358f49 100644
--- a/NEWS
+++ b/NEWS
@@ -20,8 +20,8 @@ The parameter expansion flag ! was added for the referred-to name of a
named reference.
The parameter ZSH_EXEPATH expands to the full path of the current zsh
-process, reliably on Linux, Mac, {Net,Free,Dragonfly}BSD and falls
-back to argv[0] elsewhere.
+process, reliably on Linux, Mac, {Net,Free,Dragonfly}BSD, Solaris, and
+Cygwin, and falls back to argv[0] elsewhere.
The default keymap is now emacs. Users of the vi keymaps please check
README to see if you are affected.
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index ed25fd7a9..0399faa8e 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2864,3 +2864,24 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
0:regression for workers/53179 unicode ZDOTDIR
F:output ignorable as long as not an error
*>*
+
+ argv0=/not/a/real/path
+ exepath=$(
+ ARGV0=$argv0 $ZTST_testdir/../Src/zsh -fc 'print -r - $ZSH_EXEPATH'
+ )
+ if
+ [[ $OSTYPE == (darwin|dragonfly|freebsd|netbsd)* ]] || # via library call
+ [[ $OSTYPE == (cygwin|linux|solaris)* && -e /proc/self ]] # via procfs
+ then
+ [[ $exepath == (/*)#/Src/zsh ]] && print -rn 'match: '
+ print -r - $exepath
+ # on any other system without procfs, we should have argv[0] verbatim since
+ # it's already absolute
+ elif [[ ! -e /proc/$$ ]]; then
+ [[ $exepath == $argv0 ]] && print -rn 'match: '
+ print -r - $exepath
+ else
+ ZTST_skip='ZSH_EXEPATH not reliable'
+ fi
+-:ZSH_EXEPATH
+*>match: /*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author