[PATCH] ash: <> redir should not truncate

Andreas Bühmann buehmann at users.berlios.de
Wed Jun 23 12:35:00 UTC 2010


Hi,

I believe the redirection operator <> in ash misbehaves: It must not
truncate
the opened file. (Debian's dash seems to have the same bug; bash, zsh,
and ksh
work fine on a script like this: "echo foo > tmp; cat 0<> tmp".)

Regards,

Andreas

---
 shell/ash.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index f581b5b..1f8f90a 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4938,7 +4938,7 @@ openredirect(union node *redir)
         break;
     case NFROMTO:
         fname = redir->nfile.expfname;
-        f = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
+        f = open(fname, O_RDWR|O_CREAT, 0666);
         if (f < 0)
             goto ecreate;
         break;
-- 
1.7.0.4



More information about the busybox mailing list