I like performing certain tasks using Emacs on different operating systems.
I use Termux to be able to access these tasks on my Android phone.
To reduce the configuration of the input in the file editing part of this workflow, I installed Termux: Widget and wrote a two-line widget script that
filename = $ (some shell logic) emacs $ filename
So now my phone has a button on the home screen that I can press and it opens the file I want in the editor. This part works well.
Often, once I have started editing, it is convenient to run a shell script. It's nice to be able to run the shell script in an Emacs buffer so you can use the usual buffer switch commands to interact with it. If I open a new Termux session and I type
Emacs at the prompt, so I can do
M-x async-shell-command, use the relative file names and tab completion to find the name of the script I want (for example:
../my-script.sh), and run it since Emacs. This part works well.
However, if I started Emacs from Termux: Widget, Emacs can not generate subprocesses. I receive errors like
/data/data/com.termux/files/usr/bin/sh: 1: ../my-script.sh: not found /data/data/com.termux/files/usr/bin/sh: 1: /data/data/com.termux/files/home/wwhat/my-script.sh: not found
I think the relative and absolute path names are correct because I use tab completion to check them before asking for execution.
This seems to be the kind of problem for which termux-exec was invented. However, it does not work by magic, and the documentation puzzles me.