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