Cygwin upgrade

We have an old version of Cygwin 1.2.x. I downloaded newer version of Cygwin and installed. Package manager was little bit tricky. By default, it didn’t download all plugins. Especially, at first, it was even missing “mintty.exe”, which allows Cygwin to open a terminal window. Also, after executed “mkpasswd -l > /etc/passwd” command, it didn’t generate the my account folder under Cygwin home. Eventually, I re-install older version of Cygwin and everything worked fine under the old version of Cygwin. After I went through old version uninstallation and re-installation of new version by manually checking “mintty, it started to show the terminal console.

There was another issue after that. New Cygwin complained about ‘\r’ character from the existing Shell Scripts. I looked at Cygwin help page and found out that it was due to DOS vs. Unix file type difference. All existing Shell scripts have ‘\r’ character at the end of line.

tr -d ‘\r’ < existing_script_file > new_script_file

Another issue was that these scripts are scattered in different file locations. They are more than 50, but less than 100. I don’t want to navigate to each folder and execute the script. I had to write a script to loop through files and remove ‘\r’. I haven’t officially studied Shell script previously, so it was extra challenge for me. Eventually, I got it working with below script.

# Shell to read source file and remove ‘\r’ character from sh script
# First thing that you want to do is convert .bash_profile by executing below command manually in Cygwin
# tr -d ‘\r’ < .bash_profile > .bash_profile_unix
# mv .bash_profile_unix .bash_profile
# Place to C:\Deployed folder and C:\DevApps\cygwin\home\$User folder
# Make sure all the files are writable.


cd $file_dir
for fn in *.sh
echo $fn
tr -d ‘\r’ < $fn > $fn””$str
mv $fn””$str $fn

Cygwin 1.7.5

If I save above script as, then I can execute the script as below.

$ bash


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s