Skip to content

Commit a9aabf5

Browse files
committed
Add support for truffleruby
Truffleruby comes with binaries having both shell and ruby code, this change detects start of ruby code and if necessary skips the shell code part.
1 parent f5ad527 commit a9aabf5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ matrix:
3131
env: WITH_RUBYGEMS=1.6.2
3232
- rvm: 2.5
3333
env: TEST_SUFFIX=-bundle
34+
- rvm: 2.5
35+
env: TEST_SUFFIX=-truffleruby
3436
- rvm: 1.8.7
3537
- rvm: 1.9.2
3638
- rvm: 1.9.3

Diff for: bin/ruby_executable_hooks

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ rescue LoadError
1212
warn "unable to load executable-hooks/hooks" if ENV.key?('ExecutableHooks_DEBUG')
1313
end unless $0.end_with?('/executable-hooks-uninstaller')
1414

15-
eval File.read($0), binding, $0
15+
content = File.read($0)
16+
17+
if
18+
(index = content.index("\n#!ruby\n")) && index > 0
19+
then
20+
skipped_content = content.slice!(0..index)
21+
start_line = skipped_content.count("\n") + 1
22+
eval content, binding, $0, start_line
23+
else
24+
eval content, binding, $0
25+
end

Diff for: test-tf-truffleruby/truffleruby_comment_test.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
gem install executable-hooks-$(awk -F'"' '/VERSION/{print $2}' < lib/executable-hooks/version.rb).gem --development
2+
# match=/installed/
3+
4+
gem install haml -v "4.0.7" # match=/installed/
5+
haml_bin=$(which haml )
6+
head -n 1 $haml_bin # match=/ruby_executable_hooks/
7+
8+
## simulate truffleruby style binary with shell code mixed in
9+
## \043 - is a # ... somehow it breaks tf
10+
( head -n 1 $haml_bin; echo -e 'echo $HOME\n\043!ruby'; tail -n +2 $haml_bin ) > $haml_bin.new
11+
mv $haml_bin.new $haml_bin
12+
chmod +x $haml_bin
13+
14+
haml _4.0.7_ -v # match=/4.0.7/
15+
16+
gem uninstall -x haml -v 4.0.7 # match=/Successfully uninstalled/

0 commit comments

Comments
 (0)