quoteArg static method
Quote an argument for safe shell inclusion.
Implementation
static String quoteArg(String arg) {
if (arg.isEmpty) return "''";
if (Platform.isWindows) {
// Windows quoting
if (!arg.contains(RegExp(r'[\s"&|<>^%]'))) return arg;
return '"${arg.replaceAll('"', '\\"')}"';
}
// POSIX
if (RegExp(r'^[a-zA-Z0-9._/=:@-]+$').hasMatch(arg)) return arg;
return "'${arg.replaceAll("'", "'\\''")}'";
}