Implement non-clobbering file io. Use the >? operator for this for now.

darcs-hash:20071026184232-75c98-11edcbc7548c8ad3a2d4b648cb7ae18067569f02.gz
This commit is contained in:
liljencrantz
2007-10-27 04:42:32 +10:00
parent a97faaf664
commit 2160777d2f
5 changed files with 53 additions and 9 deletions

View File

@@ -757,6 +757,7 @@ void highlight_shell( wchar_t * buff,
break;
}
case TOK_REDIRECT_NOCLOB:
case TOK_REDIRECT_OUT:
case TOK_REDIRECT_IN:
case TOK_REDIRECT_APPEND:
@@ -825,7 +826,7 @@ void highlight_shell( wchar_t * buff,
if it exists.
*/
if( last_type == TOK_REDIRECT_IN ||
last_type == TOK_REDIRECT_APPEND )
last_type == TOK_REDIRECT_APPEND )
{
if( wstat( target, &buff ) == -1 )
{
@@ -834,6 +835,15 @@ void highlight_shell( wchar_t * buff,
al_push( error, wcsdupcat( L"File \'", target, L"\' does not exist" ) );
}
}
if( last_type == TOK_REDIRECT_NOCLOB )
{
if( wstat( target, &buff ) != -1 )
{
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
if( error )
al_push( error, wcsdupcat( L"File \'", target, L"\' exists" ) );
}
}
}
break;
}