If you clone a repo to a windows system and want to run shell scripts like bash
or zsh
within the Windows Subsystem for Linux
you might need to fix the end-of-line characters. This depends on if you preserve end-of-line characters based on what is in the repo or if you have your local repo auto manage that.
tr -d '\r' < a.txt > b.txt
The following example takes two scripts used in word_search_kata
that were cloned to a Windows 10 system in DOS format. Bash does not like DOS formatted files so they need converted.
- Rename the files. I like to prefix with "dos_"
- Run each file through
tr
being sure to redirect the output to a new file using hte original name (less "dos_"). - Run new bash script to ensure it behaves correctly.
mv run_all_unittests.bash dos_run_all_unittests.bash
mv run_word_search_on_all_csv_data.bash dos_run_word_search_on_all_csv_data.bash
tr -d '\r' < dos_run_all_unittests.bash > run_all_unittests.bash
./run_all_unittests.bash
tr -d '\r' < dos_run_word_search_on_all_csv_data.bash > run_word_search_on_all_csv_data.bash
./run_word_search_on_all_csv_data.bash
If you choose, you can delete "dos_" temp file once you are satisfied that the scripts run as expected.