mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
Add in exec support (patch from Torbj?rn Axelsson <torax@cendio.se>)
and disable backticks (since they are still wierdly broken in some cases.
This commit is contained in:
parent
d1de4a16ad
commit
d2f5677762
17
lash.c
17
lash.c
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_IF_EXPRESSIONS
|
||||
#define BB_FEATURE_SH_ENVIRONMENT
|
||||
//#define DEBUG_SHELL
|
||||
@ -108,6 +108,7 @@ struct builtInCommand {
|
||||
/* function prototypes for builtins */
|
||||
static int builtin_cd(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_env(struct job *dummy, struct jobSet *junk);
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList);
|
||||
static int builtin_help(struct job *cmd, struct jobSet *junk);
|
||||
@ -139,6 +140,7 @@ static int busy_loop(FILE * input);
|
||||
static struct builtInCommand bltins[] = {
|
||||
{"bg", "Resume a job in the background", builtin_fg_bg},
|
||||
{"cd", "Change working directory", builtin_cd},
|
||||
{"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec},
|
||||
{"exit", "Exit from shell()", builtin_exit},
|
||||
{"fg", "Bring job into the foreground", builtin_fg_bg},
|
||||
{"jobs", "Lists the active jobs", builtin_jobs},
|
||||
@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* built-in 'exec' handler */
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
if (cmd->progs[0].argv[1])
|
||||
{
|
||||
cmd->progs[0].argv++;
|
||||
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
|
||||
fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
|
||||
strerror(errno));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* built-in 'exit' handler */
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
|
17
sh.c
17
sh.c
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_IF_EXPRESSIONS
|
||||
#define BB_FEATURE_SH_ENVIRONMENT
|
||||
//#define DEBUG_SHELL
|
||||
@ -108,6 +108,7 @@ struct builtInCommand {
|
||||
/* function prototypes for builtins */
|
||||
static int builtin_cd(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_env(struct job *dummy, struct jobSet *junk);
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList);
|
||||
static int builtin_help(struct job *cmd, struct jobSet *junk);
|
||||
@ -139,6 +140,7 @@ static int busy_loop(FILE * input);
|
||||
static struct builtInCommand bltins[] = {
|
||||
{"bg", "Resume a job in the background", builtin_fg_bg},
|
||||
{"cd", "Change working directory", builtin_cd},
|
||||
{"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec},
|
||||
{"exit", "Exit from shell()", builtin_exit},
|
||||
{"fg", "Bring job into the foreground", builtin_fg_bg},
|
||||
{"jobs", "Lists the active jobs", builtin_jobs},
|
||||
@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* built-in 'exec' handler */
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
if (cmd->progs[0].argv[1])
|
||||
{
|
||||
cmd->progs[0].argv++;
|
||||
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
|
||||
fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
|
||||
strerror(errno));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* built-in 'exit' handler */
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
|
17
shell/lash.c
17
shell/lash.c
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_BACKTICKS
|
||||
//#define BB_FEATURE_SH_IF_EXPRESSIONS
|
||||
#define BB_FEATURE_SH_ENVIRONMENT
|
||||
//#define DEBUG_SHELL
|
||||
@ -108,6 +108,7 @@ struct builtInCommand {
|
||||
/* function prototypes for builtins */
|
||||
static int builtin_cd(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_env(struct job *dummy, struct jobSet *junk);
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk);
|
||||
static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList);
|
||||
static int builtin_help(struct job *cmd, struct jobSet *junk);
|
||||
@ -139,6 +140,7 @@ static int busy_loop(FILE * input);
|
||||
static struct builtInCommand bltins[] = {
|
||||
{"bg", "Resume a job in the background", builtin_fg_bg},
|
||||
{"cd", "Change working directory", builtin_cd},
|
||||
{"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec},
|
||||
{"exit", "Exit from shell()", builtin_exit},
|
||||
{"fg", "Bring job into the foreground", builtin_fg_bg},
|
||||
{"jobs", "Lists the active jobs", builtin_jobs},
|
||||
@ -219,6 +221,19 @@ static int builtin_env(struct job *dummy, struct jobSet *junk)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* built-in 'exec' handler */
|
||||
static int builtin_exec(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
if (cmd->progs[0].argv[1])
|
||||
{
|
||||
cmd->progs[0].argv++;
|
||||
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
|
||||
fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
|
||||
strerror(errno));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* built-in 'exit' handler */
|
||||
static int builtin_exit(struct job *cmd, struct jobSet *junk)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user