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,TVD_RCVD_IP
	autolearn=ham autolearn_force=no version=3.4.1
Date: Mon, 25 Apr 2016 10:25:19 -0700 (PDT)
From: "Peter A. Castro" <doctor@fruitbat.org>
To: m0viefreak <m0viefreak.cm@googlemail.com>
cc: zsh-workers@zsh.org
Subject: Re: Possible ZSH bug with IO direction
In-Reply-To: <571D3938.20905@googlemail.com>
Message-ID: <alpine.LNX.2.00.1604251017100.6490@ming.fruitbat.org>
References: <571BBF3C.50402@matrix.ai> <160423151436.ZM6912@torch.brasslantern.com> <20160424131748.441d605f@pwslap01u.europe.root.pri> <160424113644.ZM3576@torch.brasslantern.com> <20160424200132.7d0d00bc@ntlworld.com> <571D3938.20905@googlemail.com>
User-Agent: Alpine 2.00 (LNX 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Seq: zsh-workers 38338

On Sun, 24 Apr 2016, m0viefreak wrote:

> Date: Sun, 24 Apr 2016 23:23:04 +0200
> From: m0viefreak <m0viefreak.cm@googlemail.com>
> To: zsh-workers@zsh.org
> Subject: Re: Possible ZSH bug with IO direction

Greetings, m0viefreak (great name, btw).

> On 24.04.2016 21:01, Peter Stephenson wrote:
>> On Sun, 24 Apr 2016 11:36:44 -0700
>> Bart Schaefer <schaefer@brasslantern.com> wrote:
>>> On Apr 24,  1:17pm, Peter Stephenson wrote:
>>> }
>>> } Mounting the filesystem within Cygwin as binary works here.
>>>
>>> Really?  That contradicts what the main.c comment asserts.
>>
>> So it seems like "binary" isn't quite what it's cracked up to be.
>>
>> The alternative might be to do something similar in the lower levels of
>> zsh, i.e. map \r\n to \n when reading shell input.  If done in input.c
>> it's no worse than doing it in the OS abstraction, and doesn't affect
>> fd's used by othe programmes.
>
> I think the cygwin_premain0 in main.c is very dangerous.
>
> In fact, bash had the same problem years ago and the hook was removed.
> See http://cygwin.com/ml/cygwin/2006-10/msg00989.html for details.

The hook was removed and replaced with an external control: igncr

This control either must be set via envvar SHELLOPTS before starting bash, 
or the script must set it explicitly at the top of any script being 
run/sourced.  Not a very transparent or convenient fix in my opinion.

> Another example I found:
>
> $ zcat < mc.1.gz > /dev/null
> gzip: stdin: invalid compressed data--crc error
> gzip: stdin: invalid compressed data--length error
>
> zcat is forced to use O_TEXT and fails to decompress the file whil using
> $ zcat mc.1.gz'
> directy works just fine.
>
> IMHO cygwin_premain0 should be removed completely. As a result,of
> course, scripts created in windows editors such as notepad, that contain
> CRLF line endings, could lead to syntax errors, but surely that's less
> of a problem and easily fixable using a proper editor.

You might think it would be, but I've had people complain about it, hence 
the hook I introduced.  You wouldn't believe the tongue-lashing I received 
for suggesting people use "binary" mode mounts and just run dos2unix on 
*all* of their scripts (and input files).  Oh yes, "less of a problem" 
indeed.  :-/

-- 
--=> Peter A. Castro
Email: doctor at fruitbat dot org / Peter dot Castro at oracle dot com
 	"Cats are just autistic Dogs" -- Dr. Tony Attwood

