X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=shell%2Fhush.c;h=9bc0013d743728af9ce7a91dc9295dc2016a872b;hb=98ee06d3d46aa7f89c204681c7075b53300a6a6e;hp=230b0fb69a646d6b635aeaa38f54707560bc7afc;hpb=88621d73980a3cb53c1f35e64a06d7cd64188987;p=oweals%2Fbusybox.git diff --git a/shell/hush.c b/shell/hush.c index 230b0fb69..9bc0013d7 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -312,7 +312,8 @@ static char *indenter(int i) static void __syntax(char *file, int line) { bb_error_msg("syntax error %s:%d", file, line); } -#define syntax() __syntax(__FILE__, __LINE__) +// NB: was __FILE__, but that produces full path sometimess, so... +#define syntax() __syntax("hush.c", __LINE__) /* Index of subroutines: */ /* function prototypes for builtins */ @@ -398,7 +399,7 @@ static int set_local_var(const char *s, int flg_export); /* Table of built-in functions. They can be forked or not, depending on * context: within pipes, they fork. As simple commands, they do not. * When used in non-forking context, they can change global variables - * in the parent shell process. If forked, of course they can not. + * in the parent shell process. If forked, of course they cannot. * For example, 'unset foo | whatever' will parse and run, but foo will * still be set at the end. */ static const struct built_in_command bltins[] = { @@ -506,7 +507,7 @@ static int builtin_export(struct child_prog *child) char *name = child->argv[1]; if (name == NULL) { - return (builtin_env(child)); + return builtin_env(child); } name = strdup(name); @@ -717,7 +718,7 @@ static int builtin_source(struct child_prog *child) /* XXX search through $PATH is missing */ input = fopen(child->argv[1], "r"); if (!input) { - bb_error_msg("Couldn't open file '%s'", child->argv[1]); + bb_error_msg("cannot open '%s'", child->argv[1]); return EXIT_FAILURE; } @@ -729,7 +730,7 @@ static int builtin_source(struct child_prog *child) status = parse_file_outer(input); mark_closed(fileno(input)); fclose(input); - return (status); + return status; } static int builtin_umask(struct child_prog *child) @@ -1120,7 +1121,7 @@ static void pseudo_exec(struct child_prog *child) #endif debug_printf("exec of %s\n",child->argv[0]); execvp(child->argv[0],child->argv); - bb_perror_msg("couldn't exec: %s",child->argv[0]); + bb_perror_msg("cannot exec: %s",child->argv[0]); _exit(1); } else if (child->group) { debug_printf("runtime nesting to group\n"); @@ -1224,7 +1225,7 @@ static int checkjobs(struct pipe* fg_pipe) if (i==fg_pipe->num_progs-1) rcode=WEXITSTATUS(status); (fg_pipe->num_progs)--; - return(rcode); + return rcode; } } } @@ -2268,7 +2269,7 @@ static int parse_group(o_string *dest, struct p_context *ctx, return 1; /* syntax error, groups and arglists don't mix */ } initialize_context(&sub); - switch(ch) { + switch (ch) { case '(': endch=')'; child->subshell=1; break; case '{': endch='}'; break; default: syntax(); /* really logic error */ @@ -2664,11 +2665,8 @@ int hush_main(int argc, char **argv) /* Initialize some more globals to non-zero values */ set_cwd(); -#ifdef CONFIG_FEATURE_COMMAND_EDITING - cmdedit_set_initial_prompt(); -#else - PS1 = NULL; -#endif + if (ENABLE_FEATURE_COMMAND_EDITING) cmdedit_set_initial_prompt(); + else PS1 = NULL; PS2 = "> "; /* initialize our shell local variables with the values @@ -2770,7 +2768,7 @@ int hush_main(int argc, char **argv) #endif final_return: - return(opt?opt:last_return_code); + return opt ? opt : last_return_code; } static char *insert_var_value(char *inp)