#define JOB_STATUS_FORMAT "[%u] %-22s %.40s\n"
-#define _SPECIAL_VARS_STR "_*@$!?#"
-#define SPECIAL_VARS_STR ("_*@$!?#" + 1)
-#define NUMERIC_SPECVARS_STR ("_*@$!?#" + 3)
+#define _SPECIAL_VARS_STR "_*@$!?#-"
+#define SPECIAL_VARS_STR ("_*@$!?#-" + 1)
+#define NUMERIC_SPECVARS_STR ("_*@$!?#-" + 3)
#if BASH_PATTERN_SUBST
/* Support / and // replace ops */
/* Note that // is stored as \ in "encoded" string representation */
int debug_indent;
#endif
struct sigaction sa;
+ char optstring_buf[sizeof("eix")];
#if BASH_EPOCH_VARS
char epoch_buf[sizeof("%lu.nnnnnn") + sizeof(long)*3];
#endif
case '#': /* number of args */
case '*': /* args */
case '@': /* args */
+ case '-': /* $- option flags set by set builtin or shell options (-i etc) */
goto make_one_char_var;
case '{': {
char len_single_ch;
case '_':
goto make_var;
#if 0
- /* TODO: $_ and $-: */
+ /* TODO: $_: */
/* $_ Shell or shell script name; or last argument of last command
* (if last command wasn't a pipe; if it was, bash sets $_ to "");
* but in command's env, set to full pathname used to invoke it */
- /* $- Option flags set by set builtin or shell options (-i etc) */
ch = i_getch(input);
nommu_addchr(as_string, ch);
ch = i_peek_and_eat_bkslash_nl(input);
case '#': /* argc */
val = utoa(G.global_argc ? G.global_argc-1 : 0);
break;
+ case '-': { /* active options */
+ /* Check set_mode() to see what option chars we support */
+ char *cp;
+ val = cp = G.optstring_buf;
+ if (G.o_opt[OPT_O_ERREXIT])
+ *cp++ = 'e';
+ if (G_interactive_fd)
+ *cp++ = 'i';
+ if (G_x_mode)
+ *cp++ = 'x';
+ /* If G.o_opt[OPT_O_NOEXEC] is true,
+ * commands read but are not executed,
+ * so $- can not execute too, 'n' is never seen in $-.
+ */
+ *cp = '\0';
+ break;
+ }
default:
val = get_local_var_value(var);
}
/* IFS is not inherited from the parent environment */
set_local_var_from_halves("IFS", defifs);
+ if (!get_local_var_value("PATH"))
+ set_local_var_from_halves("PATH", bb_default_root_path);
+
/* PS1/PS2 are set later, if we determine that we are interactive */
/* bash also exports SHLVL and _,