/trunk/uspace/app/bdsh/cmds/modules/touch/touch.c |
---|
70,8 → 70,7 |
DIR *dirp; |
/* Count the arguments */ |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
if (argc == 1) { |
printf("%s - incorrect number of arguments. Try `help %s extended'\n", |
/trunk/uspace/app/bdsh/cmds/modules/mkdir/mkdir.c |
---|
188,7 → 188,7 |
int c, opt_ind; |
char *cwd; |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
for (c = 0, optind = 0, opt_ind = 0; c != -1;) { |
c = getopt_long(argc, argv, "pvhVfm:", long_options, &opt_ind); |
/trunk/uspace/app/bdsh/cmds/modules/cat/cat.c |
---|
138,7 → 138,7 |
unsigned int argc, i, ret = 0, buffer = 0; |
int c, opt_ind; |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
for (c = 0, optind = 0, opt_ind = 0; c != -1;) { |
c = getopt_long(argc, argv, "hvmH:t:b:", long_options, &opt_ind); |
/trunk/uspace/app/bdsh/cmds/modules/help/help.c |
---|
31,6 → 31,8 |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include "config.h" |
#include "entry.h" |
#include "help.h" |
#include "cmds.h" |
37,6 → 39,7 |
#include "modules.h" |
#include "builtins.h" |
#include "errors.h" |
#include "util.h" |
static char *cmdname = "help"; |
extern const char *progname; |
95,7 → 98,7 |
int argc; |
int level = HELP_SHORT; |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
if (argc > 3) { |
printf("\nToo many arguments to `%s', try:\n", cmdname); |
/trunk/uspace/app/bdsh/cmds/modules/ls/ls.c |
---|
152,8 → 152,7 |
char *buff; |
DIR *dirp; |
/* Count the arguments */ |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
buff = (char *) malloc(PATH_MAX); |
if (NULL == buff) { |
/trunk/uspace/app/bdsh/cmds/modules/rm/rm.c |
---|
173,7 → 173,8 |
size_t len; |
char *buff = NULL; |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
if (argc < 2) { |
cli_error(CL_EFAIL, |
"%s: insufficient arguments. Try %s --help", cmdname, cmdname); |
/trunk/uspace/app/bdsh/cmds/builtins/cd/cd.c |
---|
62,7 → 62,7 |
{ |
int argc, rc = 0; |
for (argc = 0; argv[argc] != NULL; argc ++); |
argc = cli_count_args(argv); |
/* We don't yet play nice with whitespace, a getopt implementation should |
* protect "quoted\ destination" as a single argument. Its not our job to |
/trunk/uspace/app/bdsh/util.c |
---|
237,3 → 237,13 |
return (cli_strtok_r(s, delim, &last)); |
} |
/* Count and return the # of elements in an array */ |
unsigned int cli_count_args(char **args) |
{ |
unsigned int i; |
for (i=0; args[i] != NULL; i++); |
return i; |
} |
/trunk/uspace/app/bdsh/util.h |
---|
7,5 → 7,6 |
extern int cli_psprintf(char **, const char *, ...); |
extern char * cli_strtok_r(char *, const char *, char **); |
extern char * cli_strtok(char *, const char *); |
extern unsigned int cli_count_args(char **); |
#endif |