Skip to content

Commit

Permalink
cmdops: fix no-args run in which and time
Browse files Browse the repository at this point in the history
  • Loading branch information
arsv committed Nov 7, 2017
1 parent 11bcbc0 commit 6eb3d35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmdops/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <util.h>

ERRTAG("time");
ERRLIST(NEINVAL NEFAULT NEAGAIN NENOMEM NENOSYS NECHILD NEINTR);
ERRLIST(NEINVAL NEFAULT NEAGAIN NENOMEM NENOSYS NECHILD NEINTR NENOENT);

static void spawn(char** argv, char** envp)
{
Expand Down Expand Up @@ -92,6 +92,8 @@ int main(int argc, char** argv, char** envp)
if(i < argc && argv[i][0] == '-')
if(argv[i++][1])
fail("unsupported options", NULL, 0);
if(i >= argc)
fail("too few arguments", NULL, 0);

sys_gettimeofday(&t0, NULL);

Expand Down
5 changes: 5 additions & 0 deletions src/cmdops/which.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ int main(int argc, char** argv, char** envp)
char* path = xgetenv(envp, "PATH=");
int ret = 0;

if(argc < 2) {
warn(NULL, "too few arguments");
return -1;
}

for(i = 1; i < argc; i++)
ret |= which(path, argv[i], strlen(argv[i]));

Expand Down

0 comments on commit 6eb3d35

Please sign in to comment.