diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-09-21 02:48:07 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-09-21 02:48:07 +0000 |
commit | d2f567776241013fedf5b690cd74fb6baad78b1c (patch) | |
tree | f613749891ff8f2db54b8a47879c97ffd02caa81 | |
parent | d1de4a16ad662bdd8e26da5662a5b0678ce4995e (diff) | |
download | busybox-w32-d2f567776241013fedf5b690cd74fb6baad78b1c.tar.gz busybox-w32-d2f567776241013fedf5b690cd74fb6baad78b1c.tar.bz2 busybox-w32-d2f567776241013fedf5b690cd74fb6baad78b1c.zip |
Add in exec support (patch from Torbj?rn Axelsson <torax@cendio.se>)
and disable backticks (since they are still wierdly broken in some
cases.
-rw-r--r-- | lash.c | 17 | ||||
-rw-r--r-- | sh.c | 17 | ||||
-rw-r--r-- | shell/lash.c | 17 |
3 files changed, 48 insertions, 3 deletions
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #define BB_FEATURE_SH_BACKTICKS | 29 | //#define BB_FEATURE_SH_BACKTICKS |
30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS | 30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS |
31 | #define BB_FEATURE_SH_ENVIRONMENT | 31 | #define BB_FEATURE_SH_ENVIRONMENT |
32 | //#define DEBUG_SHELL | 32 | //#define DEBUG_SHELL |
@@ -108,6 +108,7 @@ struct builtInCommand { | |||
108 | /* function prototypes for builtins */ | 108 | /* function prototypes for builtins */ |
109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); | 109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); |
110 | static int builtin_env(struct job *dummy, struct jobSet *junk); | 110 | static int builtin_env(struct job *dummy, struct jobSet *junk); |
111 | static int builtin_exec(struct job *cmd, struct jobSet *junk); | ||
111 | static int builtin_exit(struct job *cmd, struct jobSet *junk); | 112 | static int builtin_exit(struct job *cmd, struct jobSet *junk); |
112 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); | 113 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); |
113 | static int builtin_help(struct job *cmd, struct jobSet *junk); | 114 | static int builtin_help(struct job *cmd, struct jobSet *junk); |
@@ -139,6 +140,7 @@ static int busy_loop(FILE * input); | |||
139 | static struct builtInCommand bltins[] = { | 140 | static struct builtInCommand bltins[] = { |
140 | {"bg", "Resume a job in the background", builtin_fg_bg}, | 141 | {"bg", "Resume a job in the background", builtin_fg_bg}, |
141 | {"cd", "Change working directory", builtin_cd}, | 142 | {"cd", "Change working directory", builtin_cd}, |
143 | {"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec}, | ||
142 | {"exit", "Exit from shell()", builtin_exit}, | 144 | {"exit", "Exit from shell()", builtin_exit}, |
143 | {"fg", "Bring job into the foreground", builtin_fg_bg}, | 145 | {"fg", "Bring job into the foreground", builtin_fg_bg}, |
144 | {"jobs", "Lists the active jobs", builtin_jobs}, | 146 | {"jobs", "Lists the active jobs", builtin_jobs}, |
@@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk) | |||
219 | return (0); | 221 | return (0); |
220 | } | 222 | } |
221 | 223 | ||
224 | /* built-in 'exec' handler */ | ||
225 | static int builtin_exec(struct job *cmd, struct jobSet *junk) | ||
226 | { | ||
227 | if (cmd->progs[0].argv[1]) | ||
228 | { | ||
229 | cmd->progs[0].argv++; | ||
230 | execvp(cmd->progs[0].argv[0], cmd->progs[0].argv); | ||
231 | fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0], | ||
232 | strerror(errno)); | ||
233 | } | ||
234 | return TRUE; | ||
235 | } | ||
236 | |||
222 | /* built-in 'exit' handler */ | 237 | /* built-in 'exit' handler */ |
223 | static int builtin_exit(struct job *cmd, struct jobSet *junk) | 238 | static int builtin_exit(struct job *cmd, struct jobSet *junk) |
224 | { | 239 | { |
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #define BB_FEATURE_SH_BACKTICKS | 29 | //#define BB_FEATURE_SH_BACKTICKS |
30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS | 30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS |
31 | #define BB_FEATURE_SH_ENVIRONMENT | 31 | #define BB_FEATURE_SH_ENVIRONMENT |
32 | //#define DEBUG_SHELL | 32 | //#define DEBUG_SHELL |
@@ -108,6 +108,7 @@ struct builtInCommand { | |||
108 | /* function prototypes for builtins */ | 108 | /* function prototypes for builtins */ |
109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); | 109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); |
110 | static int builtin_env(struct job *dummy, struct jobSet *junk); | 110 | static int builtin_env(struct job *dummy, struct jobSet *junk); |
111 | static int builtin_exec(struct job *cmd, struct jobSet *junk); | ||
111 | static int builtin_exit(struct job *cmd, struct jobSet *junk); | 112 | static int builtin_exit(struct job *cmd, struct jobSet *junk); |
112 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); | 113 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); |
113 | static int builtin_help(struct job *cmd, struct jobSet *junk); | 114 | static int builtin_help(struct job *cmd, struct jobSet *junk); |
@@ -139,6 +140,7 @@ static int busy_loop(FILE * input); | |||
139 | static struct builtInCommand bltins[] = { | 140 | static struct builtInCommand bltins[] = { |
140 | {"bg", "Resume a job in the background", builtin_fg_bg}, | 141 | {"bg", "Resume a job in the background", builtin_fg_bg}, |
141 | {"cd", "Change working directory", builtin_cd}, | 142 | {"cd", "Change working directory", builtin_cd}, |
143 | {"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec}, | ||
142 | {"exit", "Exit from shell()", builtin_exit}, | 144 | {"exit", "Exit from shell()", builtin_exit}, |
143 | {"fg", "Bring job into the foreground", builtin_fg_bg}, | 145 | {"fg", "Bring job into the foreground", builtin_fg_bg}, |
144 | {"jobs", "Lists the active jobs", builtin_jobs}, | 146 | {"jobs", "Lists the active jobs", builtin_jobs}, |
@@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk) | |||
219 | return (0); | 221 | return (0); |
220 | } | 222 | } |
221 | 223 | ||
224 | /* built-in 'exec' handler */ | ||
225 | static int builtin_exec(struct job *cmd, struct jobSet *junk) | ||
226 | { | ||
227 | if (cmd->progs[0].argv[1]) | ||
228 | { | ||
229 | cmd->progs[0].argv++; | ||
230 | execvp(cmd->progs[0].argv[0], cmd->progs[0].argv); | ||
231 | fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0], | ||
232 | strerror(errno)); | ||
233 | } | ||
234 | return TRUE; | ||
235 | } | ||
236 | |||
222 | /* built-in 'exit' handler */ | 237 | /* built-in 'exit' handler */ |
223 | static int builtin_exit(struct job *cmd, struct jobSet *junk) | 238 | static int builtin_exit(struct job *cmd, struct jobSet *junk) |
224 | { | 239 | { |
diff --git a/shell/lash.c b/shell/lash.c index 60c51f619..b8f407202 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -26,7 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #define BB_FEATURE_SH_BACKTICKS | 29 | //#define BB_FEATURE_SH_BACKTICKS |
30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS | 30 | //#define BB_FEATURE_SH_IF_EXPRESSIONS |
31 | #define BB_FEATURE_SH_ENVIRONMENT | 31 | #define BB_FEATURE_SH_ENVIRONMENT |
32 | //#define DEBUG_SHELL | 32 | //#define DEBUG_SHELL |
@@ -108,6 +108,7 @@ struct builtInCommand { | |||
108 | /* function prototypes for builtins */ | 108 | /* function prototypes for builtins */ |
109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); | 109 | static int builtin_cd(struct job *cmd, struct jobSet *junk); |
110 | static int builtin_env(struct job *dummy, struct jobSet *junk); | 110 | static int builtin_env(struct job *dummy, struct jobSet *junk); |
111 | static int builtin_exec(struct job *cmd, struct jobSet *junk); | ||
111 | static int builtin_exit(struct job *cmd, struct jobSet *junk); | 112 | static int builtin_exit(struct job *cmd, struct jobSet *junk); |
112 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); | 113 | static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList); |
113 | static int builtin_help(struct job *cmd, struct jobSet *junk); | 114 | static int builtin_help(struct job *cmd, struct jobSet *junk); |
@@ -139,6 +140,7 @@ static int busy_loop(FILE * input); | |||
139 | static struct builtInCommand bltins[] = { | 140 | static struct builtInCommand bltins[] = { |
140 | {"bg", "Resume a job in the background", builtin_fg_bg}, | 141 | {"bg", "Resume a job in the background", builtin_fg_bg}, |
141 | {"cd", "Change working directory", builtin_cd}, | 142 | {"cd", "Change working directory", builtin_cd}, |
143 | {"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec}, | ||
142 | {"exit", "Exit from shell()", builtin_exit}, | 144 | {"exit", "Exit from shell()", builtin_exit}, |
143 | {"fg", "Bring job into the foreground", builtin_fg_bg}, | 145 | {"fg", "Bring job into the foreground", builtin_fg_bg}, |
144 | {"jobs", "Lists the active jobs", builtin_jobs}, | 146 | {"jobs", "Lists the active jobs", builtin_jobs}, |
@@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk) | |||
219 | return (0); | 221 | return (0); |
220 | } | 222 | } |
221 | 223 | ||
224 | /* built-in 'exec' handler */ | ||
225 | static int builtin_exec(struct job *cmd, struct jobSet *junk) | ||
226 | { | ||
227 | if (cmd->progs[0].argv[1]) | ||
228 | { | ||
229 | cmd->progs[0].argv++; | ||
230 | execvp(cmd->progs[0].argv[0], cmd->progs[0].argv); | ||
231 | fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0], | ||
232 | strerror(errno)); | ||
233 | } | ||
234 | return TRUE; | ||
235 | } | ||
236 | |||
222 | /* built-in 'exit' handler */ | 237 | /* built-in 'exit' handler */ |
223 | static int builtin_exit(struct job *cmd, struct jobSet *junk) | 238 | static int builtin_exit(struct job *cmd, struct jobSet *junk) |
224 | { | 239 | { |