mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Make sure that io redirections are respected by the '.' builtin. This was not the case earlier, which caused various bugs, especially after eval was made into a function that internally used '.'
darcs-hash:20070425183002-ac50b-d7d93e3b74e7274fe3e0aad98e95dd608bb903ae.gz
This commit is contained in:
parent
784c5d9fa3
commit
d0585befb3
6 changed files with 23 additions and 13 deletions
14
builtin.c
14
builtin.c
|
@ -137,6 +137,13 @@ static int builtin_stdin;
|
|||
*/
|
||||
static hash_table_t *desc=0;
|
||||
|
||||
/**
|
||||
The underyion IO redirections behind the current builtin. This
|
||||
should normally not be used - sb_out and friends are already
|
||||
configured to handle everything.
|
||||
*/
|
||||
static io_data_t *real_io;
|
||||
|
||||
/**
|
||||
Counts the number of non null pointers in the specified array
|
||||
*/
|
||||
|
@ -2292,7 +2299,7 @@ static int builtin_source( wchar_t ** argv )
|
|||
|
||||
parse_util_set_argv( (argc>2)?(argv+2):(argv+1), 0);
|
||||
|
||||
res = reader_read( fd );
|
||||
res = reader_read( fd, real_io );
|
||||
|
||||
parser_pop_block();
|
||||
|
||||
|
@ -2877,7 +2884,7 @@ static int builtin_breakpoint( wchar_t **argv )
|
|||
{
|
||||
parser_push_block( BREAKPOINT );
|
||||
|
||||
reader_read( 0 );
|
||||
reader_read( 0, real_io );
|
||||
|
||||
parser_pop_block();
|
||||
|
||||
|
@ -3262,9 +3269,10 @@ static int internal_help( wchar_t *cmd )
|
|||
}
|
||||
|
||||
|
||||
int builtin_run( wchar_t **argv )
|
||||
int builtin_run( wchar_t **argv, io_data_t *io )
|
||||
{
|
||||
int (*cmd)(wchar_t **argv)=0;
|
||||
real_io = io;
|
||||
|
||||
CHECK( argv, STATUS_BUILTIN_ERROR );
|
||||
CHECK( argv[0], STATUS_BUILTIN_ERROR );
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <wchar.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -131,7 +132,7 @@ int builtin_exists( wchar_t *cmd );
|
|||
|
||||
\return the exit status of the builtin command
|
||||
*/
|
||||
int builtin_run( wchar_t **argv );
|
||||
int builtin_run( wchar_t **argv, io_data_t *io );
|
||||
|
||||
/**
|
||||
Insert all builtin names into l. These are not copies of the strings and should not be freed after use.
|
||||
|
|
2
exec.c
2
exec.c
|
@ -1158,7 +1158,7 @@ void exec( job_t *j )
|
|||
|
||||
signal_unblock();
|
||||
|
||||
p->status = builtin_run( p->argv );
|
||||
p->status = builtin_run( p->argv, j->io );
|
||||
|
||||
builtin_out_redirect=old_out;
|
||||
builtin_err_redirect=old_err;
|
||||
|
|
4
main.c
4
main.c
|
@ -332,7 +332,7 @@ int main( int argc, char **argv )
|
|||
{
|
||||
if( my_optind == argc )
|
||||
{
|
||||
res = reader_read( 0 );
|
||||
res = reader_read( 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -374,7 +374,7 @@ int main( int argc, char **argv )
|
|||
free( rel_filename );
|
||||
free( abs_filename );
|
||||
|
||||
res = reader_read( fd );
|
||||
res = reader_read( fd, 0 );
|
||||
|
||||
if( res )
|
||||
{
|
||||
|
|
8
reader.c
8
reader.c
|
@ -2933,7 +2933,7 @@ wchar_t *reader_readline()
|
|||
the prompt, using syntax highlighting. This is used for reading
|
||||
scripts and init files.
|
||||
*/
|
||||
static int read_ni( int fd )
|
||||
static int read_ni( int fd, io_data_t *io )
|
||||
{
|
||||
FILE *in_stream;
|
||||
wchar_t *buff=0;
|
||||
|
@ -2996,7 +2996,7 @@ static int read_ni( int fd )
|
|||
|
||||
if( !parser_test( str, 0, &sb, L"fish" ) )
|
||||
{
|
||||
eval( str, 0, TOP );
|
||||
eval( str, io, TOP );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3035,7 +3035,7 @@ static int read_ni( int fd )
|
|||
return res;
|
||||
}
|
||||
|
||||
int reader_read( int fd )
|
||||
int reader_read( int fd, io_data_t *io )
|
||||
{
|
||||
int res;
|
||||
|
||||
|
@ -3047,7 +3047,7 @@ int reader_read( int fd )
|
|||
|
||||
proc_push_interactive( ((fd == 0) && isatty(STDIN_FILENO)));
|
||||
|
||||
res= is_interactive?read_i():read_ni( fd );
|
||||
res= is_interactive?read_i():read_ni( fd, io );
|
||||
|
||||
/*
|
||||
If the exit command was called in a script, only exit the
|
||||
|
|
3
reader.h
3
reader.h
|
@ -12,11 +12,12 @@
|
|||
#include <wchar.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "io.h"
|
||||
|
||||
/**
|
||||
Read commands from \c fd until encountering EOF
|
||||
*/
|
||||
int reader_read( int fd);
|
||||
int reader_read( int fd, io_data_t *io);
|
||||
|
||||
/**
|
||||
Tell the shell that it should exit after the currently running command finishes.
|
||||
|
|
Loading…
Reference in a new issue