delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/10/13/11:32:39

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Matthew Woehlke <mwoehlke AT tibco DOT com>
Subject: Re: shopt igncr not working
Date: Fri, 13 Oct 2006 10:31:24 -0500
Lines: 106
Message-ID: <egobgc$c0q$1@sea.gmane.org>
References: <1160655422743 DOT antti DOT nospam DOT 1605718 DOT wGO_WJ9D1NlId3tB-z6Qig AT luukku DOT com> <20061012123406 DOT GA30908 AT trixie DOT casa DOT cgf DOT cx> <452EA386 DOT 9010201 AT qualcomm DOT com> <egmbf1$9v6$1 AT sea DOT gmane DOT org> <452F1F4A DOT 2050705 AT qualcomm DOT com>
Mime-Version: 1.0
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0
In-Reply-To: <452F1F4A.2050705@qualcomm.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Rob Walker wrote:
> Matthew Woehlke wrote:
>> Rob Walker wrote:
>>> Saying cygwin's bash wasn't designed to handle CRLF is a lot like 
>>> saying that cygwin's bash (as previously released all these years) 
>>> wasn't designed to work with the rest of Windows.  This might 
>>> actually be the case, but I don't understand the point.  If you don't 
>>> want to work with Windows, why release for Windows?
>>>
>>> Many, many other cross-platform products make allowances for CRLF 
>>> (version control systems are a prime example) to maximize 
>>> compatibility, and thereby their usefulness, on Windows.  Cygwin's 
>>> recent changes (with make and bash) here has put a real crimp in my 
>>> plans to depend on cygwin for a portable build environment.
>>>
>>> Just curious, is there a goal or strategy that drives changes like this?
>>
>> Speed?
>
> I was actually asking a larger question.  There's obviously value in 
> handling CRLF invisibly, and value in having speed.  When evaluating 
> which is _more_ valuable, what are the inputs?

Clearly speed is valued over making CRLF work in binmode mounts, which 
was never supposed to be the case in the first place.

> But seriously, dude.  If handling CRLF starts to approach in complexity 
> what the rest of bash does, CRLF handling should probably be rewritten.

I believe that's what igncr *does*. IOW you already got this wish.

>> I think using 'igncr' should satisfy your complaints. If it doesn't, 
>> you need to tell use WHY (which, you'll notice, the OP failed to do).
> So far, igncr hasn't worked for me either.  I think this is because I 
> don't know how to use it.
> 
> This is the simple shell script I'd like to have work (lines separated 
> by CRLF):
> 
>   #!/bin/bash
>   echo helloworld
> 
> I have c:/tmp mounted at /tmp, where I put my test script (called 
> helloworld.sh):
> 
>   rwalker AT maiden> pwd
>   /tmp
>   rwalker AT maiden> mount
>   C:\Documents and Settings on /home type system (binmode)
>   C:\apps\cygwin\bin on /usr/bin type system (binmode)
>   C:\apps\cygwin\lib on /usr/lib type system (binmode)
>   C:\apps\cygwin on / type system (binmode)
>   C:\tmp on /tmp type system (binmode)
>   A: on /a type system (binmode)
>   C: on /c type system (binmode)
>   D: on /d type system (binmode)
> 
> When I run this script, this is what I see (when run from the "Cygwin 
> Bash Shell" DOS box):
> 
>   rwalker AT maiden> bash --version
>   GNU bash, version 3.1.17(9)-release (i686-pc-cygwin)
>   Copyright (C) 2005 Free Software Foundation, Inc.
>   rwalker AT maiden> ./helloworld.sh
>   hello world
>   : command not foundne 3:

Ok, no surprises.

> I also tried this way:
> 
>   rwalker AT maiden> bash -O igncr
>   rwalker AT maiden> ./helloworld.sh
>   hello world
>   : command not foundne 3:

This won't work; shopts are not inherited. You'll need to set it on 
environment startup if you're going with this approach (check the 
archives for how).

> I also tried editing the script (which I fear breaks it for non 3.x 
> users of bash):
> 
>   #!/bin/bash -O igncr
>   echo helloworld

Is there any chance 'which bash' is not /bin/bash or /usr/bin/bash? 
Otherwise this seems strange, but not being a shebang guru I cannot 
think of why it shouldn't work.

Did you try adding 'shopt igncr' to the script? This won't (shouldn't, 
at least!) break it for non-3.1-9 users (and if you stick a 2>/dev/null 
after it, won't print errors).

> What does work for me is:
> 
>   rwalker AT maiden> bash -O igncr ./helloworld.sh
>   hello world

Yup, that ought to work... Obviously it's not the best solution, though.

-- 
Matthew
"What's Cygwin?" you ask.
'Tis mostly absurd software
Concerning hippos.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019