[cmd] Change what 'ver' issues

Ann and Jason Edmeades jason at edmeades.me.uk
Mon Nov 26 15:06:52 CST 2012


Currently ver issues the wine package level (e.g. 1.5.18) but
there are applications which look at the returned string and parse
it. Whilst few and far between, I've found a number of references
around the internet of people using the 'ver' output to identify
what windows the script is running on.

This patch changes the ver response so it reports the windows
major,minor and build levels as per windows and adds the wine
level onto the line as well. Note I also prefixed the output with
an additional keyword as it keeps scripts happy who tokenize the
words on the line as the build is then in the right word position.

Example output:
Wine CMD Version 5.1.2600 (1.5.18)

There's an argument to say we could just reject such bugs as
'wontfix', however the change to get this script working was so
small it was worth doing, and I do not feel the end result is
particularly detrimental either.

[Fixes bug 27088]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20121126/7dc31d21/attachment-0001.html>
-------------- next part --------------
From 93e6eb042ae02fd3b64b9630d349fed01c78fa87 Mon Sep 17 00:00:00 2001
From: Jason Edmeades <jason at edmeades.me.uk>
Date: Sat, 24 Nov 2012 00:17:17 +0000
Subject: [cmd] Change what 'ver' issues

Currently ver issues the wine package level (e.g. 1.5.18) but
there are applications which look at the returned string and parse
it. Whilst few and far between, I've found a number of references
around the internet of people using the 'ver' output to identify
what windows the script is running on.

This patch changes the ver response so it reports the windows
major,minor and build levels as per windows and adds the wine
level onto the line as well. Note I also prefixed the output with
an additional keyword as it keeps scripts happy who tokenize the
words on the line as the build is then in the right word position.

Example output:
Wine CMD Version 5.1.2600 (1.5.18)

There's an argument to say we could just reject such bugs as
'wontfix', however the change to get this script working was so
small it was worth doing, and I do not feel the end result is
particularly detrimental either.

[Fixes bug 27088]
---
 programs/cmd/cmd.rc     |    2 +-
 programs/cmd/wcmdmain.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 programs/cmd/wcmdmain.c

diff --git a/programs/cmd/cmd.rc b/programs/cmd/cmd.rc
index 76f1bca..184aaa8 100644
--- a/programs/cmd/cmd.rc
+++ b/programs/cmd/cmd.rc
@@ -346,7 +346,7 @@ Enter HELP <command> for further information on any of the above commands.\n"
   WCMD_NOPATH, "PATH not found\n"
   WCMD_ANYKEY,"Press any key to continue... "
   WCMD_CONSTITLE,"Wine Command Prompt"
-  WCMD_VERSION,"CMD Version %1!S!\n"
+  WCMD_VERSION,"Wine CMD Version %1!S!\n"
   WCMD_MOREPROMPT, "More? "
   WCMD_LINETOOLONG, "The input line is too long.\n"
   WCMD_VOLUMELABEL, "Volume in drive %1!c! is %2\n"
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
old mode 100644
new mode 100755
index cefb8e4..cb9fab6
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -2318,12 +2318,20 @@ int wmain (int argc, WCHAR *argvW[])
   static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
   static const WCHAR defaultpromptW[] = {'$','P','$','G','\0'};
   CMD_LIST *toExecute = NULL;         /* Commands left to be executed */
+  OSVERSIONINFOW osv;
+  char osver[50];
 
   srand(time(NULL));
 
+  /* Get the windows version being emulated */
+  osv.dwOSVersionInfoSize = sizeof(osv);
+  GetVersionExW(&osv);
+
   /* Pre initialize some messages */
   strcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY));
-  cmd = WCMD_format_string(WCMD_LoadMessage(WCMD_VERSION), PACKAGE_VERSION);
+  sprintf(osver, "%d.%d.%d (%s)", osv.dwMajorVersion, osv.dwMinorVersion,
+          osv.dwBuildNumber, PACKAGE_VERSION);
+  cmd = WCMD_format_string(WCMD_LoadMessage(WCMD_VERSION), osver);
   strcpyW(version_string, cmd);
   LocalFree(cmd);
   cmd = NULL;
-- 
1.7.9.5


More information about the wine-patches mailing list