From 2160777d2f26a7e00c3dc003bf52bf9d40d885c7 Mon Sep 17 00:00:00 2001 From: liljencrantz Date: Sat, 27 Oct 2007 04:42:32 +1000 Subject: Implement non-clobbering file io. Use the >? operator for this for now. darcs-hash:20071026184232-75c98-11edcbc7548c8ad3a2d4b648cb7ae18067569f02.gz --- parser.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'parser.c') diff --git a/parser.c b/parser.c index a699219e..916dd79b 100644 --- a/parser.c +++ b/parser.c @@ -1462,6 +1462,7 @@ static void parse_job_argument_list( process_t *p, case TOK_REDIRECT_IN: case TOK_REDIRECT_APPEND: case TOK_REDIRECT_FD: + case TOK_REDIRECT_NOCLOB: { int type = tok_last_type( tok ); io_data_t *new_io; @@ -1557,6 +1558,12 @@ static void parse_job_argument_list( process_t *p, new_io->param1.filename = target; break; + case TOK_REDIRECT_NOCLOB: + new_io->io_mode = IO_FILE; + new_io->param2.flags = O_CREAT | O_EXCL | O_WRONLY; + new_io->param1.filename = target; + break; + case TOK_REDIRECT_IN: new_io->io_mode = IO_FILE; new_io->param2.flags = O_RDONLY; @@ -2121,6 +2128,7 @@ static int parse_job( process_t *p, break; case TOK_REDIRECT_OUT: + case TOK_REDIRECT_NOCLOB: case TOK_REDIRECT_APPEND: case TOK_REDIRECT_IN: case TOK_REDIRECT_FD: @@ -3324,6 +3332,7 @@ int parser_test( const wchar_t * buff, case TOK_REDIRECT_IN: case TOK_REDIRECT_APPEND: case TOK_REDIRECT_FD: + case TOK_REDIRECT_NOCLOB: { if( !had_cmd ) { -- cgit v1.2.3