This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: CR/LF problems after upgrade


On 05 January 2007 18:45, fschmidt wrote:

> from http://cygwin.com/ml/cygwin-announce/2006-12/msg00026.html
>
>> 2. d2u is your friend.  You can use it to convert any problematic script
>> into binary line endings. 
>> 
> 
> Several people I work with, who are even less technical than I am, use
> cygwin and edit scripts with various editors.  So this will not work.

  You need to use /development methodology/ to solve this problem.  Either set
their editors to use LFs, or if they like editors that cannot do CR/LFs try
and offer them as similar an editor as you can find to use that does do LFs,
or perhaps write a script for them to run that finds all the script files and
automatically d2u's them, or convert files to LFs when you check them into
version control... there are loads of possible solutions.

> I don't know what mounts are, or how to use them.

  That is entirely your own fault.  The solution to this problem is for you to
be bothered to read the documentation.  No technical means can help you if you
can't be bothered to employ it.

>> 4c. To affect all scripts, export the environment variable BASH_ENV,
>> pointing to a file that sets the shell option as desired.  Bash will
>> source this file on startup for every script.
>> 
> 
> I tried:
> 
> cd /etc
> echo '(set -o igncr) 2>/dev/null && set -o igncr; # comment is needed'
>> bash_env
> export BASH_ENV=/etc/bash_env
> 
> This did not work.

  WJFFM:  perhaps you need to "chmod x+x /etc/bash_env"?  Here's an example:

~ $ cd /tmp
/tmp $ mkdir crlf
/tmp $ cd crlf/
/tmp/crlf $ touch crlf.sh
/tmp/crlf $ write crlf.sh
/tmp/crlf $ cat crlf.sh
#!/bin/bash
echo This is a script with CRLF endings
ls
pwd
uname
id
/tmp/crlf $ u2d crlf.sh
crlf.sh: done.
/tmp/crlf $ chmod a+x crlf.sh
/tmp/crlf $ ./crlf.sh
This is a script with CRLF endings
: command not foundls
: command not foundpwd
: command not founduname
: command not foundid
/tmp/crlf $ echo '(set -o igncr) 2>/dev/null && set -o igncr; # comment is
need
ed' >> ./bash_env
/tmp/crlf $ export BASH_ENV=/tmp/crlf/bash_env
/tmp/crlf $ d2u bash_env
bash_env: done.
/tmp/crlf $ chmod a+x bash_env
/tmp/crlf $ ./crlf.sh
This is a script with CRLF endings
bash_env  crlf.sh
/tmp/crlf
CYGWIN_NT-5.1
uid=11165(dk) gid=10513(Domain Users)
groups=0(root),544(Administrators),545(Use
rs),1005(Debugger Users),11113(Artimi),10512(Domain Admins),10513(Domain
Users),
10519(Enterprise Admins),11311(Exmergers),12171(Hardware_Share)
/tmp/crlf $

>> 4d. Added in the bash-3.2-2 release: export the environment variable
>> SHELLOPTS with igncr included in it.  It is read-only from within bash,
>> but you can set it before invoking bash; once in bash, it auto-tracks the
>> current state of 'set -o igncr' or 'shopt -s igncr'.  If exported, then
>> all bash child processes inherit the same option settings.
>> 
> 
> I tried:
> 
> export SHELLOPTS=$SHELLOPTS:igncr
> 
> and got:
> 
> bash: SHELLOPTS: readonly variable

  Well duh.  What on earth did you suppose it means up there where it says "It
is read-only from within bash"?  Can you not see the words which are right in
front of your face?


>> 5. You can also experiment with the IFS variable for controlling how bash
>> will treat \r during variable expansion.
>> 
> 
> I don't know what the IFS variable is, or how to use it.

  This is actually the least useful of the suggestions and will only apply in
quite limited suggestions, so it's not worth your spending much time on.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]