perl "-i" switch bug on cygwin

Benoit Rochefort Benoit.Rochefort@gerad.ca
Wed Feb 6 08:47:00 GMT 2002


Hi!

It seems there is a bug on the "-i" switch for perl.
I do not know if it's a perl issue or cygwin issue so I post it here for
first; let me know please if it would be better to send a bug report to
perl mainteners instead.

Here is a small example:

###############################################################################
gcm [0][GEN13]~>mkdir tmp
gcm [0][GEN13]~>cd tmp
/home/benoitr/tmp
gcm [0][GEN13]~/tmp>echo hello > hello
gcm [0][GEN13]~/tmp>ls -al
total 5
drwxr-xr-x    2 benoitr  None            0 Feb  6 11:35 ./
drwxr-xr-x    5 benoitr  None         4096 Feb  6 11:34 ../
-rw-r--r--    1 benoitr  None            6 Feb  6 11:35 hello
gcm [0][GEN13]~/tmp>perl -p -i -e 1 hello
Can't do inplace edit on hello: Permission denied.
gcm [0][GEN13]~/tmp>ls -al
total 4
drwxr-xr-x    2 benoitr  None            0 Feb  6 11:35 ./
drwxr-xr-x    5 benoitr  None         4096 Feb  6 11:34 ../
gcm [0][GEN13]~/tmp>echo hello > hello
gcm [0][GEN13]~/tmp>perl -p -i~ -e 1 hello
gcm [0][GEN13]~/tmp>ls -al
total 6
drwxr-xr-x    2 benoitr  None            0 Feb  6 11:35 ./
drwxr-xr-x    5 benoitr  None         4096 Feb  6 11:34 ../
-rw-r--r--    1 benoitr  None            6 Feb  6 11:35 hello
-rw-r--r--    1 benoitr  None            6 Feb  6 11:35 hello~
###############################################################################

As you can see, the "-i" switch works well with an argument but not at all
with no arguments, which is really inconvenient for me since I have a bunch
of scripts written on UNIX system that rely on this capability (for
substituting texts inplace on a collection of files in conjunction with
find and xargs for example).

I remember that I had this problem one year ago (on cygwin with a modified
version of perl since perl was not on the cygwin standard package at this
time) and fixes it by using the arg form of the -i switch, followed by a rm
of the moved file.

The "man perlrun" page well describe the desired behavior of the "-i"
switch with an argument (in fact, the code that "should" be executed) but
not at all the "no arg" form of the "-i" switch. I suppose it should only
"unlink" the moved file (but is this the way it is done; i.e. moving the
original file with a name not already used in the same directory?).

Oh! Please don't send a workaround, just tell me if it's really a bug or my
misunderstanding of something and what should I do exactly to forward my
observations so that perl/cygwin can be corrected accordingly to the doc.

As a sugar, if the "-i" switch doc in the man page could exactly describe
the behavior when no arg is given, that would be for sure an enhancement.

Ben

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list