But, when I want to run a script in a directory, something like
run(`./bootstrap`)
or
run(`.\\bootstrap`)
where either one of those works calling it in a cmd or powershell window. I get
ERROR: LoadError: could not spawn `./bootstrap`: no such file or directory (ENOENT)
or (respectively)
ERROR: LoadError: could not spawn `'.\bootstrap'`: no such file or directory (ENOENT)
The latter error presents another problem (because quoting the command won’t run the command). It still shouldn’t fail, however, because running that single-quoted string in powershell returns the quoted string back to you:
> '.\bootstrap'
.\bootstrap
So, what am I doing wrong here? FYI, it works perfectly on linux.
libuv is not capable of spawning batch files directly.
The quoting of commands in printing isn’t done in a way that is appropriate for windows cmd. That could be fixed, though cmd’s quoting rules are very complicated and it may be better to avoid it entirely.
On the other hand, if people want to treat Julia as a scripting language, the Cmd functions should work cross-platform without extra code. Julia should make jump through this kind of hoop instead of the programmer. I know that’s probably asking a lot (I’ve seen a little of the discussion around this on the issue tracker), but from a user’s perspective, that’s basic scripting functionality.
OK, seems like you want something to work for Windows and Linux (without using if is_windows() or similar).
Not sure if this is currently possible since Windows will require file extensions for .bat and .cmd files, and these are unlikely to be names on Linux.
Note that run(`.\\program.[exe|com|bat|cmd]`) will work on Windows.
Also if you already have a string cmdname appropriate for the OS, then the following should work for both Windows and Linux: