mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Add support for the -n switch to skip execution of any commands
darcs-hash:20060318010459-ac50b-9d9e5c489e0e4df2159d8c1d0ff952d42e2a2a82.gz
This commit is contained in:
parent
94b7c8d5e6
commit
80b4055eab
6 changed files with 34 additions and 5 deletions
7
exec.c
7
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 );
|
||||
|
||||
|
|
21
main.c
21
main.c
|
@ -138,6 +138,10 @@ int main( int argc, char **argv )
|
|||
"login", no_argument, 0, 'l'
|
||||
}
|
||||
,
|
||||
{
|
||||
"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();
|
||||
|
||||
|
|
2
parser.c
2
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 );
|
||||
|
|
2
proc.c
2
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
|
||||
|
|
6
proc.h
6
proc.h
|
@ -231,6 +231,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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue