Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version;
        bh=o5KSM5iHo3JtnU8rzt7IaiaVsAHlZ0gdcl5AWL6XUF4=;
        b=eE/zVqFc90LOAUcDVrD5LCFOBKR+uSK0e1M8sBakHC+cypuAybo+FfB/cYK4W3UCZK
         cvU21oZAEzBVFk/8+7frRmTadcAdqjULJBUYp2X3Te1nqcYA12RaROlHIXqKPdD0y+X8
         9zAKvB2XsyCSBe+XM2ckjc4o8VlvvapQn1Qlilb9yYBasPXdrziOUm2AZQoX//FNJm1V
         2QBN/EGAdN8VOFbcHxaZ8ri2l5b1bCeAqNd+KTjXxsdUy9ziPZ1kFiYS6KiHqwyK/fp0
         s2mnKmiP0UAZZ4mZL6jztMHqchvlZVDJe0cbN5yGZ15GdVORTLddyU44iSccyTMFIwJf
         23Rg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version;
        bh=o5KSM5iHo3JtnU8rzt7IaiaVsAHlZ0gdcl5AWL6XUF4=;
        b=fOvb1KcntLprDurF+WR0Lktzc+PO4tM24Q9gXmwtPo4ZNbL11OyflWUtuj7ui6AcE6
         j2InEHDDnk12hJwBrj7O9owSzvOgfUbCK1WLYgjXNSkMolDL/sWgJtIOTducu99lRWwE
         Wh9ofA8kvFlPTmLHdwzEhi0jHziIhY8IRDB/1AL+RywKq5GjhKkfj4cq9LxANZLngXlW
         Cx6DwQBuHFHVpLe7SnievNZnGZWSZsgOxa10sfWz00mLs+qgw1jWunfGMAA71HCEcc18
         B+Ty2pf3WT9Bv7NXluWAWQyYata5Yj38qYQLAu2KrYHeQ0AiZHke3iJOVE6NRXpJBpNi
         LGpQ==
X-Gm-Message-State: AOPr4FUk4tlapo+9v9sS3NUJ53clrEMs7ZMbxYzjDG81dcGUJykkwkftr/aQ1dnGzWOahw==
X-Received: by 10.66.189.166 with SMTP id gj6mr43386271pac.158.1461522937864;
        Sun, 24 Apr 2016 11:35:37 -0700 (PDT)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160424113558.ZM3564@torch.brasslantern.com>
Date: Sun, 24 Apr 2016 11:35:58 -0700
In-Reply-To: <571CFD70.7090506@matrix.ai>
Comments: In reply to Roger Qiu <roger.qiu@matrix.ai>
        "Re: Possible ZSH bug with IO direction" (Apr 25,  3:08am)
References: <571BBF3C.50402@matrix.ai> 
	<160423151436.ZM6912@torch.brasslantern.com> 
	<571CFD70.7090506@matrix.ai>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: Possible ZSH bug with IO direction
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 38327

On Apr 25,  3:08am, Roger Qiu wrote:
} Subject: Re: Possible ZSH bug with IO direction
}
} Thanks, the workaround did work. But I've never seen read & write 
} redirection at the interactive prompt. Does that make the STDIN for the 
} program I'm running readable and writable?

Yes.

} How does that work?

Stdin/out/err are just file descriptors 0/1/2.  They can be open in
whatever mode the parent process likes.  It wouldn't make much sense
to have stdin open for write only, but nothing prevents that.

Consider that /dev/tty is all of stdin/out/err for most interactive
programs.  It's open read/write even though programs don't usually treat
the individual descriptors that way.

} Can the program then rewind that descriptor, and write to `input.jpg`?

If the program were using system-call interfaces on descriptor 0, yes.
However the STDIO library object STDIN will still be initialized for
reading only, so in most cases the program won't notice.

} Also since Bash doesn't suffer from this problem, will this be fixed 
} eventually?

As the comment from main.c explains, it's a question of either breaking
a few external programs that care about raw file data, or breaking the
entire internal string-processing in e.g. zsh's parameter substitution
any time those strings are read from a file.  So I would expect the
answer is that this won't change unless Cygwin changes something.  Also,
we're woefully short on any volunteers for Windows-specific issues.

