Windows 10 symbolic link: bash vs cmd

I have a single bash script that I use to launch many programs. I called this script launcher.shTo use it, I create a symbolic link named myprog pointing to launcher.sh.

While in BASH shell (MSYS2/MINGW64)
inside launcher.sh, I determine the name of the "script itself" and I get "myprog" and, so, I can proceed accordingly.

While in CMD shell
inside launcher.sh, I determine the name of the "script itself" and I get "launcher" and, so, I don't know what program I am supposed to launch.

Is there a solution to this problem?

1 Answer

I tested this using normal .bat files it works fine, and running WSL bash on .sh files works fine, but launching the file using git-bash did not work. So, I think the answer is to use either .bat or WSL for .sh in Windows. To test I used test.bat with echo %0 and test.sh with echo $0, and then created symlinks with mklink, and checked the responses when calling the scripts directly and with the symlinks. I did not test hard links or junctions.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like