wd

Workdir changer
git clone https://git.sinitax.com/sinitax/wd
Log | Files | Refs | LICENSE | sfeed.txt

wd.c (395B)


      1#include <unistd.h>
      2#include <string.h>
      3#include <errno.h>
      4#include <stdio.h>
      5
      6int
      7main(int argc, char **argv)
      8{
      9	if (argc < 3) {
     10		fprintf(stderr, "Usage: wd DIR CMD..\n");
     11		return 1;
     12	}
     13
     14	if (chdir(argv[1])) {
     15		fprintf(stderr, "wd: chdir %s: %s\n",
     16			argv[1], strerror(errno));
     17		return 1;
     18	}
     19
     20	execvp(argv[2], argv + 2);
     21
     22	fprintf(stderr, "wd: execv: %s\n", strerror(errno));
     23	return 1;
     24}