aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2013-03-19 11:18:39 +0000
committerRon Yorston <rmy@pobox.com>2013-03-19 11:18:39 +0000
commit63d2c5fead323df5f4250ed544d0bc03527c8936 (patch)
tree660979b139a4bc4b143c08843cb7efbc69bdcb4d /shell/ash.c
parent27fc2d535588728ac3ca69337271471fb6fe3ee9 (diff)
parenta42f530e034b673726a91ea5d8202254e677f066 (diff)
downloadbusybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.gz
busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.bz2
busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c61
1 files changed, 26 insertions, 35 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 75c01ec14..962fc2609 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -441,6 +441,9 @@ static void trace_vprintf(const char *fmt, va_list va);
441/* ============ Utility functions */ 441/* ============ Utility functions */
442#define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0) 442#define xbarrier() do { __asm__ __volatile__ ("": : :"memory"); } while (0)
443 443
444#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
445#define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
446
444static int isdigit_str9(const char *str) 447static int isdigit_str9(const char *str)
445{ 448{
446 int maxlen = 9 + 1; /* max 9 digits: 999999999 */ 449 int maxlen = 9 + 1; /* max 9 digits: 999999999 */
@@ -2064,27 +2067,6 @@ getoptsreset(const char *value)
2064} 2067}
2065#endif 2068#endif
2066 2069
2067/* math.h has these, otherwise define our private copies */
2068#if !ENABLE_SH_MATH_SUPPORT
2069#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
2070#define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c)))
2071/*
2072 * Return the pointer to the first char which is not part of a legal variable name
2073 * (a letter or underscore followed by letters, underscores, and digits).
2074 */
2075static const char*
2076endofname(const char *name)
2077{
2078 if (!is_name(*name))
2079 return name;
2080 while (*++name) {
2081 if (!is_in_name(*name))
2082 break;
2083 }
2084 return name;
2085}
2086#endif
2087
2088/* 2070/*
2089 * Compares two strings up to the first = or '\0'. The first 2071 * Compares two strings up to the first = or '\0'. The first
2090 * string must be terminated by '='; the second may be terminated by 2072 * string must be terminated by '='; the second may be terminated by
@@ -12774,6 +12756,9 @@ dotcmd(int argc, char **argv)
12774 /* "false; . empty_file; echo $?" should print 0, not 1: */ 12756 /* "false; . empty_file; echo $?" should print 0, not 1: */
12775 exitstatus = 0; 12757 exitstatus = 0;
12776 12758
12759 /* This aborts if file isn't found, which is POSIXly correct.
12760 * bash returns exitcode 1 instead.
12761 */
12777 fullname = find_dot_file(argv[1]); 12762 fullname = find_dot_file(argv[1]);
12778 12763
12779 argv += 2; 12764 argv += 2;
@@ -12785,6 +12770,9 @@ dotcmd(int argc, char **argv)
12785 shellparam.p = argv; 12770 shellparam.p = argv;
12786 }; 12771 };
12787 12772
12773 /* This aborts if file can't be opened, which is POSIXly correct.
12774 * bash returns exitcode 1 instead.
12775 */
12788 setinputfile(fullname, INPUT_PUSH_FILE); 12776 setinputfile(fullname, INPUT_PUSH_FILE);
12789 commandname = fullname; 12777 commandname = fullname;
12790 cmdloop(0); 12778 cmdloop(0);
@@ -13832,27 +13820,21 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
13832#endif 13820#endif
13833 procargs(argv); 13821 procargs(argv);
13834 13822
13835#if ENABLE_FEATURE_EDITING_SAVEHISTORY
13836 if (iflag) {
13837 const char *hp = lookupvar("HISTFILE");
13838 if (!hp) {
13839 hp = lookupvar("HOME");
13840 if (hp) {
13841 char *defhp = concat_path_file(hp, ".ash_history");
13842 setvar("HISTFILE", defhp, 0);
13843 free(defhp);
13844 }
13845 }
13846 }
13847#endif
13848 if (argv[0] && argv[0][0] == '-') 13823 if (argv[0] && argv[0][0] == '-')
13849 isloginsh = 1; 13824 isloginsh = 1;
13850 if (isloginsh) { 13825 if (isloginsh) {
13826 const char *hp;
13827
13851 state = 1; 13828 state = 1;
13852 read_profile("/etc/profile"); 13829 read_profile("/etc/profile");
13853 state1: 13830 state1:
13854 state = 2; 13831 state = 2;
13855 read_profile(".profile"); 13832 hp = lookupvar("HOME");
13833 if (hp) {
13834 hp = concat_path_file(hp, ".profile");
13835 read_profile(hp);
13836 free((char*)hp);
13837 }
13856 } 13838 }
13857 state2: 13839 state2:
13858 state = 3; 13840 state = 3;
@@ -13884,6 +13866,15 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
13884#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY 13866#if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
13885 if (iflag) { 13867 if (iflag) {
13886 const char *hp = lookupvar("HISTFILE"); 13868 const char *hp = lookupvar("HISTFILE");
13869 if (!hp) {
13870 hp = lookupvar("HOME");
13871 if (hp) {
13872 hp = concat_path_file(hp, ".ash_history");
13873 setvar("HISTFILE", hp, 0);
13874 free((char*)hp);
13875 hp = lookupvar("HISTFILE");
13876 }
13877 }
13887 if (hp) 13878 if (hp)
13888 line_input_state->hist_file = hp; 13879 line_input_state->hist_file = hp;
13889# if ENABLE_FEATURE_SH_HISTFILESIZE 13880# if ENABLE_FEATURE_SH_HISTFILESIZE