From a2cb71e1d47ec38b906772338b223e87919f7fc0 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 17 Oct 2022 15:55:08 -0400 Subject: [PATCH] make our ruby tolerant of different shebangs (#191) --- projects/ruby-lang.org/package.yml | 2 ++ projects/ruby-lang.org/tolerant-shebang.diff | 22 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 projects/ruby-lang.org/tolerant-shebang.diff diff --git a/projects/ruby-lang.org/package.yml b/projects/ruby-lang.org/package.yml index 34e70f47..81c4d673 100644 --- a/projects/ruby-lang.org/package.yml +++ b/projects/ruby-lang.org/package.yml @@ -18,7 +18,9 @@ build: gnu.org/gettext: ^0.21 tea.xyz/gx/cc: c99 tea.xyz/gx/make: '*' + git-scm.org: 2 script: | + git apply props/tolerant-shebang.diff ./configure --prefix="{{prefix}}" make --jobs {{hw.concurrency}} install diff --git a/projects/ruby-lang.org/tolerant-shebang.diff b/projects/ruby-lang.org/tolerant-shebang.diff new file mode 100644 index 00000000..a5b446be --- /dev/null +++ b/projects/ruby-lang.org/tolerant-shebang.diff @@ -0,0 +1,22 @@ +diff --git a/ruby.c b/ruby.c +index d7ba181..e2a80df 100644 +--- a/ruby.c ++++ b/ruby.c +@@ -2281,7 +2281,7 @@ load_file_internal(VALUE argp_v) + RSTRING_GETMEM(line, str, len); + if (len > 2 && str[0] == '#' && str[1] == '!') { + if (line_start == 1) warn_cr_in_shebang(str, len); +- if ((p = strstr(str+2, ruby_engine)) != 0) { ++ if ((p = strstr(str+2, ruby_engine)) != 0 && !getenv("TEA_PREFIX")) { + goto start_read; + } + } +@@ -2295,7 +2295,7 @@ load_file_internal(VALUE argp_v) + if (c == INT2FIX('!') && !NIL_P(line = rb_io_gets(f))) { + RSTRING_GETMEM(line, str, len); + warn_cr_in_shebang(str, len); +- if ((p = strstr(str, ruby_engine)) == 0) { ++ if ((p = strstr(str, ruby_engine)) == 0 && !getenv("TEA_PREFIX")) { + /* not ruby script, assume -x flag */ + goto search_shebang; + }