mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 00:39:48 +08:00
Hide no_exec behind a function
This commit is contained in:
parent
be41407610
commit
4fcb9d1fed
|
@ -156,7 +156,7 @@ wcstring builtin_help_get(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
UNUSED(parser);
|
||||
UNUSED(streams);
|
||||
// This won't ever work if no_exec is set.
|
||||
if (no_exec) return wcstring();
|
||||
if (no_exec()) return wcstring();
|
||||
|
||||
wcstring_list_t lst;
|
||||
wcstring out;
|
||||
|
|
|
@ -1019,7 +1019,7 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
|
|||
bool exec_error = false;
|
||||
|
||||
// If fish was invoked with -n or --no-execute, then no_exec will be set and we do nothing.
|
||||
if (no_exec) {
|
||||
if (no_exec()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) {
|
|||
break;
|
||||
}
|
||||
case 'n': {
|
||||
no_exec = 1;
|
||||
set_no_exec(true);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
@ -390,9 +390,9 @@ int main(int argc, char **argv) {
|
|||
my_optind = fish_parse_opt(argc, argv, &opts);
|
||||
|
||||
// No-exec is prohibited when in interactive mode.
|
||||
if (is_interactive_session && no_exec) {
|
||||
if (is_interactive_session && no_exec()) {
|
||||
debug(1, _(L"Can not use the no-execute mode when running an interactive session"));
|
||||
no_exec = 0;
|
||||
set_no_exec(false);
|
||||
}
|
||||
|
||||
// Only save (and therefore restore) the fg process group if we are interactive. See issues
|
||||
|
|
|
@ -601,7 +601,7 @@ parse_execution_result_t parse_execution_context_t::run_while_statement(
|
|||
|
||||
// no_exec means that fish was invoked with -n or --no-execute. If set, we allow the loop to
|
||||
// not-execute once so its contents can be checked, and then break.
|
||||
if (no_exec) {
|
||||
if (no_exec()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -959,7 +959,7 @@ bool parse_execution_context_t::determine_io_chain(tnode_t<g::arguments_or_redir
|
|||
|
||||
// PCA: I can't justify this skip_variables flag. It was like this when I got here.
|
||||
bool target_expanded =
|
||||
expand_one(target, no_exec ? expand_flag::skip_variables : expand_flags_t{},
|
||||
expand_one(target, no_exec() ? expand_flag::skip_variables : expand_flags_t{},
|
||||
parser->vars(), parser->shared());
|
||||
if (!target_expanded || target.empty()) {
|
||||
// TODO: Improve this error message.
|
||||
|
|
|
@ -58,7 +58,10 @@ bool is_block = false;
|
|||
bool is_breakpoint = false;
|
||||
bool is_login = false;
|
||||
int is_event = 0;
|
||||
int no_exec = 0;
|
||||
|
||||
static relaxed_atomic_bool_t s_no_exec;
|
||||
bool no_exec() { return s_no_exec; }
|
||||
void set_no_exec(bool flag) { s_no_exec = flag; }
|
||||
|
||||
bool have_proc_stat() {
|
||||
// Check for /proc/self/stat to see if we are running with Linux-style procfs.
|
||||
|
|
|
@ -448,7 +448,8 @@ void set_job_control_mode(job_control_t mode);
|
|||
/// If this flag is set, fish will never fork or run execve. It is used to put fish into a syntax
|
||||
/// verifier mode where fish tries to validate the syntax of a file but doesn't actually do
|
||||
/// anything.
|
||||
extern int no_exec;
|
||||
bool no_exec();
|
||||
void set_no_exec(bool flag);
|
||||
|
||||
/// Notify the user about stopped or terminated jobs, and delete completed jobs from the job list.
|
||||
/// If \p interactive is set, allow removing interactive jobs; otherwise skip them.
|
||||
|
|
Loading…
Reference in New Issue
Block a user