aboutsummaryrefslogtreecommitdiff
path: root/ash.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-07-07 00:05:55 +0000
committerEric Andersen <andersen@codepoet.org>2001-07-07 00:05:55 +0000
commit1c03923b0b50d710cf78d02cf2a2fc80090455ef (patch)
tree1089bdbb9d8a20b986300ba598f3e639e6a848ec /ash.c
parentb7e6f13b3c264f6d689f0eefc61d4718c3043062 (diff)
downloadbusybox-w32-1c03923b0b50d710cf78d02cf2a2fc80090455ef.tar.gz
busybox-w32-1c03923b0b50d710cf78d02cf2a2fc80090455ef.tar.bz2
busybox-w32-1c03923b0b50d710cf78d02cf2a2fc80090455ef.zip
Add in a shell tagline (per lash/hush behavior) to make it easier
to know which shell is in use. Add in 'help' to list available builtins, and fixup msh so it can do STANDALONE_SHELL. -Erik
Diffstat (limited to 'ash.c')
-rw-r--r--ash.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/ash.c b/ash.c
index 99460d3d6..4250f50e2 100644
--- a/ash.c
+++ b/ash.c
@@ -1603,6 +1603,7 @@ static int exitcmd (int, char **);
1603static int exportcmd (int, char **); 1603static int exportcmd (int, char **);
1604static int histcmd (int, char **); 1604static int histcmd (int, char **);
1605static int hashcmd (int, char **); 1605static int hashcmd (int, char **);
1606static int helpcmd (int, char **);
1606static int jobscmd (int, char **); 1607static int jobscmd (int, char **);
1607static int localcmd (int, char **); 1608static int localcmd (int, char **);
1608#ifndef BB_PWD 1609#ifndef BB_PWD
@@ -1704,6 +1705,7 @@ static const struct builtincmd builtincmds[] = {
1704 { BUILTIN_REGULAR "getopts", getoptscmd }, 1705 { BUILTIN_REGULAR "getopts", getoptscmd },
1705#endif 1706#endif
1706 { BUILTIN_NOSPEC "hash", hashcmd }, 1707 { BUILTIN_NOSPEC "hash", hashcmd },
1708 { BUILTIN_NOSPEC "help", helpcmd },
1707 { BUILTIN_REGULAR "jobs", jobscmd }, 1709 { BUILTIN_REGULAR "jobs", jobscmd },
1708#ifdef JOBS 1710#ifdef JOBS
1709 { BUILTIN_REGULAR "kill", killcmd }, 1711 { BUILTIN_REGULAR "kill", killcmd },
@@ -3274,6 +3276,7 @@ static void
3274setinteractive(int on) 3276setinteractive(int on)
3275{ 3277{
3276 static int is_interactive; 3278 static int is_interactive;
3279 static int do_banner=0;
3277 3280
3278 if (on == is_interactive) 3281 if (on == is_interactive)
3279 return; 3282 return;
@@ -3282,6 +3285,12 @@ setinteractive(int on)
3282 setsignal(SIGTERM); 3285 setsignal(SIGTERM);
3283 chkmail(1); 3286 chkmail(1);
3284 is_interactive = on; 3287 is_interactive = on;
3288 if (do_banner==0 && is_interactive) {
3289 /* Looks like they want an interactive shell */
3290 printf( "\n\n" BB_BANNER " Built-in shell (ash)\n");
3291 printf( "Enter 'help' for a list of built-in commands.\n\n");
3292 do_banner=1;
3293 }
3285} 3294}
3286 3295
3287static void 3296static void
@@ -3802,6 +3811,51 @@ printentry(cmdp, verbose)
3802 3811
3803 3812
3804 3813
3814/*** List the available builtins ***/
3815
3816
3817static int helpcmd(int argc, char** argv)
3818{
3819 int col, i;
3820 const struct builtincmd *x;
3821
3822 printf("\nBuilt-in commands:\n");
3823 printf("-------------------\n");
3824 for (col=0, i=0, x = builtincmds; i < NUMBUILTINS; x++, i++) {
3825 if (!x->name || ! (x->name+1))
3826 continue;
3827 col += printf("%s%s", ((col == 0) ? "\t" : " "),
3828 (x->name+1));
3829 if (col > 60) {
3830 printf("\n");
3831 col = 0;
3832 }
3833 }
3834#ifdef BB_FEATURE_SH_STANDALONE_SHELL
3835 {
3836 const struct BB_applet *applet;
3837 extern const struct BB_applet applets[];
3838 extern const size_t NUM_APPLETS;
3839
3840 for (i=0, applet = applets; i < NUM_APPLETS; applet++, i++) {
3841 if (!applet->name)
3842 continue;
3843
3844 col += printf("%s%s", ((col == 0) ? "\t" : " "),
3845 applet->name);
3846 if (col > 60) {
3847 printf("\n");
3848 col = 0;
3849 }
3850 }
3851 }
3852#endif
3853 printf("\n\n");
3854 return EXIT_SUCCESS;
3855}
3856
3857
3858
3805/* 3859/*
3806 * Resolve a command name. If you change this routine, you may have to 3860 * Resolve a command name. If you change this routine, you may have to
3807 * change the shellexec routine as well. 3861 * change the shellexec routine as well.
@@ -7755,6 +7809,11 @@ shell_main(argc, argv)
7755 EXECCMD = find_builtin("exec"); 7809 EXECCMD = find_builtin("exec");
7756 EVALCMD = find_builtin("eval"); 7810 EVALCMD = find_builtin("eval");
7757 7811
7812#ifndef BB_FEATURE_SH_FANCY_PROMPT
7813 unsetenv("PS1");
7814 unsetenv("PS2");
7815#endif
7816
7758#if PROFILE 7817#if PROFILE
7759 monitor(4, etext, profile_buf, sizeof profile_buf, 50); 7818 monitor(4, etext, profile_buf, sizeof profile_buf, 50);
7760#endif 7819#endif
@@ -13088,7 +13147,7 @@ findvar(struct var **vpp, const char *name)
13088/* 13147/*
13089 * Copyright (c) 1999 Herbert Xu <herbert@debian.org> 13148 * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
13090 * This file contains code for the times builtin. 13149 * This file contains code for the times builtin.
13091 * $Id: ash.c,v 1.6 2001/07/06 04:26:23 andersen Exp $ 13150 * $Id: ash.c,v 1.7 2001/07/07 00:05:55 andersen Exp $
13092 */ 13151 */
13093static int timescmd (int argc, char **argv) 13152static int timescmd (int argc, char **argv)
13094{ 13153{