Project

General

Profile

Bug #13786

Unexpected behavior handling shebang

Added by vo.x (Vit Ondruch) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[ruby-core:82267]

Description

Ruby exhibits unexpected behavior handling this shebang:

$ cat <<EOF > foo
> #!/usr/bin/scl enable rh-ruby22 -- ruby
> EOF

$ ruby foo
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- uby (LoadError)
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

This was originally reported here 1.

Associated revisions

Revision 157ee2bd
Added by nobu (Nobuyoshi Nakada) over 2 years ago

ruby.c: ignore non-option in shebang line

  • ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59564
Added by nobu (Nobuyoshi Nakada) over 2 years ago

ruby.c: ignore non-option in shebang line

  • ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786]

Revision 59564
Added by nobu (Nobuyoshi Nakada) over 2 years ago

ruby.c: ignore non-option in shebang line

  • ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786]

Revision 59564
Added by nobu (Nobuyoshi Nakada) over 2 years ago

ruby.c: ignore non-option in shebang line

  • ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786]

History

Updated by shevegen (Robert A. Heiler) over 2 years ago

May I ask, what is the scl program doing with the shebang line?

Updated by vo.x (Vit Ondruch) over 2 years ago

shevegen (Robert A. Heiler) wrote:

May I ask, what is the scl program doing with the shebang line?

Ok, lets use different shebangs, where the "scl" won't distract you:

$ cat <<EOF > foo
> #!/usr/bin/ruby -- ruby
> EOF

$ ruby foo
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- uby (LoadError)
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

$ cat <<EOF > foo
> #!rubbish ruby -- ruby
> EOF

$ ruby foo
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- uby (LoadError)
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

Ruby tries to parse options after "ruby" in a shebang line, and assumes there are only options.
So the last "ruby" is treated as "-ruby" option.

#4

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59564.


ruby.c: ignore non-option in shebang line

  • ruby.c (moreswitches): process all words as options only in an environment variable, but not in a shebang line. [ruby-core:82267] [Bug #13786]

Also available in: Atom PDF