resolveShellSpec function
Maps ShellConfig to concrete spawn parameters.
Platform defaults (Android HOME/cwd, shell binary fallbacks) are applied
here; hosts override via ShellConfig fields. See docs/library-api.md.
Implementation
ShellSpec resolveShellSpec(ShellConfig shell, {Map<String, String>? env}) {
final e = env ?? Platform.environment;
final shellEnv = _effectiveShellEnvironment(e, shell.env);
final home = shellEnv['HOME'];
String? expandTilde(String? p) {
if (p == null) return null;
if (p == '~') return home;
if (p.startsWith('~/') && home != null) return '$home${p.substring(1)}';
return p;
}
final program = shell.program ?? _defaultShellExecutable(e);
return ShellSpec(
executable: program,
arguments: shell.args,
workingDirectory:
expandTilde(shell.workingDirectory) ?? _defaultWorkingDirectory(e),
environment: shellEnv,
);
}