igor-petruk / scriptisto

A language-agnostic "shebang interpreter" that enables you to write scripts in compiled languages.
Apache License 2.0
909 stars 25 forks source link

Cannot run scripts anymore after PATH search change #29

Closed AndiDog closed 3 years ago

AndiDog commented 3 years ago

Expected Behavior

$ scriptisto new rust >bin/foo.rs
$ chmod +x bin/foo.rs
$ ./bin/foo.rs
Hello, Rust! Command line options: Opt { input: None }
$ bin/foo.rs
Hello, Rust! Command line options: Opt { input: None }

(contrived output ā€“ both cases, with and without ./ prefix, must be fixed)

Actual Behavior

$ scriptisto --version # built from Git
scriptisto 0.6.14-alpha.0
$ scriptisto new rust >bin/foo.rs
$ chmod +x bin/foo.rs
$ ./bin/foo.rs
Error: ErrorMessage { msg: "\"./bin/foo.rs\" is not found or not executable" }
$ bin/foo.rs
Error: ErrorMessage { msg: "\"bin/foo.rs\" is not found or not executable" }

The fix for #26 has introduced this bug since bin/foo.rs isn't on the PATH. Searching the PATH doesn't solve the use cases. The first command line argument is a file path, potentially containing slashes, and not a name of an executable (which can never contain slashes). One could check it with Path::new("bin/foo.rs").exists(), if needed by the code to distinguish from subcommands.

Specifications

Workaround

Had to revert to 0.6.10 to at least get the ./some-script syntax to work correctly.

igor-petruk commented 3 years ago

Everything should work now with 0.6.14, can you pls check and close the bug. Thanks

AndiDog commented 3 years ago

Works fine. šŸ˜‰ Thank you!