If you don't mind always including .sh in the script file name, you can keep the same script for Cygwin and Unix (Macbook).
To illustrate:
1. Always point .sh to your script file name, for example, test1.sh
2. test1.sh is as follows:
#!/bin/bash echo '$0 = ' $0 echo '$1 = ' $1 filepath=$1 > 3. Windows Cygwin "test1.sh"
4. Unix "test1.sh"
Note. On Windows, you need to use the file explorer to do the following:
1. Open the file explorer
2. Right-click the file with the extension .sh, for example test1.sh
3. Open with ... → Select sh.exe
After that, your Windows 10 remembers the execution of all .sh files using sh.exe.
Note. Using this method, you do not need to add the script file name in bash to run
david m lee Dec 19 '15 at 20:08 2015-12-19 20:08
source share