bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] in-place edit request


From: Andrew J. Schorr
Subject: Re: [bug-gawk] in-place edit request
Date: Wed, 26 Dec 2012 13:59:36 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Dec 26, 2012 at 01:47:43PM -0500, Andrew J. Schorr wrote:
> An strace of perl -p -i.bak -e 's/foo/bar/;' /tmp/testfile:
> 
> open("/tmp/testfile", O_RDONLY)         = 3
> ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
> 0x7fff783e3e28) = -1 ENOTTY (Inappropriate ioctl for device)
> lseek(3, 0, SEEK_CUR)                   = 0
> fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
> fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
> rename("/tmp/testfile", "/tmp/testfile.bak") = 0
> open("/tmp/testfile", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
> ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
> 0x7fff783e3e28) = -1 ENOTTY (Inappropriate ioctl for device)
> lseek(4, 0, SEEK_CUR)                   = 0
> fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
> fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
> fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
> fchmod(4, 0100644)                      = 0
> read(3, "is foo replaced?\n", 8192)     = 17
> read(3, "", 8192)                       = 0
> write(4, "is bar replaced?\n", 17)      = 17
> close(4)                                = 0
> close(3)                                = 0
> 
> And without a backup:
> 
> open("/tmp/testfile", O_RDONLY)         = 3
> ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
> 0x7fff05267508) = -1 ENOTTY (Inappropriate ioctl for device)
> lseek(3, 0, SEEK_CUR)                   = 0
> fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
> fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
> unlink("/tmp/testfile")                 = 0
> open("/tmp/testfile", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
> ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
> 0x7fff05267508) = -1 ENOTTY (Inappropriate ioctl for device)
> lseek(4, 0, SEEK_CUR)                   = 0
> fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
> fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
> fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
> fchmod(4, 0100644)                      = 0
> read(3, "is foo replaced?\n", 8192)     = 17
> read(3, "", 8192)                       = 0
> write(4, "is bar replaced?\n", 17)      = 17
> close(4)                                = 0
> close(3)                                = 0

For completeness, here is how sed handles it:

With a backup (sed -i.bak -e 's/foo/bar/;' /tmp/testfile):

open("/tmp/testfile", O_RDONLY)         = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
0x7fffaa73b938) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
umask(0700)                             = 022
getpid()                                = 54583
open("/tmp/sedYTcgb8", O_RDWR|O_CREAT|O_EXCL, 0600) = 4
umask(022)                              = 0700
fcntl(4, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(4, {st_mode=S_IFREG, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f04ebc26000
lseek(4, 0, SEEK_CUR)                   = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f04ebc25000
read(3, "is foo replaced?\n", 4096)     = 17
write(4, "is bar replaced?\n", 17)      = 17
read(3, "", 4096)                       = 0
fchmod(4, 0100644)                      = 0
fchown(4, 342, 50)                      = 0
close(3)                                = 0
munmap(0x7f04ebc25000, 4096)            = 0
close(4)                                = 0
munmap(0x7f04ebc26000, 4096)            = 0
rename("/tmp/testfile", "/tmp/testfile.bak") = 0
rename("/tmp/sedYTcgb8", "/tmp/testfile") = 0

Without a backup (sed -i -e 's/foo/bar/;' /tmp/testfile):

open("/tmp/testfile", O_RDONLY)         = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 
0x7fff9c178218) = -1 ENOTTY (Inappropriate ioctl for device)
fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
umask(0700)                             = 022
getpid()                                = 54580
open("/tmp/sedkyvHxa", O_RDWR|O_CREAT|O_EXCL, 0600) = 4
umask(022)                              = 0700
fcntl(4, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(4, {st_mode=S_IFREG, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f953c9dc000
lseek(4, 0, SEEK_CUR)                   = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=17, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f953c9db000
read(3, "is foo replaced?\n", 4096)     = 17
write(4, "is bar replaced?\n", 17)      = 17
read(3, "", 4096)                       = 0
fchmod(4, 0100644)                      = 0
fchown(4, 342, 50)                      = 0
close(3)                                = 0
munmap(0x7f953c9db000, 4096)            = 0
close(4)                                = 0
munmap(0x7f953c9dc000, 4096)            = 0
rename("/tmp/sedkyvHxa", "/tmp/testfile") = 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]