projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
stop using __u32 etc. uint32_t is there for a reason
[oweals/busybox.git]
/
shell
/
bbsh.c
diff --git
a/shell/bbsh.c
b/shell/bbsh.c
index 57a103bf8871a53455cc70db6a40a254e9bf87fd..99e4f61fbe9986feb60792106d56dc984fae7c1b 100644
(file)
--- a/
shell/bbsh.c
+++ b/
shell/bbsh.c
@@
-36,7
+36,7
@@
echo `echo hello#comment " woot` and more
*/
echo `echo hello#comment " woot` and more
*/
-#include
<busybox.h>
+#include
"busybox.h"
// A single executable, its arguments, and other information we know about it.
#define BBSH_FLAG_EXIT 1
// A single executable, its arguments, and other information we know about it.
#define BBSH_FLAG_EXIT 1
@@
-105,23
+105,23
@@
static char *parse_word(char *start, struct command **cmd)
// Parse a line of text into a pipeline.
// Returns a pointer to the next line.
// Parse a line of text into a pipeline.
// Returns a pointer to the next line.
-static char *parse_pipeline(char *cmdline, struct pipeline *
pip
e)
+static char *parse_pipeline(char *cmdline, struct pipeline *
lin
e)
{
{
- struct command **cmd = &(
pip
e->cmd);
- char *start =
pip
e->cmdline = cmdline;
+ struct command **cmd = &(
lin
e->cmd);
+ char *start =
lin
e->cmdline = cmdline;
if (!cmdline) return 0;
if (!cmdline) return 0;
- if (ENABLE_BBSH_JOBCTL)
pip
e->cmdline = cmdline;
+ if (ENABLE_BBSH_JOBCTL)
lin
e->cmdline = cmdline;
// Parse command into argv[]
for (;;) {
char *end;
// Skip leading whitespace and detect end of line.
// Parse command into argv[]
for (;;) {
char *end;
// Skip leading whitespace and detect end of line.
-
while (isspace(*start)) start++
;
+
start = skip_whitespace(start)
;
if (!*start || *start=='#') {
if (!*start || *start=='#') {
- if (ENABLE_BBSH_JOBCTL)
pip
e->cmdlinelen = start-cmdline;
+ if (ENABLE_BBSH_JOBCTL)
lin
e->cmdlinelen = start-cmdline;
return 0;
}
return 0;
}
@@
-145,15
+145,15
@@
static char *parse_pipeline(char *cmdline, struct pipeline *pipe)
start = end;
}
start = end;
}
- if (ENABLE_BBSH_JOBCTL)
pip
e->cmdlinelen = start-cmdline;
+ if (ENABLE_BBSH_JOBCTL)
lin
e->cmdlinelen = start-cmdline;
return start;
}
// Execute the commands in a pipeline
return start;
}
// Execute the commands in a pipeline
-static int run_pipeline(struct pipeline *
pip
e)
+static int run_pipeline(struct pipeline *
lin
e)
{
{
- struct command *cmd =
pip
e->cmd;
+ struct command *cmd =
lin
e->cmd;
if (!cmd || !cmd->argc) return 0;
// Handle local commands. This is totally fake and plastic.
if (!cmd || !cmd->argc) return 0;
// Handle local commands. This is totally fake and plastic.
@@
-185,16
+185,16
@@
static void free_cmd(void *data)
static void handle(char *command)
{
static void handle(char *command)
{
- struct pipeline
pip
e;
+ struct pipeline
lin
e;
char *start = command;
for (;;) {
char *start = command;
for (;;) {
- memset(&
pip
e,0,sizeof(struct pipeline));
- start = parse_pipeline(start, &
pip
e);
- if (!
pip
e.cmd) break;
+ memset(&
lin
e,0,sizeof(struct pipeline));
+ start = parse_pipeline(start, &
lin
e);
+ if (!
lin
e.cmd) break;
- run_pipeline(&
pip
e);
- free_list(
pip
e.cmd, free_cmd);
+ run_pipeline(&
lin
e);
+ free_list(
lin
e.cmd, free_cmd);
}
}
}
}
@@
-203,15
+203,13
@@
int bbsh_main(int argc, char *argv[])
char *command=NULL;
FILE *f;
char *command=NULL;
FILE *f;
-
bb_getopt_ulflags
(argc, argv, "c:", &command);
+
getopt32
(argc, argv, "c:", &command);
f = argv[optind] ? xfopen(argv[optind],"r") : NULL;
if (command) handle(command);
else {
unsigned cmdlen=0;
for (;;) {
f = argv[optind] ? xfopen(argv[optind],"r") : NULL;
if (command) handle(command);
else {
unsigned cmdlen=0;
for (;;) {
- struct pipeline pipe;
-
if(!f) putchar('$');
if(1 > getline(&command, &cmdlen,f ? : stdin)) break;
if(!f) putchar('$');
if(1 > getline(&command, &cmdlen,f ? : stdin)) break;