www.delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Date: | Wed, 14 Feb 2007 21:45:10 +0200 |
Message-Id: | <200702141945.l1EJjA2S024281@beta.mvs.co.il> |
From: | "Ehud Karni" <ehud AT unix DOT mvs DOT co DOT il> |
To: | eric_backus AT alum DOT mit DOT edu |
Cc: | cygwin AT cygwin DOT com |
Subject: | Re: Unable to run even simple batch scripts any more |
In-reply-to: | <loom.20070213T010200-940@post.gmane.org> (message from Eric Backus on Tue, 13 Feb 2007 00:56:24 +0000 (UTC)) |
Reply-to: | ehud AT unix DOT mvs DOT co DOT il |
References: | <021b01c74ef4$b38a71d0$8532a8c0 AT M6> <eqqqiq$65c$1 AT sea DOT gmane DOT org> <loom DOT 20070213T010200-940 AT post DOT gmane DOT org> |
X-Mailer: | Emacs 21.3.1 rmail (send-msg 1.108) |
MIME-Version: | 1.0 |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
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 |
On Tue, 13 Feb 2007 00:56:24 Eric Backus wrote: > > Obviously, the horse is still alive and attempting to limp along. I predict > it'll stay alive for quite some time longer. > [snip] > > * Workaround inserting "set -o igncr" is impractical when there are lots of > scripts. [snip] Among my many scripts, there are some with DOS (i.e. CR LF) ending that I prefer to leave as is (mostly to be able to edit them with notpad). I wrote a little script that can fix bash scripts with CRs by adding the required "set -o igncr" line. Notes: 1. You can, of course, replace the `awk' with a simple `d2u' if you don't need the CRs at all. 2. Change the `grep' arguments (mostly the "-r" and the files list) to suit your needs. 3. This script will fail on a file with ":" in its name (which can occur only on manged mounts, because of the OS limitations) Ehud. -------------------- cut here -------------------- #! /bin/bash -ex chk_it () { while read HEAD do echo " Checking $HEAD" # show some progress case "$HEAD" in *":1:#"*"^M" ) # ONLY (ba)sh files with CR ending SNM=`echo "$HEAD" | cut "-d:" -f1` # extract script name echo "Fixing $SNM ++++++++++++++++++++" cp -p "$SNM" "$SNM"-new # copy with permissions awk ' BEGIN { IA = 0 } $0 ~ /^[ ]*#/ { print $0 ; next } { if ( IA == 0 ) { print "set -o igncr #\r" ; IA = 1 ; } print $0 ; } ' < "$SNM" > "$SNM"-new # add "set -o igncr" after initial comments mv "$SNM" "$SNM"-old # save old script mv "$SNM"-new "$SNM" # rename new to current esac done } # ---------------------------------------------------------------------- grep -E -H -I -m 1 -n -U -r -e '^#![ ]*/bin/(ba)?sh' * \ | cat -v | chk_it # check & replace CR scripts ##################### end of fix-cr.sh script #################### -- Ehud Karni Tel: +972-3-7966-561 /"\ Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D <http://www.keyserver.net/> Better Safe Than Sorry -- 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |