Skip to content

Commit c030f24

Browse files
Gerrit P. Haasejhi
authored andcommitted
[Patch] Inplace editing on Cygwin and others?
From: "Gerrit P. Haase" <gp@familiehaase.de> Message-ID: <199100765833.20020601041443@familiehaase.de> p4raw-id: //depot/perl@16946
1 parent 4c7fc0a commit c030f24

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.cygwin

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,9 @@ Win9x can not rename() an open file (although WinNT can).
401401
The Cygwin chroot() implementation has holes (it can not restrict file
402402
access by native Win32 programs).
403403

404-
Inplace editing ( perl -i ) of files doesn't work without doing a backup
405-
of the file being edited ( perl -i.bak ).
404+
Inplace editing C<perl -i> of files doesn't work without doing a backup
405+
of the file being edited C<perl -i.bak> because of windowish restrictions,
406+
so Perl does this automagically if you just use C<perl -i>.
406407

407408
=back
408409

doio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ Perl_nextargv(pTHX_ register GV *gv)
790790
#endif
791791
}
792792
else {
793-
#if !defined(DOSISH) && !defined(AMIGAOS) && !defined(__CYGWIN__)
793+
#if !defined(DOSISH) && !defined(AMIGAOS)
794794
# ifndef VMS /* Don't delete; use automatic file versioning */
795795
if (UNLINK(PL_oldname) < 0) {
796796
if (ckWARN_d(WARN_INPLACE))

perl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,12 @@ Perl_moreswitches(pTHX_ char *s)
23632363
case 'i':
23642364
if (PL_inplace)
23652365
Safefree(PL_inplace);
2366+
#if defined(__CYGWIN__) /* do backup extension automagically */
2367+
if (*(s+1) == '\0') {
2368+
PL_inplace = savepv(".bak");
2369+
return s+1;
2370+
}
2371+
#endif /* __CYGWIN__ */
23662372
PL_inplace = savepv(s+1);
23672373
/*SUPPRESS 530*/
23682374
for (s = PL_inplace; *s && !isSPACE(*s); s++) ;

0 commit comments

Comments
 (0)