-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
portability: /usr/bin/env bash #3574
Conversation
Work in progress as Travis is throwing a wobbly over this one. |
3cbbe93
to
819c72b
Compare
I've got to the bottom of the test failures, the issue is that whilst this works fine:
This does not:
Works fine on my setup with MacOS and Bash5 but Ubuntu vanilla doesn't like it because in shebang lines arguments behave as though they were quoted apparently:
Simple fix?: -#!/usr/bin/env bash -l
+#!bash -l I guess |
I can't think of a reason why that statement is wrong, but if it is not wrong why does anyone ever need to use Clearly |
Sadly After a docs dive:
Options:
Options 1-5 seem pretty ugly, anyone got an option 6? |
Here's what option (3) would look like. diff --git a/cylc/flow/etc/job.sh b/cylc/flow/etc/job.sh
index 28fd2d292..625e8da1f 100644
--- a/cylc/flow/etc/job.sh
+++ b/cylc/flow/etc/job.sh
@@ -1,5 +1,11 @@
#!/bin/bash
+if [[ $1 == 'noreinvoke' ]]; then
+ shift
+else
+ exec "$(command -v bash)" "$0" noreinvoke "$@"
+fi
+ In retrospect it's probably not that bad since |
8f7e4ae
to
088e246
Compare
(Or, by experiment, not The Wikipedia "Shebang" page says an absolute path is required:
Maybe that makes sense: when a script begins executing (before its content is passed the interpreter specified on the shebang line) it is being executed by the OS, not being interpreted by the shell that invoked it (after all, the shell that invoked it could be anything, potentially something with no executable search path mechanism). |
What if we leave the value we have now for linux, and replace it doing something like "if os == darwin"? Could that work? Or maybe have a script for darwin? |
Rrecapping, to make sure I understand. There are two problems:
The Wikipedia Shebang page pretty much says there's no perfectly portable solution for interpreter location, for a static script. So for bash location I guess our options are:
For login shell, we can't use
(I like the idea of not using a login shell, but too many users might be unknowingly relying on the existing behaviour?) |
088e246
to
c5ed0fb
Compare
I'd tentatively say that proposal is reasonable. But perhaps we could make it a (non-default) option to not reinvoke job scripts in login shells. |
I'm not entirely convinced about that, although it would be great to have it as an option. The problem is, task job scripts mostly do typical command-line-y stuff that is very easy to do in bash and essentially just reproduces what users do when developing and testing the executables that they want to run via Cylc: export variables, move files around, and run commands and executables. That's the one thing that (in small doses) bash is better (or at least easier) for than Python, and it seems a bit much to force everyone to figure out how to do it in Python. However, maybe I could be convinced 😬 |
BTW this branch seems to have a few spurious changes?
|
Discussion best placed somewhere else but here's a starter for ten:
|
8b2ac0f
to
b24fb45
Compare
Whoops, rebase mistake, now removed the accidentally re-added files along with the remaining content in |
OK, I'm convinced! (Although I would still llump all of that into my "it would be great to have it as an option" comment - most users most of the time, I think, would still rather just use plain old bash to invoke a simple executable inside of their job scripts). |
96b62a5
to
3226e97
Compare
3226e97
to
dea5587
Compare
Rebased. |
4dd03d6
to
4d4618b
Compare
@hjoliver we have approval from Dave, I'll leave you to whack the merge button when ready. |
3cb66af
to
7c5fa87
Compare
7c5fa87
to
d9b2de7
Compare
Rebased. |
One of the new SoD tests failed here, I'll investigate... |
|
These changes close #3554
Basically
sed -i 's|/bin/bash|/usr/bin/env bash|g' $(git grep --name-only '/bin/bash')
If tests pass I'll move onto docs and changelog.
Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.