static void * brkaddr;
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
static char * current_prompt;
#endif
setval(ifs, " \t\n");
prompt = lookup("PS1");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
if (prompt->value == null)
#endif
setval(prompt, "$ ");
prompt->status &= ~EXPORT;
}
cprompt = lookup("PS2");
-#ifdef BB_FEATURE_SH_FANCY_PROMPT
+#ifdef CONFIG_FEATURE_SH_FANCY_PROMPT
if (cprompt->value == null)
#endif
setval(cprompt, "> ");
PUSHIO(afile, 0, iof);
if (isatty(0) && isatty(1) && !cflag) {
interactive++;
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
printf( "\n\n" BB_BANNER " Built-in shell (msh)\n");
printf( "Enter 'help' for a list of built-in commands.\n\n");
+#endif
}
}
signal(SIGQUIT, qflag);
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=prompt->value;
#else
prs(prompt->value);
#endif
}
onecommand();
+ /* Ensure that getenv("PATH") stays current */
+ setenv("PATH", path->value, 1);
}
}
ronly(vp)
struct var *vp;
{
- if (isalpha(vp->name[0])) /* not an internal symbol ($# etc) */
+ if (isalpha(vp->name[0]) || vp->name[0] == '_') /* not an internal symbol */
vp->status |= RONLY;
}
isassign(s)
register char *s;
{
- if (!isalpha((int)*s))
+ if (!isalpha((int)*s) && *s != '_')
return(0);
for (; *s != '='; s++)
- if (*s == 0 || !isalnum(*s))
+ if (*s == 0 || (!isalnum(*s) && *s != '_'))
return(0);
return(1);
}
register char *cp;
struct var *vp;
- if (!isalpha(*s))
+ if (!isalpha(*s) && *s != '_')
return(0);
for (cp = s; *cp != '='; cp++)
- if (*cp == 0 || !isalnum(*cp))
+ if (*cp == 0 || (!isalnum(*cp) && *cp != '_'))
return(0);
vp = lookup(s);
nameval(vp, ++cp, cf == COPYV? (char *)NULL: s);
checkname(cp)
register char *cp;
{
- if (!isalpha(*cp++))
+ if (!isalpha(*cp++) && *(cp-1) != '_')
return(0);
while (*cp)
- if (!isalnum(*cp++))
+ if (!isalnum(*cp++) && *(cp-1) != '_')
return(0);
return(1);
}
register struct var *vp;
for (vp = vlist; vp; vp = vp->next)
- if (vp->status & f && isalpha(*vp->name)) {
+ if (vp->status & f && (isalpha(*vp->name) || *vp->name == '_')) {
if (vp->status & EXPORT)
write(out, "export ", 7);
if (vp->status & RONLY)
startl = 1;
if (multiline || cf & CONTIN) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);
return(YYERRCODE);
}
if (interactive && c == '\n' && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);
register char *sp, *tp;
int eacces = 0, asis = 0;
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
char *name = c;
-#ifdef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
+#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
name = get_last_path_component(name);
#endif
optind = 1;
col = 0;
}
}
-#ifdef BB_FEATURE_SH_STANDALONE_SHELL
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
{
int i;
const struct BB_applet *applet;
register char *s;
int out;
{
- if (isalnum(*s)) {
+ if (isalnum(*s) || *s == '_') {
write(out, s, strlen(s));
write(out, "\n", 1);
}
c = 0;
}
unget(c);
- if (!isalpha(c))
+ if (!isalpha(c) && c != '_')
scanequals = 0;
for (;;) {
c = subgetc('"', foundequals);
foundequals = 1;
scanequals = 0;
}
- else if (!isalnum(c))
+ else if (!isalnum(c) && c != '_')
scanequals = 0;
}
*e.linep++ = c;
s = e.linep;
if (c != '{') {
*e.linep++ = c;
- if (isalpha(c)) {
- while ((c = readc())!=0 && isalnum(c))
+ if (isalpha(c) || c == '_') {
+ while ((c = readc())!=0 && (isalnum(c) || c == '_'))
if (e.linep < elinep)
*e.linep++ = c;
unget(c);
if (multiline)
return e.iop->prev = 0;
if (interactive && e.iop == iostack+1) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=prompt->value;
#else
prs(prompt->value);
return *bp->bufp++ & 0177;
}
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
if (interactive) {
static char mycommand[BUFSIZ];
static int position = 0, size = 0;
e.iobase = e.iop;
for (;;) {
if (interactive && e.iop <= iostack) {
-#ifdef BB_FEATURE_COMMAND_EDITING
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
current_prompt=cprompt->value;
#else
prs(cprompt->value);