Re: redirect bug

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

 



On Tue, Jun 23, 2009 at 10:06:30AM +0000, Nikola Vladov wrote:
> May be this is a bug:
> 
> echo XX > uu
> cat <> uu
> 
> dash truncates file uu.  The open flag O_TRUNC must be removed.
> I'm not 100% shure what POSIX say about: program <> file

Thank you.  I'll add this patch.

commit d4e757429c4006d7fe731c8ec7c9a3f21b2d23b5
Author: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Date:   Tue Jun 30 15:13:28 2009 +0800

    [REDIR] Do not truncate file for FROMTO redirection
    
    On Tue, Jun 23, 2009 at 10:06:30AM +0000, Nikola Vladov wrote:
    > May be this is a bug:
    >
    > echo XX > uu
    > cat <> uu
    >
    > dash truncates file uu.  The open flag O_TRUNC must be removed.
    > I'm not 100% shure what POSIX say about: program <> file
    
    Indeed, this is a bug we inherited from NetBSD.  This patch removes
    the O_TRUNC flag for FROMTO.
    
    Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

diff --git a/ChangeLog b/ChangeLog
index e6a1d26..37ea778 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-30  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
+
+	* Do not truncate file for FROMTO redirection.
+
 2009-06-27  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
 
 	* Fix quoted pattern patch breakage.
diff --git a/src/redir.c b/src/redir.c
index b01237d..54af96b 100644
--- a/src/redir.c
+++ b/src/redir.c
@@ -192,7 +192,7 @@ openredirect(union node *redir)
 		break;
 	case NFROMTO:
 		fname = redir->nfile.expfname;
-		if ((f = open64(fname, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
+		if ((f = open64(fname, O_RDWR|O_CREAT, 0666)) < 0)
 			goto ecreate;
 		break;
 	case NTO:
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux