Add "--version" long option.

This commit is contained in:
Dianne Skoll
2023-09-25 08:23:28 -04:00
parent 13571f84af
commit 62388fb21f
3 changed files with 19 additions and 0 deletions

View File

@@ -40,6 +40,7 @@
#include "expr.h"
#include "err.h"
static void ProcessLongArg(char const *arg);
/***************************************************************
*
* Command line options recognized:
@@ -243,6 +244,11 @@ void InitRemind(int argc, char const *argv[])
while(*arg) arg++;
break;
case '-':
ProcessLongArg(arg);
while(*arg) arg++;
break;
case '@':
UseVTColors = 1;
if (*arg) {
@@ -958,3 +964,12 @@ AddTrustedUser(char const *username)
NumTrustedUsers++;
}
static void
ProcessLongArg(char const *arg)
{
if (!strcmp(arg, "version")) {
printf("%s\n", VERSION);
exit(0);
}
fprintf(ErrFp, "%s: Unknown long option --%s\n", ArgV[0], arg);
}

View File

@@ -437,6 +437,9 @@ rm -rf include_dir/ww
# This segfaulted in 04.02.03
../src/remind -h '-imsgprefix(x)="foo"' /dev/null >> ../tests/test.out 2>&1
# Test --version long option
../src/remind --version >> ../tests/test.out 2>&1
# Remove references to SysInclude, which is build-specific
grep -F -v '$SysInclude' < ../tests/test.out > ../tests/test.out.1 && mv -f ../tests/test.out.1 ../tests/test.out
cmp -s ../tests/test.out ../tests/test.cmp

View File

@@ -11695,3 +11695,4 @@ Can't open file: include_dir/ww
Error reading include_dir/ww: Can't open file
SECURITY: Won't read world-writable file or directory!
Error reading include_dir/ww: No files matching *.rem
04.02.06