3

I am currently working through "Learn More Python the Hard Way" by Zed Shaw (continuation of learnpythonthehardway.org/book). In it, he creates a test .sh file that he uses throughout the series. I am on a Windows machine, and I understand bash commands are not compatible with Powershell so I'm wondering what command will allow me to run the file given that "bash" does not work.

I also understand that .sh is associated with Linux, but usually he offers up the Windows version as well, yet this time he did not give a Windows-based explanation. The course also insists on using bash, otherwise I would have simple made the file with a .ps1 extension. I have also read about utilizing Cygwin, but I feel the instructor would have instructed us to do so if necessary.

TL;DR: How does Zed Shaw intend for me to execute: bash tests/find_tests.sh When I'm on a Windows machine and there are not hints to use the .ps1 extension or Cygwin?

Jongware
  • 22,200
  • 8
  • 54
  • 100
BananaRama
  • 33
  • 1
  • 1
  • 7

2 Answers2

4

Well, it depends on what these scripts are doing.

I think that the best option for you would be to use MSYS ("Minimal SYStem"). It contains Bash.

Cygwin is awesome and I'm using it every day, but it's probably too complex for what you need. It basically gives you Linux command-line environment integrated to the Windows system. You can install various compilers, interpreters and tons of other Linux tools, compiled particularly for Cygwin and distributed in Cygwin repositories.

MSYS is a part of MinWG ("Minimalist GNU for Windows") and MinGW was originally forked from Cygwin. MSYS is just a subset of Cygwin/MinGW. I would say, that it will be easier for you to use MSYS.

Install Cygwin if you plan to learn or further play with Linux shells and command-line tools. Or if you just want to have useful command-line environment on Windows.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
1

Windows does not have the ability to run bash scripts built in by default. What you'll need to do is install Cygwin or something similar to handle execution of bash scripts.

Once you have Cygwin installed you'll have access to most unix commands, including sh.

It is a little bit of overhead to install, but if you plan on using a Windows machine to code from here on out it is highly beneficial to have.

asdf
  • 2,927
  • 2
  • 21
  • 42