diff options
author | 2007-10-27 04:42:32 +1000 | |
---|---|---|
committer | 2007-10-27 04:42:32 +1000 | |
commit | 2160777d2f26a7e00c3dc003bf52bf9d40d885c7 (patch) | |
tree | 635d559912cba3dec7f00dd7e0e364e54300df79 /highlight.c | |
parent | a97faaf664264a356e592118ec99cc26ce4c0e47 (diff) |
Implement non-clobbering file io. Use the >? operator for this for now.
darcs-hash:20071026184232-75c98-11edcbc7548c8ad3a2d4b648cb7ae18067569f02.gz
Diffstat (limited to 'highlight.c')
-rw-r--r-- | highlight.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/highlight.c b/highlight.c index 603d75b9..8a5f7512 100644 --- a/highlight.c +++ b/highlight.c @@ -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; } |