Fix a bug where io redirection of builtins would not truncate files if the builtin did not produce any output

darcs-hash:20070324223430-ac50b-3f3d6fd35f5b82c59ecaa06b459fe2b61dc8f387.gz
This commit is contained in:
axel 2007-03-25 08:34:30 +10:00
parent e8ba091161
commit e128fa1a8e

10
exec.c
View file

@ -1317,6 +1317,8 @@ void exec( job_t *j )
( !sb_err->used ) &&
( !p->next );
int has_file_redirect = 0;
/*
If the output of a builtin is to be sent to an internal
buffer, there is no need to fork. This helps out the
@ -1337,6 +1339,14 @@ void exec( job_t *j )
free( res );
}
for( io = j->io; io; io=io->next )
{
if( io->io_mode == IO_FILE )
{
skip_fork = 0;
}
}
if( skip_fork )
{
p->completed=1;