Bash shell script issue

Michel LaBarre michel.labarre@rogers.com
Wed Sep 7 01:41:00 GMT 2016


Suggestion to Kipton: 
    od -cx <name-of-your-script> 
will show you exactly what is in your script so you can see any spurious carriage-returns or other special characters.

> -----Original Message-----
> From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On
> Behalf Of Eric Blake
> Sent: September-06-16 9:21 PM
> To: cygwin@cygwin.com; kipton_moravec@yahoo.com
> Subject: Re: Bash shell script issue
> 
> On 09/06/2016 05:36 PM, Kipton Moravec wrote:
> 
> > I this is the script:
> > #!/bin/bash
> > echo $PWD
> 
> Insufficient quoting. This does not do the right thing if $PWD contains
> spaces.  But not necessarily related to your problem at hand.
> 
> > project_root=$PWD
> > echo $project_root
> 
> Again, insufficient quoting.
> 
> > x=${project_root}/tools
> > echo $x
> 
> And again.
> 
> > echo ${x} | cat -A
> >
> > On original Windows 7 computer I get:
> > dalkmora@DALM0048
> ~/walnut/dp2b_walnut_customer_flextronics/walnut
> > $ ./testconvert1.sh
> > /home/dalkmora/walnut/dp2b_walnut_customer_flextronics/walnut
> > /home/dalkmora/walnut/dp2b_walnut_customer_flextronics/walnut
> > /toolsdalkmora/walnut/dp2b_walnut_customer_flextronics/walnut
> >
> /home/dalkmora/walnut/dp2b_walnut_customer_flextronics/walnut^M/to
> ols^M$
> 
> The carriage returns are likely a product of you editing the file in
> text mode (Windows notepad is notorious for this, but many other native
> programs do likewise), but trying to execute the script in binary mode
> (the default, if you do not use 'set -o igncr').
> 
> 
> > What am I doing wrong or is this an error?
> > Where do the carriage returns (^M) come from, and how do I get rid of
> them?
> 
> d2u /path/to/your/script
> 
> to remove all the carriage returns from your careless editing. Once they
> are gone, then you don't need the 'igncr' crutch to tell bash to go into
> text mode.
> 
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org



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



More information about the Cygwin mailing list