diff options
author | Ron Yorston <rmy@pobox.com> | 2015-05-28 12:52:36 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-05-28 12:52:36 +0100 |
commit | 6fb17897d620572290b1f604430c06c261145aad (patch) | |
tree | baae7370671ff5a8247bd31b2c15ddc0ca36c0c6 | |
parent | 316ecf214a051121516730f794721f5e7b3036ac (diff) | |
download | busybox-w32-6fb17897d620572290b1f604430c06c261145aad.tar.gz busybox-w32-6fb17897d620572290b1f604430c06c261145aad.tar.bz2 busybox-w32-6fb17897d620572290b1f604430c06c261145aad.zip |
ash: seek to EOF when file is opened for append
This shouldn't be necessary but without it the offset becomes
zero when an external command is run.
rm -f log
echo 1234567890 >>log
cmd /c echo hi >>log
echo 1234567890 >>log
Before this change log would contain:
hi
567890
1234567890
-rw-r--r-- | shell/ash.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 578904478..34d5af446 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -5455,6 +5455,9 @@ openredirect(union node *redir) | |||
5455 | f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666); | 5455 | f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666); |
5456 | if (f < 0) | 5456 | if (f < 0) |
5457 | goto ecreate; | 5457 | goto ecreate; |
5458 | #if ENABLE_PLATFORM_MINGW32 | ||
5459 | lseek(f, 0, SEEK_END); | ||
5460 | #endif | ||
5458 | break; | 5461 | break; |
5459 | default: | 5462 | default: |
5460 | #if DEBUG | 5463 | #if DEBUG |