*-i*[*extension*]

-i"\.sed"

but wow, nice way to destroy file.


On Mon, Apr 15, 2013 at 8:12 AM, Marc Espie <[email protected]> wrote:

> $ cat goodfilename
> coincoin
>
> $ perl -pi -e 's/toto/tutu/' goodfilename
> works
>
> $ cp goodfilename /tmp
> $ perl -pi -e 's/toto/tutu/' /tmp/goodfilename
> Can't do inplace edit on goodfilename: File exists.
> $ cat /tmp/goodfilename
> cat: /tmp/goodfilename: No such file or directory.
>
> ktrace shows a disturbing lack of Unix semantics:
>  ....
>  15350 perl     CALL  open(0x1850b9e863f0,0<O_RDONLY>)
>  15350 perl     NAMI  "goodfilename"
>  15350 perl     RET   open 3
>  ...
>  15350 perl     CALL  unlink(0x1850b9e86a00)
>  15350 perl     NAMI  "goodfilename"
>  15350 perl     RET   unlink 0
>  15350 perl     CALL
>  open(0x1850b9e868e0,0xa01<O_WRONLY|O_CREAT|O_EXCL>,0x180<S_IRUSR|S_IWUSR>)
>  15350 perl     NAMI  "goodfilename"
>  15350 perl     RET   open -1 errno 17 File exists
>
>
> err...
>
> simply put:
>
> #include <fcntl.h>
> #include <unistd.h>
> #include <stdio.h>
>
> int
> main()
> {
>         if (open("fucked_up", O_RDWR|O_CREAT|O_TRUNC, 0666) == -1)
>                 perror("open");
>         if (unlink("fucked_up") != 0)
>                 perror("unlink");
>         if (open("fucked_up", O_WRONLY|O_CREAT|O_EXCL, 0666) == -1)
>                 perror("reopen");
>         return 0;
> }
>
>


-- 
---------------------------------------------------------------------------------------------------------------------
() ascii ribbon campaign - against html e-mail
/\

Reply via email to