1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 13:33:52 +01:00

19408: fix argument handling for ulimit -aH

This commit is contained in:
Peter Stephenson 2004-02-08 21:05:49 +00:00
parent 97ab9b22d7
commit d84942a9b4
2 changed files with 17 additions and 3 deletions

@ -1,3 +1,7 @@
2004-02-08 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
* 19408: Src/Builtins/rlimits.c: fix option handling for ulimit -aH.
2004-02-04 Oliver Kiddle <opk@zsh.org> 2004-02-04 Oliver Kiddle <opk@zsh.org>
* Mikael Magnusson: 19405: Completion/Unix/Command/_gphoto2: * Mikael Magnusson: 19405: Completion/Unix/Command/_gphoto2:

@ -462,7 +462,7 @@ bin_unlimit(char *nam, char **argv, Options ops, int func)
static int static int
bin_ulimit(char *name, char **argv, Options ops, int func) bin_ulimit(char *name, char **argv, Options ops, int func)
{ {
int res, resmask = 0, hard = 0, soft = 0, nres = 0; int res, resmask = 0, hard = 0, soft = 0, nres = 0, all = 0;
char *options; char *options;
do { do {
@ -486,11 +486,12 @@ bin_ulimit(char *name, char **argv, Options ops, int func)
soft = 1; soft = 1;
continue; continue;
case 'a': case 'a':
if (*argv || options[1] || resmask) { if (resmask) {
zwarnnam(name, "no arguments required after -a", zwarnnam(name, "no limits allowed with -a",
NULL, 0); NULL, 0);
return 1; return 1;
} }
all = 1;
resmask = (1 << RLIM_NLIMITS) - 1; resmask = (1 << RLIM_NLIMITS) - 1;
nres = RLIM_NLIMITS; nres = RLIM_NLIMITS;
continue; continue;
@ -547,6 +548,11 @@ bin_ulimit(char *name, char **argv, Options ops, int func)
resmask |= 1 << res; resmask |= 1 << res;
nres++; nres++;
} }
if (all && res != -1) {
zwarnnam(name, "no limits allowed with -a",
NULL, 0);
return 1;
}
} }
} }
if (!*argv || **argv == '-') { if (!*argv || **argv == '-') {
@ -560,6 +566,10 @@ bin_ulimit(char *name, char **argv, Options ops, int func)
nres++; nres++;
continue; continue;
} }
if (all) {
zwarnnam(name, "no arguments allowed after -a", NULL, 0);
return 1;
}
if (res < 0) if (res < 0)
res = RLIMIT_FSIZE; res = RLIMIT_FSIZE;
if (strcmp(*argv, "unlimited")) { if (strcmp(*argv, "unlimited")) {