hush: fix preprocessor directives indentation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1b76ffaae4
commit
259747caa7
62
shell/hush.c
62
shell/hush.c
@ -3653,9 +3653,9 @@ static void debug_print_tree(struct pipe *pi, int lvl)
|
|||||||
fdprintf(2, "%*s cmd %d assignment_cnt:%d",
|
fdprintf(2, "%*s cmd %d assignment_cnt:%d",
|
||||||
lvl*2, "", prn,
|
lvl*2, "", prn,
|
||||||
command->assignment_cnt);
|
command->assignment_cnt);
|
||||||
#if ENABLE_HUSH_LINENO_VAR
|
# if ENABLE_HUSH_LINENO_VAR
|
||||||
fdprintf(2, " LINENO:%u", command->lineno);
|
fdprintf(2, " LINENO:%u", command->lineno);
|
||||||
#endif
|
# endif
|
||||||
if (command->group) {
|
if (command->group) {
|
||||||
fdprintf(2, " group %s: (argv=%p)%s%s\n",
|
fdprintf(2, " group %s: (argv=%p)%s%s\n",
|
||||||
CMDTYPE[command->cmd_type],
|
CMDTYPE[command->cmd_type],
|
||||||
@ -4771,9 +4771,9 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign
|
|||||||
# endif
|
# endif
|
||||||
end_ch &= (DOUBLE_CLOSE_CHAR_FLAG - 1);
|
end_ch &= (DOUBLE_CLOSE_CHAR_FLAG - 1);
|
||||||
|
|
||||||
#if ENABLE_HUSH_INTERACTIVE
|
# if ENABLE_HUSH_INTERACTIVE
|
||||||
G.promptmode = 1; /* PS2 */
|
G.promptmode = 1; /* PS2 */
|
||||||
#endif
|
# endif
|
||||||
debug_printf_prompt("%s promptmode=%d\n", __func__, G.promptmode);
|
debug_printf_prompt("%s promptmode=%d\n", __func__, G.promptmode);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -4829,13 +4829,13 @@ static int add_till_closing_bracket(o_string *dest, struct in_str *input, unsign
|
|||||||
syntax_error_unterm_ch(end_ch);
|
syntax_error_unterm_ch(end_ch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#if 0
|
# if 0
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
/* "backslash+newline", ignore both */
|
/* "backslash+newline", ignore both */
|
||||||
o_delchr(dest); /* undo insertion of '\' */
|
o_delchr(dest); /* undo insertion of '\' */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
o_addchr(dest, ch);
|
o_addchr(dest, ch);
|
||||||
//bb_error_msg("%s:o_addchr('%c') after '\\'", __func__, ch);
|
//bb_error_msg("%s:o_addchr('%c') after '\\'", __func__, ch);
|
||||||
continue;
|
continue;
|
||||||
@ -4992,7 +4992,7 @@ static int parse_dollar(o_string *as_string,
|
|||||||
if (last_ch == 0) /* error? */
|
if (last_ch == 0) /* error? */
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
#error Simple code to only allow ${var} is not implemented
|
# error Simple code to only allow ${var} is not implemented
|
||||||
#endif
|
#endif
|
||||||
if (as_string) {
|
if (as_string) {
|
||||||
o_addstr(as_string, dest->data + pos);
|
o_addstr(as_string, dest->data + pos);
|
||||||
@ -8701,9 +8701,9 @@ static int process_wait_result(struct pipe *fg_pipe, pid_t childpid, int status)
|
|||||||
pi->cmds[i].pid = 0;
|
pi->cmds[i].pid = 0;
|
||||||
pi->alive_cmds--;
|
pi->alive_cmds--;
|
||||||
if (!pi->alive_cmds) {
|
if (!pi->alive_cmds) {
|
||||||
#if ENABLE_HUSH_BASH_COMPAT
|
# if ENABLE_HUSH_BASH_COMPAT
|
||||||
G.dead_job_exitcode = job_exited_or_stopped(pi);
|
G.dead_job_exitcode = job_exited_or_stopped(pi);
|
||||||
#endif
|
# endif
|
||||||
if (G_interactive_fd) {
|
if (G_interactive_fd) {
|
||||||
printf(JOB_STATUS_FORMAT, pi->jobid,
|
printf(JOB_STATUS_FORMAT, pi->jobid,
|
||||||
"Done", pi->cmdtext);
|
"Done", pi->cmdtext);
|
||||||
@ -10552,10 +10552,10 @@ static int FAST_FUNC builtin_type(char **argv)
|
|||||||
if (0) {} /* make conditional compile easier below */
|
if (0) {} /* make conditional compile easier below */
|
||||||
/*else if (find_alias(*argv))
|
/*else if (find_alias(*argv))
|
||||||
type = "an alias";*/
|
type = "an alias";*/
|
||||||
#if ENABLE_HUSH_FUNCTIONS
|
# if ENABLE_HUSH_FUNCTIONS
|
||||||
else if (find_function(*argv))
|
else if (find_function(*argv))
|
||||||
type = "a function";
|
type = "a function";
|
||||||
#endif
|
# endif
|
||||||
else if (find_builtin(*argv))
|
else if (find_builtin(*argv))
|
||||||
type = "a shell builtin";
|
type = "a shell builtin";
|
||||||
else if ((path = find_in_path(*argv)) != NULL)
|
else if ((path = find_in_path(*argv)) != NULL)
|
||||||
@ -10610,11 +10610,11 @@ static int FAST_FUNC builtin_read(char **argv)
|
|||||||
* Option string must start with "sr" to match BUILTIN_READ_xxx
|
* Option string must start with "sr" to match BUILTIN_READ_xxx
|
||||||
*/
|
*/
|
||||||
params.read_flags = getopt32(argv,
|
params.read_flags = getopt32(argv,
|
||||||
#if BASH_READ_D
|
# if BASH_READ_D
|
||||||
"!srn:p:t:u:d:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u, ¶ms.opt_d
|
"!srn:p:t:u:d:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u, ¶ms.opt_d
|
||||||
#else
|
# else
|
||||||
"!srn:p:t:u:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u
|
"!srn:p:t:u:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u
|
||||||
#endif
|
# endif
|
||||||
);
|
);
|
||||||
if ((uint32_t)params.read_flags == (uint32_t)-1)
|
if ((uint32_t)params.read_flags == (uint32_t)-1)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -10787,24 +10787,24 @@ static int FAST_FUNC builtin_export(char **argv)
|
|||||||
{
|
{
|
||||||
unsigned opt_unexport;
|
unsigned opt_unexport;
|
||||||
|
|
||||||
#if ENABLE_HUSH_EXPORT_N
|
# if ENABLE_HUSH_EXPORT_N
|
||||||
/* "!": do not abort on errors */
|
/* "!": do not abort on errors */
|
||||||
opt_unexport = getopt32(argv, "!n");
|
opt_unexport = getopt32(argv, "!n");
|
||||||
if (opt_unexport == (uint32_t)-1)
|
if (opt_unexport == (uint32_t)-1)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
#else
|
# else
|
||||||
opt_unexport = 0;
|
opt_unexport = 0;
|
||||||
argv++;
|
argv++;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (argv[0] == NULL) {
|
if (argv[0] == NULL) {
|
||||||
char **e = environ;
|
char **e = environ;
|
||||||
if (e) {
|
if (e) {
|
||||||
while (*e) {
|
while (*e) {
|
||||||
#if 0
|
# if 0
|
||||||
puts(*e++);
|
puts(*e++);
|
||||||
#else
|
# else
|
||||||
/* ash emits: export VAR='VAL'
|
/* ash emits: export VAR='VAL'
|
||||||
* bash: declare -x VAR="VAL"
|
* bash: declare -x VAR="VAL"
|
||||||
* we follow ash example */
|
* we follow ash example */
|
||||||
@ -10817,7 +10817,7 @@ static int FAST_FUNC builtin_export(char **argv)
|
|||||||
printf("export %.*s", (int)(p - s) + 1, s);
|
printf("export %.*s", (int)(p - s) + 1, s);
|
||||||
print_escaped(p + 1);
|
print_escaped(p + 1);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
/*fflush_all(); - done after each builtin anyway */
|
/*fflush_all(); - done after each builtin anyway */
|
||||||
}
|
}
|
||||||
@ -11472,9 +11472,9 @@ static int FAST_FUNC builtin_kill(char **argv)
|
|||||||
|
|
||||||
#if ENABLE_HUSH_WAIT
|
#if ENABLE_HUSH_WAIT
|
||||||
/* http://www.opengroup.org/onlinepubs/9699919799/utilities/wait.html */
|
/* http://www.opengroup.org/onlinepubs/9699919799/utilities/wait.html */
|
||||||
#if !ENABLE_HUSH_JOB
|
# if !ENABLE_HUSH_JOB
|
||||||
# define wait_for_child_or_signal(pipe,pid) wait_for_child_or_signal(pid)
|
# define wait_for_child_or_signal(pipe,pid) wait_for_child_or_signal(pid)
|
||||||
#endif
|
# endif
|
||||||
static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid)
|
static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -11506,7 +11506,7 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
|
|||||||
/* Can't pass waitfor_pipe into checkjobs(): it won't be interruptible */
|
/* Can't pass waitfor_pipe into checkjobs(): it won't be interruptible */
|
||||||
ret = checkjobs(NULL, waitfor_pid); /* waitpid(WNOHANG) inside */
|
ret = checkjobs(NULL, waitfor_pid); /* waitpid(WNOHANG) inside */
|
||||||
debug_printf_exec("checkjobs:%d\n", ret);
|
debug_printf_exec("checkjobs:%d\n", ret);
|
||||||
#if ENABLE_HUSH_JOB
|
# if ENABLE_HUSH_JOB
|
||||||
if (waitfor_pipe) {
|
if (waitfor_pipe) {
|
||||||
int rcode = job_exited_or_stopped(waitfor_pipe);
|
int rcode = job_exited_or_stopped(waitfor_pipe);
|
||||||
debug_printf_exec("job_exited_or_stopped:%d\n", rcode);
|
debug_printf_exec("job_exited_or_stopped:%d\n", rcode);
|
||||||
@ -11516,7 +11516,7 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
/* if ECHILD, there are no children (ret is -1 or 0) */
|
/* if ECHILD, there are no children (ret is -1 or 0) */
|
||||||
/* if ret == 0, no children changed state */
|
/* if ret == 0, no children changed state */
|
||||||
/* if ret != 0, it's exitcode+1 of exited waitfor_pid child */
|
/* if ret != 0, it's exitcode+1 of exited waitfor_pid child */
|
||||||
@ -11524,12 +11524,12 @@ static int wait_for_child_or_signal(struct pipe *waitfor_pipe, pid_t waitfor_pid
|
|||||||
ret--;
|
ret--;
|
||||||
if (ret < 0) /* if ECHILD, may need to fix "ret" */
|
if (ret < 0) /* if ECHILD, may need to fix "ret" */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
#if ENABLE_HUSH_BASH_COMPAT
|
# if ENABLE_HUSH_BASH_COMPAT
|
||||||
if (waitfor_pid == -1 && errno == ECHILD) {
|
if (waitfor_pid == -1 && errno == ECHILD) {
|
||||||
/* exitcode of "wait -n" with no children is 127, not 0 */
|
/* exitcode of "wait -n" with no children is 127, not 0 */
|
||||||
ret = 127;
|
ret = 127;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -11558,14 +11558,14 @@ static int FAST_FUNC builtin_wait(char **argv)
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
argv = skip_dash_dash(argv);
|
argv = skip_dash_dash(argv);
|
||||||
#if ENABLE_HUSH_BASH_COMPAT
|
# if ENABLE_HUSH_BASH_COMPAT
|
||||||
if (argv[0] && strcmp(argv[0], "-n") == 0) {
|
if (argv[0] && strcmp(argv[0], "-n") == 0) {
|
||||||
/* wait -n */
|
/* wait -n */
|
||||||
/* (bash accepts "wait -n PID" too and ignores PID) */
|
/* (bash accepts "wait -n PID" too and ignores PID) */
|
||||||
G.dead_job_exitcode = -1;
|
G.dead_job_exitcode = -1;
|
||||||
return wait_for_child_or_signal(NULL, -1 /*no job, wait for one job*/);
|
return wait_for_child_or_signal(NULL, -1 /*no job, wait for one job*/);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
if (argv[0] == NULL) {
|
if (argv[0] == NULL) {
|
||||||
/* Don't care about wait results */
|
/* Don't care about wait results */
|
||||||
/* Note 1: must wait until there are no more children */
|
/* Note 1: must wait until there are no more children */
|
||||||
@ -11589,7 +11589,7 @@ static int FAST_FUNC builtin_wait(char **argv)
|
|||||||
do {
|
do {
|
||||||
pid_t pid = bb_strtou(*argv, NULL, 10);
|
pid_t pid = bb_strtou(*argv, NULL, 10);
|
||||||
if (errno || pid <= 0) {
|
if (errno || pid <= 0) {
|
||||||
#if ENABLE_HUSH_JOB
|
# if ENABLE_HUSH_JOB
|
||||||
if (argv[0][0] == '%') {
|
if (argv[0][0] == '%') {
|
||||||
struct pipe *wait_pipe;
|
struct pipe *wait_pipe;
|
||||||
ret = 127; /* bash compat for bad jobspecs */
|
ret = 127; /* bash compat for bad jobspecs */
|
||||||
@ -11606,7 +11606,7 @@ static int FAST_FUNC builtin_wait(char **argv)
|
|||||||
/* else: parse_jobspec() already emitted error msg */
|
/* else: parse_jobspec() already emitted error msg */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
/* mimic bash message */
|
/* mimic bash message */
|
||||||
bb_error_msg("wait: '%s': not a pid or valid job spec", *argv);
|
bb_error_msg("wait: '%s': not a pid or valid job spec", *argv);
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
@ -11628,7 +11628,7 @@ static int FAST_FUNC builtin_wait(char **argv)
|
|||||||
ret = G.last_bg_pid_exitcode;
|
ret = G.last_bg_pid_exitcode;
|
||||||
} else {
|
} else {
|
||||||
/* Example: "wait 1". mimic bash message */
|
/* Example: "wait 1". mimic bash message */
|
||||||
bb_error_msg("wait: pid %d is not a child of this shell", (int)pid);
|
bb_error_msg("wait: pid %u is not a child of this shell", (unsigned)pid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* ??? */
|
/* ??? */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user