how can I run a command from an environment variable and have the internal trailing ampersand work?
You are correct, the reason is since it is being run from inside an environment variable. Therefore, the entire subsequent text, including the &
, is being passed as an argument to your long-running-script
.
The way around that is, to have the invocation $prompt_acc &
instead of $prompt_acc
in your prompt-to-run
file. This way, if you decide you don't want to run the script, the &
does not get in the way.