hush: more style fixes.

This commit is contained in:
Denis Vlasenko
2007-04-13 19:56:56 +00:00
parent f03dbeda90
commit fbf6dea5a2

View File

@@ -104,7 +104,11 @@ typedef enum {
/* The descrip member of this structure is only used to make debugging /* The descrip member of this structure is only used to make debugging
* output pretty */ * output pretty */
static const struct {int mode; int default_fd; const char *descrip;} redir_table[] = { static const struct {
int mode;
int default_fd;
const char *descrip;
} redir_table[] = {
{ 0, 0, "()" }, { 0, 0, "()" },
{ O_RDONLY, 0, "<" }, { O_RDONLY, 0, "<" },
{ O_CREAT|O_TRUNC|O_WRONLY, 1, ">" }, { O_CREAT|O_TRUNC|O_WRONLY, 1, ">" },
@@ -2661,7 +2665,8 @@ static int parse_file_outer(FILE *f)
* we don't fight over who gets the foreground */ * we don't fight over who gets the foreground */
static void setup_job_control(void) static void setup_job_control(void)
{ {
static pid_t shell_pgrp; /*static --why?? */ pid_t shell_pgrp;
/* Loop until we are in the foreground. */ /* Loop until we are in the foreground. */
while (tcgetpgrp(shell_terminal) != (shell_pgrp = getpgrp())) while (tcgetpgrp(shell_terminal) != (shell_pgrp = getpgrp()))
kill(- shell_pgrp, SIGTTIN); kill(- shell_pgrp, SIGTTIN);
@@ -2689,7 +2694,7 @@ int hush_main(int argc, char **argv)
{ {
int opt; int opt;
FILE *input; FILE *input;
char **e = environ; char **e;
#if ENABLE_FEATURE_EDITING #if ENABLE_FEATURE_EDITING
line_input_state = new_line_input_t(FOR_SHELL); line_input_state = new_line_input_t(FOR_SHELL);
@@ -2720,10 +2725,10 @@ int hush_main(int argc, char **argv)
/* initialize our shell local variables with the values /* initialize our shell local variables with the values
* currently living in the environment */ * currently living in the environment */
if (e) { e = environ;
for (; *e; e++) if (e)
set_local_var(*e, 2); /* without call putenv() */ while (*e)
} set_local_var(*e++, 2); /* without call putenv() */
last_return_code = EXIT_SUCCESS; last_return_code = EXIT_SUCCESS;
@@ -2742,13 +2747,10 @@ int hush_main(int argc, char **argv)
while ((opt = getopt(argc, argv, "c:xif")) > 0) { while ((opt = getopt(argc, argv, "c:xif")) > 0) {
switch (opt) { switch (opt) {
case 'c': case 'c':
{
global_argv = argv+optind; global_argv = argv+optind;
global_argc = argc-optind; global_argc = argc-optind;
opt = parse_string_outer(optarg, FLAG_PARSE_SEMICOLON); opt = parse_string_outer(optarg, FLAG_PARSE_SEMICOLON);
goto final_return; goto final_return;
}
break;
case 'i': case 'i':
interactive++; interactive++;
break; break;
@@ -2765,13 +2767,13 @@ int hush_main(int argc, char **argv)
#endif #endif
} }
} }
/* A shell is interactive if the `-i' flag was given, or if all of /* A shell is interactive if the '-i' flag was given, or if all of
* the following conditions are met: * the following conditions are met:
* no -c command * no -c command
* no arguments remaining or the -s flag given * no arguments remaining or the -s flag given
* standard input is a terminal * standard input is a terminal
* standard output is a terminal * standard output is a terminal
* Refer to Posix.2, the description of the `sh' utility. */ * Refer to Posix.2, the description of the 'sh' utility. */
if (argv[optind] == NULL && input == stdin if (argv[optind] == NULL && input == stdin
&& isatty(STDIN_FILENO) && isatty(STDOUT_FILENO) && isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)
) { ) {
@@ -2802,7 +2804,7 @@ int hush_main(int argc, char **argv)
#if ENABLE_FEATURE_CLEAN_UP #if ENABLE_FEATURE_CLEAN_UP
fclose(input); fclose(input);
if (cwd && cwd != bb_msg_unknown) if (cwd != bb_msg_unknown)
free((char*)cwd); free((char*)cwd);
{ {
struct variables *cur, *tmp; struct variables *cur, *tmp;