/branches/shell/uspace/app/bdsh/input.c |
---|
63,15 → 63,13 |
char *cmd[WORD_MAX]; |
int n = 0, i = 0; |
int rc = 0; |
char *tmp = (char *) NULL; |
char *tmp; |
if (NULL == usr->line) { |
rc = CL_EFAIL; |
goto finit; |
} |
if (NULL == usr->line) |
return CL_EFAIL; |
tmp = cli_strdup(usr->line); |
cli_verbose("Tok: tmp = %s", tmp); |
/* Break up what the user typed, space delimited */ |
cmd[n] = cli_strtok(tmp, " "); |
while (cmd[n] && n < WORD_MAX) { |
78,6 → 76,9 |
cmd[++n] = cli_strtok(NULL, " "); |
} |
for (n = 0; cmd[n] != NULL; n++) |
cli_verbose("arg[%d] => `%s'", n, cmd[n]); |
/* We have rubbish */ |
if (NULL == cmd[0]) { |
rc = CL_ENOENT; |
113,6 → 114,7 |
} |
finit: |
/* Why is free complaining about these ? |
if (NULL != usr->line) { |
free(usr->line); |
usr->line = (char *) NULL; |
119,7 → 121,7 |
} |
if (NULL != tmp) |
free(tmp); |
*/ |
return rc; |
} |
/branches/shell/uspace/app/bdsh/cmds/modules/help/help.c |
---|
38,7 → 38,7 |
#include "builtins.h" |
#include "errors.h" |
const char *cmdname = "help"; |
static char *cmdname = "help"; |
extern const char *progname; |
extern unsigned int cli_interactive; |
/branches/shell/uspace/app/bdsh/cmds/builtins/cd/cd.c |
---|
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"); |
/branches/shell/uspace/app/bdsh/cmds/builtins/cd/entry.h |
---|
5,7 → 5,7 |
/* Entry points for the cd command */ |
extern void * help_cmd_cd(unsigned int); |
extern int * cmd_cd(char *[], cliuser_t *); |
extern int * cmd_cd(char **, cliuser_t *); |
#endif |
/branches/shell/uspace/app/bdsh/util.c |
---|
117,6 → 117,7 |
*last = NULL; |
return (NULL); |
} |
tok = s - 1; |
for (;;) { |
/branches/shell/uspace/app/bdsh/scli.c |
---|
129,6 → 129,7 |
cli_set_prompt(&usr); |
get_input(&usr); |
if (NULL != usr.line) { |
cli_verbose("Sending %s to tokenizer", usr.line); |
ret = tok_input(&usr); |
usr.lasterr = ret; |
} |