This commit is contained in:
Arun Prakash Jana 2020-02-14 20:53:20 +05:30
parent 1ed015e988
commit f2c4890d6e
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -6451,13 +6451,12 @@ int main(int argc, char *argv[])
#ifndef NOMOUSE #ifndef NOMOUSE
mmask_t mask; mmask_t mask;
#endif #endif
const char* const env_opts = xgetenv(env_cfg[NNN_OPTS], NULL); const char* const env_opts = xgetenv(env_cfg[NNN_OPTS], NULL);
int env_opts_idx = (env_opts ? (int)strlen(env_opts) : -1); int env_opts_id = env_opts ? (int)strlen(env_opts) : -1;
while ((opt = (--env_opts_idx >= 0 ? env_opts[env_opts_idx] : getopt(argc, argv, "aAb:cdeEgHKnop:QrRs:St:vVxh"))) != -1) {
if (env_opts_idx >= 0) { while ((opt = (env_opts_id > 0
optarg = NULL; ? env_opts[--env_opts_id]
} : getopt(argc, argv, "aAb:cdeEgHKnop:QrRs:St:vVxh"))) != -1) {
switch (opt) { switch (opt) {
case 'a': case 'a':
cfg.mtime = 0; cfg.mtime = 0;
@ -6502,9 +6501,9 @@ int main(int argc, char *argv[])
cfg.nonavopen = 1; cfg.nonavopen = 1;
break; break;
case 'p': case 'p':
if (!optarg) { if (env_opts_id >= 0)
break; break;
}
cfg.picker = 1; cfg.picker = 1;
if (optarg[0] == '-' && optarg[1] == '\0') if (optarg[0] == '-' && optarg[1] == '\0')
cfg.pickraw = 1; cfg.pickraw = 1;
@ -6534,39 +6533,26 @@ int main(int argc, char *argv[])
cfg.rollover = 0; cfg.rollover = 0;
break; break;
case 's': case 's':
if (!optarg) { if (env_opts_id < 0)
break;
}
session = optarg; session = optarg;
break; break;
case 't': case 't':
if (!optarg) { if (env_opts_id < 0)
break;
}
idletimeout = atoi(optarg); idletimeout = atoi(optarg);
break; break;
case 'v': case 'v':
namecmpfn = &xstrverscasecmp; namecmpfn = &xstrverscasecmp;
break; break;
case 'V': case 'V':
if (env_opts_idx >= 0) {
break;
}
fprintf(stdout, "%s\n", VERSION); fprintf(stdout, "%s\n", VERSION);
return _SUCCESS; return _SUCCESS;
case 'x': case 'x':
cfg.x11 = 1; cfg.x11 = 1;
break; break;
case 'h': case 'h':
if (env_opts_idx >= 0) {
break;
}
usage(); usage();
return _SUCCESS; return _SUCCESS;
default: default:
if (env_opts_idx >= 0) {
fprintf(stderr, "Error: Illegal option '%c' in env var '%s'\n\n", opt, env_cfg[NNN_OPTS]);
}
usage(); usage();
return _FAILURE; return _FAILURE;
} }