From c3bae8b6a9ffecf0f41f1f6898a508066baa2f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 23 Oct 2023 05:47:42 +0200 Subject: [PATCH] Fix fixing JRuby shebangs on macOS LC_CTYPE is "utf-8" on macOS, which instructs utilities like `tr` to expect Unicode input. However, in case of binary files, which we here explicitly guard against, the utility will fail because of invalid input encoding. The solution is to set LC_CTYPE=C which effectively removes the expectation around input encoding and allows `tr` to process the input byte-by-byte. --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 8defac8d..00bff056 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -793,7 +793,7 @@ install_jruby_launcher() { fix_jruby_shebangs() { for file in "${PREFIX_PATH}/bin"/*; do - if [ "$(head -c 20 "$file" | tr -d '\0')" = "#!/usr/bin/env jruby" ]; then + if [ "$(head -c 20 "$file" | LC_CTYPE=C tr -d '\0')" = "#!/usr/bin/env jruby" ]; then sed -i.bak "1 s:.*:#\!${PREFIX_PATH}\/bin\/jruby:" "$file" rm "$file".bak fi