aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--exec.c7
-rw-r--r--main.c21
-rw-r--r--parser.c2
-rw-r--r--proc.c2
-rw-r--r--proc.h6
-rw-r--r--share/completions/fish.fish1
6 files changed, 34 insertions, 5 deletions
diff --git a/exec.c b/exec.c
index 9dff5985..e9373160 100644
--- a/exec.c
+++ b/exec.c
@@ -653,8 +653,6 @@ void exec( job_t *j )
pid_t pid;
int mypipe[2];
sigset_t chldset;
- sigemptyset( &chldset );
- sigaddset( &chldset, SIGCHLD );
int skip_fork;
io_data_t pipe_read, pipe_write;
@@ -667,6 +665,11 @@ void exec( job_t *j )
*/
int exec_error=0;
+ if( no_exec )
+ return;
+
+ sigemptyset( &chldset );
+ sigaddset( &chldset, SIGCHLD );
debug( 4, L"Exec job '%ls' with id %d", j->command, j->job_id );
diff --git a/main.c b/main.c
index 9e0b90bc..85f92f34 100644
--- a/main.c
+++ b/main.c
@@ -139,6 +139,10 @@ int main( int argc, char **argv )
}
,
{
+ "no-execute", no_argument, 0, 'n'
+ }
+ ,
+ {
"profile", required_argument, 0, 'p'
}
,
@@ -160,14 +164,14 @@ int main( int argc, char **argv )
int opt = getopt_long( argc,
argv,
- "hilvc:p:d:",
+ "hilnvc:p:d:",
long_options,
&opt_index );
#else
int opt = getopt( argc,
argv,
- "hilvc:p:d:" );
+ "hilnvc:p:d:" );
#endif
if( opt == -1 )
break;
@@ -210,6 +214,10 @@ int main( int argc, char **argv )
is_login=1;
break;
+ case 'n':
+ no_exec=1;
+ break;
+
case 'p':
profile = optarg;
break;
@@ -236,6 +244,15 @@ int main( int argc, char **argv )
is_interactive_session &= isatty(STDIN_FILENO);
is_interactive_session |= force_interactive;
+ /*
+ No-exec is prohibited when in interactive mode
+ */
+ if( is_interactive_session && no_exec)
+ {
+ debug( 1, _(L"Can not use the no-execute mode when running an interactive session") );
+ no_exec = 0;
+ }
+
common_init();
halloc_util_init();
diff --git a/parser.c b/parser.c
index 9ab8b5ca..b882c6e3 100644
--- a/parser.c
+++ b/parser.c
@@ -2521,7 +2521,7 @@ int parser_test( wchar_t * buff,
current_tokenizer = &tok;
for( tok_init( &tok, buff, 0 );
- tok_has_next( &tok ) && !err;
+ tok_has_next( &tok );
tok_next( &tok ) )
{
current_tokenizer_pos = tok_get_pos( &tok );
diff --git a/proc.c b/proc.c
index 431d8e2c..799cf2e1 100644
--- a/proc.c
+++ b/proc.c
@@ -90,6 +90,8 @@ int is_event=0;
int proc_had_barrier;
pid_t proc_last_bg_pid = 0;
int job_control_mode = JOB_CONTROL_INTERACTIVE;
+int no_exec=0;
+
/**
The event variable used to send all process event
diff --git a/proc.h b/proc.h
index 98b365b0..27496660 100644
--- a/proc.h
+++ b/proc.h
@@ -232,6 +232,12 @@ extern pid_t proc_last_bg_pid;
extern int job_control_mode;
/**
+ If this flag is set, fish will never fork or run execve.
+*/
+extern int no_exec;
+
+
+/**
Sets the status of the last process to exit
*/
void proc_set_last_status( int s );
diff --git a/share/completions/fish.fish b/share/completions/fish.fish
index 4e20d92a..5b34ac38 100644
--- a/share/completions/fish.fish
+++ b/share/completions/fish.fish
@@ -1,6 +1,7 @@
complete -c fish -s c -l "command" -d (N_ "Run fish with this command")
complete -c fish -s h -l help -d (N_ "Display help and exit")
complete -c fish -s v -l version -d (N_ "Display version and exit")
+complete -c fish -s n -l no-execute -d (N_ "Only parse input, do not execute")
complete -c fish -s i -l interactive -d (N_ "Run in interactive mode")
complete -c fish -s l -l login -d (N_ "Run in login mode")
complete -c fish -s p -l profile -d (N_ "Output profiling information to specified file") -f