delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/02/06/11:48:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: Benoit Rochefort <Benoit DOT Rochefort AT gerad DOT ca>
MIME-Version: 1.0
Message-ID: <15457.24107.156173.920568@montreal.crt.umontreal.ca>
Date: Wed, 6 Feb 2002 11:47:39 -0500 (EST)
To: cygwin AT cygwin DOT com
Subject: perl "-i" switch bug on cygwin
X-Mailer: VM 6.72 under 21.1 (patch 8) "Bryce Canyon" XEmacs Lucid
X-Face: C!5Mk_!qB]35}VpD|H>GN/@fk%~7:*/x8&~\]|r|)/zV?rJ){uX4Nh`a$L/z__Kx4Gt!mDU
3kZlj)F2]Ds$?l';SO9]v^|[i2nY`pZ+mu+HT%5ITkuP#e]@8F4 AT Hc.=]oN1+d\M AT Rl>-$C?h$yntf
-JVx)3L2}VzG.!bQEy]~I_3fup`HtZ^t/Iz.|Vh$~o`^g\

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019