/* vi: set sw=4 ts=4: */
/*
- * BusyBox Shell
+ * lash -- the BusyBox Lame-Ass SHell
*
* Copyright (C) 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
#include <unistd.h>
-#ifdef BB_FEATURE_SH_COMMAND_EDITING
-#include "cmdedit.h"
-#endif
-
#define JOB_STATUS_FORMAT "[%d] %-22s %.40s\n"
static int shell_help(struct job *cmd, struct jobSet *junk);
static int shell_jobs(struct job *dummy, struct jobSet *jobList);
static int shell_pwd(struct job *dummy, struct jobSet *junk);
-static int shell_set(struct job *cmd, struct jobSet *junk);
+static int shell_export(struct job *cmd, struct jobSet *junk);
static int shell_source(struct job *cmd, struct jobSet *jobList);
static int shell_unset(struct job *cmd, struct jobSet *junk);
{"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg},
{"jobs", "Lists the active jobs", "jobs", shell_jobs},
{"pwd", "Print current directory", "pwd", shell_pwd},
- {"set", "Set environment variable", "set [VAR=value]", shell_set},
+ {"export", "Set environment variable", "export [VAR=value]", shell_export},
{"unset", "Unset environment variable", "unset VAR", shell_unset},
- {".", "Source-in and run commands in a file", ". filename",
- shell_source},
+ {".", "Source-in and run commands in a file", ". filename", shell_source},
{"help", "List shell built-in commands", "help", shell_help},
{NULL, NULL, NULL, NULL}
};
static int shell_fg_bg(struct job *cmd, struct jobSet *jobList)
{
int i, jobNum;
- struct job *job;
+ struct job *job=NULL;
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
return TRUE;
}
-/* built-in 'set VAR=value' handler */
-static int shell_set(struct job *cmd, struct jobSet *junk)
+/* built-in 'export VAR=value' handler */
+static int shell_export(struct job *cmd, struct jobSet *junk)
{
int res;
}
res = putenv(cmd->progs[0].argv[1]);
if (res)
- fprintf(stdout, "set: %s\n", strerror(errno));
+ fprintf(stdout, "export: %s\n", strerror(errno));
return (res);
}
static int getCommand(FILE * source, char *command)
{
if (source == stdin) {
- fprintf(stdout, "BBSHELL %s %s", cwd, prompt);
- fflush(stdout);
#ifdef BB_FEATURE_SH_COMMAND_EDITING
- cmdedit_read_input(fileno(stdin), fileno(stdout), command);
+ int len;
+ char *promptStr;
+ len=fprintf(stdout, "BBSHELL %s %s", cwd, prompt);
+ fflush(stdout);
+ promptStr=(char*)malloc(sizeof(char)*(len+1));
+ sprintf(promptStr, "BBSHELL %s %s", cwd, prompt);
+ cmdedit_read_input(promptStr, fileno(stdin), fileno(stdout), command);
+ free( promptStr);
return 0;
+#else
+ fprintf(stdout, "%s %s", cwd, prompt);
+ fflush(stdout);
#endif
}