>From 698c8ae89e1bbea8d047d48c66067b09e0c38dc9 Mon Sep 17 00:00:00 2001 From: Daniel Reichelt Date: Sun, 31 Mar 2013 15:08:49 +0200 Subject: [PATCH 1/2] add flag 'N' --- bash/flags.c | 16 +++++++++++++++- bash/flags.h | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bash/flags.c b/bash/flags.c index d3b38ad..fd78008 100644 --- a/bash/flags.c +++ b/bash/flags.c @@ -75,6 +75,11 @@ int place_keywords_in_env = 0; destructive. */ int read_but_dont_execute = 0; +/* Non-zero means print commands if read_and_print_but_dont_execute is non-zero. + This is useful for static analysis of commands to be executed in a + script */ +int read_and_print_but_dont_execute = 0; + /* Non-zero means end of file is after one command. */ int just_one_command = 0; @@ -184,6 +189,7 @@ const struct flags_alist shell_flags[] = { { 'm', &jobs_m_flag }, #endif /* JOB_CONTROL */ { 'n', &read_but_dont_execute }, + { 'N', &read_and_print_but_dont_execute }, { 'p', &privileged_mode }, #if defined (RESTRICTED_SHELL) { 'r', &restricted }, @@ -274,6 +280,14 @@ change_flag (flag, on_or_off) read_but_dont_execute = 0; break; + case 'N': /* set 'n' as well */ + if (interactive_shell) { + read_but_dont_execute = 0; + } else { + read_but_dont_execute = 1; + } + break; + case 'p': if (on_or_off == FLAG_OFF) disable_priv_mode (); @@ -317,7 +331,7 @@ void reset_shell_flags () { mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0; - place_keywords_in_env = read_but_dont_execute = just_one_command = 0; + place_keywords_in_env = read_but_dont_execute = read_and_print_but_dont_execute = just_one_command = 0; noclobber = unbound_vars_is_error = echo_input_at_read = 0; echo_command_at_execute = jobs_m_flag = forced_interactive = 0; no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0; diff --git a/bash/flags.h b/bash/flags.h index d8fa757..aab4291 100644 --- a/bash/flags.h +++ b/bash/flags.h @@ -42,7 +42,7 @@ extern char optflags[]; extern int mark_modified_vars, exit_immediately_on_error, disallow_filename_globbing, - place_keywords_in_env, read_but_dont_execute, + place_keywords_in_env, read_but_dont_execute, read_and_print_but_dont_execute, just_one_command, unbound_vars_is_error, echo_input_at_read, echo_command_at_execute, no_invisible_vars, noclobber, hashing_enabled, forced_interactive, privileged_mode, -- 1.7.2.5