Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Should -i eat my files?

0 views
Skip to first unread message

Johannes Fürnkranz

unread,
Oct 10, 2002, 12:05:01 PM10/10/02
to
$ perl -v

This is perl, v5.6.1 built for cygwin-multi

$ ls -l
total 4
-rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 a
-rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 b
-rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 c
-rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 d

$ perl -i -pe 's/x/y/g' *
Can't do inplace edit on a: Permission denied.
Can't do inplace edit on b: Permission denied.
Can't do inplace edit on c: Permission denied.
Can't do inplace edit on d: Permission denied.

$ ls -l
total 0

Is this normal?

(it works fine if I do -i.bak, but real men don't need backups, right? :-) )

Juffi

John W. Krahn

unread,
Oct 10, 2002, 7:02:16 PM10/10/02
to
Johannes Fürnkranz wrote:
>
> $ perl -v
>
> This is perl, v5.6.1 built for cygwin-multi
^^^^^^^^^^^^
^^^^^^^^^^^^

> $ ls -l
> total 4
> -rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 a
> -rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 b
> -rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 c
> -rw-r--r-- 1 juffi Kein 1 Oct 10 18:01 d
>
> $ perl -i -pe 's/x/y/g' *
> Can't do inplace edit on a: Permission denied.
> Can't do inplace edit on b: Permission denied.
> Can't do inplace edit on c: Permission denied.
> Can't do inplace edit on d: Permission denied.
>
> $ ls -l
> total 0
>
> Is this normal?
>
> (it works fine if I do -i.bak, but real men don't need backups, right? :-) )

perldoc perldiag
[snip]
Can't do inplace edit on %s: %s
(S inplace) The creation of the new file failed for
the indicated reason.

Can't do inplace edit without backup
(F) You're on a system such as MS-DOS that gets con­
fused if you try reading from a deleted (but still
opened) file. You have to say `-i.bak', or some such.

John
--
use Perl;
program
fulfillment

Johannes Fürnkranz

unread,
Oct 11, 2002, 4:12:13 AM10/11/02
to
John W. Krahn wrote:
>
> perldoc perldiag
> [snip]
> Can't do inplace edit on %s: %s
> (S inplace) The creation of the new file failed for
> the indicated reason.
>
> Can't do inplace edit without backup
> (F) You're on a system such as MS-DOS that gets con­
> fused if you try reading from a deleted (but still
> opened) file. You have to say `-i.bak', or some such.

Thanks, I did not know that.

But even if I had known it, I would have assumed that -i simply does not
work on Windows systems. This gives absolutely no indication that it
will delete my files! Shouldn't there at least a big warning somewhere,
or better, an implementation that refuses to use -i on an OS where it can't?

Juffi

Tad McClellan

unread,
Oct 11, 2002, 9:55:18 AM10/11/02
to
Johannes Fürnkranz <johannes....@t-online.de> wrote:
> John W. Krahn wrote:
>>
>> perldoc perldiag
>> [snip]

>> Can't do inplace edit without backup


>> (F) You're on a system such as MS-DOS that gets con­
>> fused if you try reading from a deleted (but still
>> opened) file. You have to say `-i.bak', or some such.
>
> Thanks, I did not know that.
>
> But even if I had known it, I would have assumed that -i simply does not
> work on Windows systems. This gives absolutely no indication that it
> will delete my files! Shouldn't there at least a big warning somewhere,
> or better, an implementation that refuses to use -i on an OS where it can't?


So you want to retract that "but real men don't need backups" now?

:-)

When you decided to use "bare" -i, you knew you were entering
dangerous territory. You went anyway.

But a warning wouldn't hurt either.


--
Tad McClellan SGML consulting
ta...@augustmail.com Perl programming
Fort Worth, Texas

ctc...@hotmail.com

unread,
Oct 11, 2002, 11:30:53 AM10/11/02
to
"John W. Krahn" <kra...@acm.org> wrote:
>
> Can't do inplace edit without backup
> (F) You're on a system such as MS-DOS that gets con­
> fused if you try reading from a deleted (but still
> opened) file. You have to say `-i.bak', or some such.

It sounded like his problem is that he didn't get this message,
when he should of, rather it just went ahead and munged his files.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service

Johannes Fürnkranz

unread,
Oct 12, 2002, 4:13:54 AM10/12/02
to
Tad McClellan wrote:

> Johannes Fürnkranz <johannes....@t-online.de> wrote:
>
> So you want to retract that "but real men don't need backups" now?
>
> :-)

Sure.
[ For what it's worth: I did have a backup. :-) ]

> When you decided to use "bare" -i, you knew you were entering
> dangerous territory. You went anyway.

Well, I thought it was dangerous because I had no possibility of undoing
whatever changes to a file I make, not because it will kill my files.

When you use the -i switch on Linux on a regular basis, and know how to
handle it with care, you'd be *very* surprised if you try it on cygwin,
do whatever you did under Linux and suddenly your files are gone.

Juffi


Johannes Fürnkranz

unread,
Oct 12, 2002, 4:20:05 AM10/12/02
to
ctc...@hotmail.com wrote:
> "John W. Krahn" <kra...@acm.org> wrote:
>
>> Can't do inplace edit without backup
>> (F) You're on a system such as MS-DOS that gets con?

>> fused if you try reading from a deleted (but still
>> opened) file. You have to say `-i.bak', or some such.
>
>
> It sounded like his problem is that he didn't get this message,
> when he should of, rather it just went ahead and munged his files.

Are you trying to tell me that when I am used to perl under Linux, I
should first re-read the entire documentation before I even try to type
a simple command-line substitution under a different operating system?

Perl is known to be a very safe, stable and portable system, at least it
has always been good to me. So I expect whatever works under Linux, will
most likely work under other operating systems, and if it doesn't that
it will certainly not flush my files, but give me a decent error message
that says -i doesn't work here.

Juffi

0 new messages