From: Gerrit P. Haase Date: Sat, 1 Jun 2002 04:14:43 +0000 (+0200) Subject: [Patch] Inplace editing on Cygwin and others? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c030f24b810c923631239a170282534aaf44e4ba;p=p5sagit%2Fp5-mst-13.2.git [Patch] Inplace editing on Cygwin and others? From: "Gerrit P. Haase" Message-ID: <199100765833.20020601041443@familiehaase.de> p4raw-id: //depot/perl@16946 --- diff --git a/README.cygwin b/README.cygwin index c09eeab..99d0a4f 100644 --- a/README.cygwin +++ b/README.cygwin @@ -401,8 +401,9 @@ Win9x can not rename() an open file (although WinNT can). The Cygwin chroot() implementation has holes (it can not restrict file access by native Win32 programs). -Inplace editing ( perl -i ) of files doesn't work without doing a backup -of the file being edited ( perl -i.bak ). +Inplace editing C of files doesn't work without doing a backup +of the file being edited C because of windowish restrictions, +so Perl does this automagically if you just use C. =back diff --git a/doio.c b/doio.c index e209cf2..95ae169 100644 --- a/doio.c +++ b/doio.c @@ -790,7 +790,7 @@ Perl_nextargv(pTHX_ register GV *gv) #endif } else { -#if !defined(DOSISH) && !defined(AMIGAOS) && !defined(__CYGWIN__) +#if !defined(DOSISH) && !defined(AMIGAOS) # ifndef VMS /* Don't delete; use automatic file versioning */ if (UNLINK(PL_oldname) < 0) { if (ckWARN_d(WARN_INPLACE)) diff --git a/perl.c b/perl.c index 90b227e..2354ce5 100644 --- a/perl.c +++ b/perl.c @@ -2363,6 +2363,12 @@ Perl_moreswitches(pTHX_ char *s) case 'i': if (PL_inplace) Safefree(PL_inplace); +#if defined(__CYGWIN__) /* do backup extension automagically */ + if (*(s+1) == '\0') { + PL_inplace = savepv(".bak"); + return s+1; + } +#endif /* __CYGWIN__ */ PL_inplace = savepv(s+1); /*SUPPRESS 530*/ for (s = PL_inplace; *s && !isSPACE(*s); s++) ;