Constructs a command line to run in a shell. The shell could be re-used/long-lived, this means we cannot spawn a new process with a nice and fresh environment, we need to encode environment modifications into the returned command.
Inspired by VS Code implementation, see: https://github.com/microsoft/vscode/blob/f395cac4fff0721a8099126172c01411812bcb4a/src/vs/workbench/contrib/debug/node/terminals.ts#L79
the host terminal process infos
program to execute in the host terminal
This method will try to leave arg[0]
unescaped if possible. The reason
is that shells like cmd
expect their own commands like dir
to be
unescaped.
empty string if args
is empty, otherwise an escaped command.
If this method returns false
then we definitely need quoting.
May return false positives.
Create command lines ready to be sent to a shell's stdin for evaluation.