aboutsummaryrefslogtreecommitdiff
path: root/src/cmdline.opt
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-02-09 16:34:52 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-02-09 16:34:52 +0200
commit62f22e19e0953022d68f220463104117a1a5b7e2 (patch)
tree1c0ca58723492296f84b25b8f1e195573263188a /src/cmdline.opt
parentdaae7b2e4fbcecbb11f85949358c189fc25291b6 (diff)
downloadeclat-62f22e19e0953022d68f220463104117a1a5b7e2.tar.gz
eclat-62f22e19e0953022d68f220463104117a1a5b7e2.tar.bz2
Read default options from the environment variable ECLAT_OPTIONS.
* src/cmdline.opt (process_options): Process the value of the environment variable ECLAT_OPTIONS prior to the actual command line options. * src/eclat.c (main): Update invocation of process_options. * doc/eclat.1: Update.
Diffstat (limited to 'src/cmdline.opt')
-rw-r--r--src/cmdline.opt33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt
index 9ca41ee..23a0858 100644
--- a/src/cmdline.opt
+++ b/src/cmdline.opt
@@ -276,9 +276,35 @@ END
OPTIONS_END
static void
-parse_options(int argc, char *argv[], int *index)
+parse_options(int *pargc, char **pargv[])
{
- GETOPT(argc, argv, *index, exit(EX_USAGE))
+ int index;
+ int argc;
+ char **argv;
+ char *p;
+
+ argc = *pargc;
+ argv = *pargv;
+
+ p = getenv("ECLAT_OPTIONS");
+ if (p) {
+ struct wordsplit ws;
+ int i, j;
+
+ ws.ws_offs = argc;
+ if (wordsplit(p, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS))
+ die(EX_SOFTWARE, "wordsplit failed at \"%s\": %s",
+ p, wordsplit_strerror(&ws));
+ memmove(ws.ws_wordv + 1, ws.ws_wordv + ws.ws_offs,
+ sizeof(ws.ws_wordv[0])*ws.ws_wordc);
+ ws.ws_wordv[0] = argv[0];
+ for (i = 1, j = ws.ws_wordc + 1; i < argc; i++, j++)
+ ws.ws_wordv[j] = argv[i];
+ argc += ws.ws_wordc;
+ argv = ws.ws_wordv;
+ }
+
+ GETOPT(argc, argv, index, exit(EX_USAGE))
if (pp_cmd_buffer && grecs_preprocessor) {
char *cmd = grecs_malloc(strlen(grecs_preprocessor) +
@@ -288,5 +314,8 @@ parse_options(int argc, char *argv[], int *index)
grecs_preprocessor = cmd;
free(pp_cmd_buffer);
}
+
+ *pargc = argc - index;
+ *pargv = argv + index;
}

Return to:

Send suggestions and report system problems to the System administrator.