64,18 → 64,12 |
|
/* This is a very rudamentary 'cd' command. It is not 'link smart' (yet) */ |
|
int * cmd_cd(char *argv[], cliuser_t *usr) |
int * cmd_cd(char **argv, cliuser_t *usr) |
{ |
int argc, rc = 0; |
char *dest = NULL; |
|
for (argc = 0; argv[argc] != NULL; argc ++); |
|
/* Someone just typed 'cd' , send them home */ |
|
if (argc < 2) |
dest = cli_strdup(usr->home); |
|
/* We don't yet play nice with whitespace, a getopt implementation should |
* protect "quoted\ destination" as a single argument. Its not our job to |
* look for && || or redirection as the tokenizer should have done that |
89,15 → 83,11 |
/* We have the correct # of arguments |
* TODO: handle tidle (~) expansion? */ |
|
if (argc == 2) |
dest = cli_strdup(argv[1]); |
rc = chdir(argv[1]); |
|
rc = chdir(dest); |
if (rc == 0) { |
free(dest); |
return CMD_SUCCESS; |
} else { |
free(dest); |
switch (rc) { |
case ENOMEM: |
cli_error(CL_EFAIL, "Destination path too long"); |