I have Julia code that executes external commands with parameters. The parameters are file or folder names. I thought if I check if the code is executed on Windows and use a backslash as path delimiter on Windows and a slash otherwise it would work. But it does NOT work if Julia is executed in a bash shell (git bash) on Windows.
How can I determine if Julia is executed in bash, powershell or on the dos command prompt on Windows?
The command is never run with a shell. Instead, Julia parses the command syntax directly, appropriately interpolating variables and splitting on words as the shell would, respecting shell quoting syntax. The command is run as julia’s immediate child process, using fork and exec calls.
Do your paths contain spaces or maybe other problematic characters?
Remember, git-bash is running on Windows, and so your are using Windows Julia. Which bypasses the Posix-emulation library (cygwin.dll?) used by bash, and adresses Windows native API. So you get Windows path separator … because that will be what Julia will use to find the files.
If you want to use bash Unix-like file path inside Julia, you will have to split them with “/” and then join the part with the (Windows) system separator (see joinpath)
/ works just fine on Windows too as long as you use it consistently (i.e. don’t try to mix it with backslash).
@ufechner7 didn’t provide any example of the code they are trying to run, but my suspicion is that the problem is more due to incorrect argument quoting in run or something rather than simple issues with joinpath.
In any, case, @ufechner7 really should provide a MWE; it’s pointless to speculate about hypothetical bugs.