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

[PATCH] Show patchlevel in version string



When building zsh with a custom patch level you cannot quickly see which
patchlevel you are on via `zsh --version'. When using zsh on Debian or
in my case, where I run the git version of zsh the patch level is hidden
in an environment variable ZSH_PATCHLEVEL. Git for example shows you the
git revision when issues `git --version' as seen here:

  $ git --version
  git version 2.33.0.113.g6c40894d24

This shows directly what version a user is running without having to
know about ZSH_PATCHLEVEL.

Because I'm not aware how downstream deals with a difference in version
strings I've decided to add it to the vendor/os type bit. Debian for
example uses `debian/5.8-6+b2' as a patch level. This would probably
break scripts which expect `zsh x.y.z' if the patch level replaced the
ZSH_VERSION string.

After this patch is applied, you get to see the following version string
after you configured zsh with `--enable-custom-patchlevel=$(git describe)':

  $ ./Src/zsh --version
  zsh 5.8.0.2-dev (x86_64-pc-linux-gnu/zsh-5.8-481-g64befeb4c)

Signed-off-by: Wesley Schwengle <wesley@xxxxxxxxxxxxxxx>
---
 Src/init.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Src/init.c b/Src/init.c
index 878a53a37..a04d599c3 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -421,8 +421,14 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
 		/* GNU-style long options */
 		++*argv;
 		if (!strcmp(*argv, "version")) {
+#ifdef CUSTOM_PATCHLEVEL
+		    printf("zsh %s (%s-%s-%s/%s)\n",
+			    ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE, CUSTOM_PATCHLEVEL);
+#else
 		    printf("zsh %s (%s-%s-%s)\n",
 			    ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE);
+#endif
+
 		    LAST_OPTION(0);
 		}
 		if (!strcmp(*argv, "help")) {
-- 
2.33.0.113.g6c40894d24





Messages sorted by: Reverse Date, Date, Thread, Author