Actions
Bug #13786
closedUnexpected behavior handling shebang
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
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.
Updated by shevegen (Robert A. Heiler) about 7 years ago
May I ask, what is the scl program doing with the shebang line?
Updated by vo.x (Vit Ondruch) about 7 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) about 7 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.
Updated by nobu (Nobuyoshi Nakada) about 7 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]
Actions
Like0
Like0Like0Like0Like0