bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] in-place edit request


From: Andrew J. Schorr
Subject: Re: [bug-gawk] in-place edit request
Date: Wed, 26 Dec 2012 15:51:18 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Dec 26, 2012 at 10:22:27PM +0200, Aharon Robbins wrote:
> Files that start with minus is not an issue.  It's no different than
> passing filenames that start with minus straight to gawk.

I believe "mv" may get confused by filenames starting with "-".  For example:

bash-4.1$ echo hello > -foobar
bash-4.1$ mv -foobar junk
mv: invalid option -- 'o'
Try `mv --help' for more information.

Using the rename system call avoids this problem.

> Here's a cute question for you though. What about if the input filename
> is "-" or "/dev/stdin" ?  Yet Another Special Case.

I would probably just run "stat" on the FILENAME and make sure it exists
and it's a regular file by testing S_ISREG(st_mode).  Is that safe enough?

If that doesn't do the trick, one could get devious and register an input
parser so that can_take_file will be called and can test the awk_input
"struct stat sbuf" vs. the results of stat(FILENAME).  It would always
return FALSE, but store info on whether to process the file.  I hope that
won't be necessary. :-)

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]