Skip to content

Commit

Permalink
[Patch] Inplace editing on Cygwin and others?
Browse files Browse the repository at this point in the history
From: "Gerrit P. Haase" <gp@familiehaase.de>
Message-ID: <199100765833.20020601041443@familiehaase.de>

p4raw-id: //depot/perl@16946
  • Loading branch information
Gerrit P. Haase authored and jhi committed Jun 1, 2002
1 parent 4c7fc0a commit c030f24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.cygwin
Expand Up @@ -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<perl -i> of files doesn't work without doing a backup
of the file being edited C<perl -i.bak> because of windowish restrictions,
so Perl does this automagically if you just use C<perl -i>.

=back

Expand Down
2 changes: 1 addition & 1 deletion doio.c
Expand Up @@ -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))
Expand Down
6 changes: 6 additions & 0 deletions perl.c
Expand Up @@ -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++) ;
Expand Down

0 comments on commit c030f24

Please sign in to comment.