shellChangeDirectory function
Builds a shell command that changes to workdir before continuing.
On POSIX, shellQuote prevents the shell from evaluating command substitutions or other metacharacters in the directory name.
Implementation
String shellChangeDirectory(String workdir) {
if (Platform.isWindows) {
final escaped = workdir.replaceAll('"', '""');
return 'cd /d "$escaped" &&';
}
return 'cd ${shellQuote(workdir)} &&';
}