Closed VorpalBlade closed 1 year ago
Is it possible to use templates in scripts? If yes then something like
$ cat run_test.sh.tmpl
{{- if eq .chezmoi.os "android" }}
#!/data/data/com.termux/files/usr/bin/env bash
{{ else }}
#!/usr/bin/env bash
{{ end }}
echo Hi
could work. For it to work without such a workaround we would have to patch our golang and add the same functionality as we have in libtermux-exec.
Tangentially related: we have an open feature request for adding support for golang's "shebangs" (like //usr/bin/go run $0 $@ ; exit
) over at https://github.com/termux/termux-exec/issues/22.
Ah, yes, It is possible to be even more elegant:
#!{{ lookPath "bash" }}
[ ... ]
That solves my immediate problem. However, that is specific to chezmoi. I don't know if there are any other Go programs that need to execute scripts that lack the template functionality. None that I use that I know of.
Problem description
chezmoi installed from the official termux repositories fail to execute scripts. This is specific to the termux environment, and works fine on normal desktop Linux.
Based on a bug report in chezmoi this is a termux bug: https://github.com/twpayne/chezmoi/issues/2345
The issue seems to be that termux uses LD_PRELOAD hacks that don't take effect on programs written in Go. An alternative solution to enable full functionality on Termux is needed (as the upstream developer does not consider this a bug in chezmoi).
Steps to reproduce the behavior.
What is the expected behavior?
The
run_
script should execute, and in this case print "Hi"Instead you will get an output like the following:
System information