resolveShellSpec function
Implementation
ShellSpec resolveShellSpec(ShellConfig shell, {Map<String, String>? env}) {
final e = env ?? Platform.environment;
final home = e['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 ??
e['SHELL'] ??
(Platform.isWindows ? 'cmd.exe' : '/bin/bash');
return ShellSpec(
executable: program,
arguments: shell.args,
workingDirectory: expandTilde(shell.workingDirectory),
environment: {...e, 'TERM': 'xterm-256color', ...shell.env},
);
}