+++ This bug was initially created as a clone of Bug #1058796 +++
Everybody would like to write scripts such as:
$ cat myscript.rb
#!/usr/bin/scl enable ruby193 ruby
puts 'hello from ruby'
However, this does not work. Therefore some tries to workaround this problem using wrapper scripts, so there exits package such as ruby193-ruby-wrapper, which add some simple wrappers you can later use in shebangs. Other fails with errors such as [1].
It appears, that all these problems are due to nature, of how the shebang is interpreted. E.g. the line "#!/usr/bin/scl enable ruby193 ruby" is the same as you would execute "/usr/bin/scl 'enable ruby193 ruby'". In other words, everything behind the /usr/bin/scl is passed into the newly executed interpreter as a first argument. How this works is discussed in [2].
I believe, that simple solution would be, if scl can parse the first parameter and split it internally into the other parameters, when it detects:
1) it has only one parameter,
2) it begins with acceptable keyword
3) and this keyword is followed by white space.
This IMO would completely remove the need for wrapper scripts and make scl users more happy.
[1] https://access.redhat.com/site/discussions/702583
[2] http://netbsd.2816.n7.nabble.com/usr-bin-env-behaviour-td219297.html
--- Additional comment from Miroslav Suchý on 2014-01-28 17:50:28 CET ---
Note that since bug 924120 you can use -- as delimiter, which can get you help rid of quotes:
/usr/bin/scl enable ruby193 -- ruby
But that does not solve the problem with shebang behaviour :(
I would not like modification of scl itself. Because it opens question how to parse options which contains spaces:
ruby -e puts\ "foo"
Instead we can ship with scl-utils script called scl-shebang, which will be:
#!/bin/bash
ACTION = $1
COLLECTION = $2
shift 2
scl "$ACTION" "$COLLECTION" $@
And you should be then able to run
#!/usr/bin/scl-shebang enable ruby193 -- ruby --some-param
--- Additional comment from Honza Horak on 2014-01-28 18:41:15 CET ---
(In reply to Miroslav Suchý from comment #1)
> Instead we can ship with scl-utils script called scl-shebang, which will be:
> #!/bin/bash
> ACTION = $1
> COLLECTION = $2
> shift 2
> scl "$ACTION" "$COLLECTION" $@
>
> And you should be then able to run
> #!/usr/bin/scl-shebang enable ruby193 -- ruby --some-param
IIUIC, the script gets only $1 set to value 'enable ruby193 -- ruby --some-param' in this example, so it should have to look differently; e.g. like the following:
#!/bin/sh
eval scl $@
Anyway, +1 for additional script, since making scl more complex doesn't seem like a good idea for me.
--- Additional comment from Vít Ondruch on 2014-01-29 09:19:39 CET ---
Thank you guys for your input. Definitely good idea with scl-shebang wrapper.
Nevertheless, I am still slightly in favor of my original proposal for single reason - it does not need any additional documentation IMO. Using "#!/usr/bin/scl enable ruby193 ruby" shebang is naturally the first thing people will try and fail with confusing: "Need at least 3 arguments. Run scl --help to get help." So I would first try to modify the scl and if this attempt fails, I would go with something like scl-shebang.
Btw I agree with Honza's commet #2 (did not tested it though ;).
--- Additional comment from Jan Zeleny on 2014-04-08 13:52:39 CEST ---
Upstream ticket:
https://fedorahosted.org/SoftwareCollections/ticket/13
--- Additional comment from Fedora Update System on 2015-01-09 16:05:35 CET ---
scl-utils-2.0-2.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/scl-utils-2.0-2.fc20
--- Additional comment from Fedora Update System on 2015-01-09 16:06:45 CET ---
scl-utils-2.0-2.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/scl-utils-2.0-2.fc21
--- Additional comment from Fedora Update System on 2015-01-10 03:58:08 CET ---
Package scl-utils-2.0-2.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing scl-utils-2.0-2.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-0479/scl-utils-2.0-2.fc21
then log in and leave karma (feedback).
--- Additional comment from Fedora Update System on 2015-01-21 09:27:03 CET ---
scl-utils-2.0.1-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/scl-utils-2.0.1-1.fc21
--- Additional comment from Fedora Update System on 2015-01-21 09:27:22 CET ---
scl-utils-2.0.1-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/scl-utils-2.0.1-1.fc20
--- Additional comment from Miroslav Suchý on 2015-01-21 09:44:21 CET ---
Can you please post here, what solution you choose? How this report was resolved?
--- Additional comment from Jan Zeleny on 2015-01-21 10:41:50 CET ---
This works as of scl-utils-2.0:
#!/usr/bin/scl enable <collection> -- <command>
If you find any problems, let us know.
--- Additional comment from Fedora Update System on 2015-01-30 05:28:51 CET ---
scl-utils-2.0.1-2.fc20 has been pushed to the Fedora 20 stable repository. If problems still persist, please make note of it in this bug report.
--- Additional comment from Fedora Update System on 2015-01-30 05:44:21 CET ---
scl-utils-2.0.1-2.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
--- Additional comment from iakov Gan on 2016-06-26 20:19:45 CEST ---
Any idea when/how scl-utils-2.0.1 will be avalible for RHEL?
--- Additional comment from Vít Ondruch on 2016-06-27 10:51:31 CEST ---
(In reply to iakov Gan from comment #14)
> Any idea when/how scl-utils-2.0.1 will be avalible for RHEL?
I would not expect it any time soon due to backward compatibility issues.