RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1369788 - Add support for SCL in shebangs
Summary: Add support for SCL in shebangs
Keywords:
Status: CLOSED DUPLICATE of bug 1372700
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: scl-utils
Version: 7.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On: 1058796
Blocks: 949833 1385471 1390495
TreeView+ depends on / blocked
 
Reported: 2016-08-24 12:04 UTC by Tomas Orsava
Modified: 2017-01-17 12:11 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1058796
: 1390495 (view as bug list)
Environment:
Last Closed: 2017-01-13 12:56:40 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Tomas Orsava 2016-08-24 12:04:13 UTC
+++ 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.

Comment 3 Joe Orton 2017-01-13 12:56:40 UTC

*** This bug has been marked as a duplicate of bug 1372700 ***


Note You need to log in before you can comment on or make changes to this bug.