fork-dev / Tracker

Bug and issue tracker for Fork for Mac
493 stars 12 forks source link

A "Start Process" custom command will crash without `#!/bin/sh` #2148

Open JessyCatterwaul opened 3 weeks ago

JessyCatterwaul commented 3 weeks ago

Running a script from a custom command will not work unless #!/bin/sh is at the beginning of the file. If it's absent, Fork crashes upon initiating the command.

#!/bin/sh is not necessary when running a script as "Sh Command", instead.

DanPristupov commented 3 weeks ago

Running a script from a custom command will not work unless #!/bin/sh is at the beginning of the file.

What interpreter must be used when there's no shebang?

#!/bin/sh is not necessary when running a script as "Sh Command", instead.

Yes, because it's an sh command (i.e. we know the interpreter).

DanPristupov commented 3 weeks ago

https://en.wikipedia.org/wiki/Shebang_(Unix)

JessyCatterwaul commented 3 weeks ago

What interpreter must be used when there's no shebang?

The Fork tooling is undocumented, so I actually have no idea what you're asking. All I know is that I don't need to define what shell I'm using in Terminal, and expect the same here. If that's an incorrect assumption, then it should be documented.

Regardless, this shouldn't cause Fork to crash. If we can't have documentation, perhaps we could at least have an educational error message here.

DanPristupov commented 3 weeks ago

The Fork tooling is undocumented, so I actually have no idea what you're asking.

It’s not Fork, it’s unix. I sent the link to the docs already.

Here’s the quote:

The loader executes the specified interpreter program, passing to it as an argument the path that was initially used when attempting to run the script, so that the program may use the file as input data. For example, if a script .. starts with the line #!/bin/sh, then the program loader is instructed to run the program /bin/sh, passing path to script as the first argument.

All I know is that I don't need to define what shell I'm using in Terminal

You are just lucky (or use very simple scripts). For example sh and bash have quite a lot of differences and running a script without shebang on different systems (macOS 10.14, macOS 10.15 or Linux) will likely lead to an unexpected behavior.

Regardless, this shouldn't cause Fork to crash.

No, it shouldn't. I'll try to reproduce the problem.