Bash shell script issue

Kipton Moravec kipton_moravec@yahoo.com
Tue Sep 6 22:39:00 GMT 2016


I am relatively new to shell scripts, but this works on linux and I do not know why it does not work for me in cygwin.

I am running cygwin 32 on a 64-bit Windows 7 computer and so I do not know if that is my problem or not. I am having problems upgrading the version of CYGWIN it hangs in post install, so I decided to grab another computer and install cygwin 32 on it, and it is running Windows 10. That is the second example. 


I this is the script: 
#!/bin/bash 
echo $PWD 
project_root=$PWD 
echo $project_root 
x=${project_root}/tools 
echo $x 
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/tools^M$ 

On new Windows 10 I get: 
dalkmora@DALM0255 ~/walnut 
$ ./testconvert1.sh 
/home/dalkmora/walnut 
/home/dalkmora/walnut 
/toolsdalkmora/walnut 
/home/dalkmora/walnut^M/tools^M$

So when I type the commands on the command line it works as I think it should.


dalkmora@DALM0048 ~/walnut/dp2b_walnut_customer_flextronics/walnut 
$ project_root=$PWD 

dalkmora@DALM0048 ~/walnut/dp2b_walnut_customer_flextronics/walnut 
$ echo $project_root 
/home/dalkmora/walnut/dp2b_walnut_customer_flextronics/walnut 

dalkmora@DALM0048 ~/walnut/dp2b_walnut_customer_flextronics/walnut 
$ x=${project_root}/tools 

dalkmora@DALM0048 ~/walnut/dp2b_walnut_customer_flextronics/walnut 
$ echo $x 
/home/dalkmora/walnut/dp2b_walnut_customer_flextronics/walnut/tools 


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? 

The FAQ says you want the results of cygcheck -s -v -r > cygcheck.out
it is attached. 

Kip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 259529 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160906/e9663040/attachment.obj>
-------------- next part --------------
--
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