This commit is contained in:
lollipopkit
2023-08-07 20:02:09 +08:00
parent c1b3ff7bfd
commit 36b24bedb4
7 changed files with 55 additions and 52 deletions

View File

@@ -33,7 +33,16 @@ enum AppShellFuncType {
case AppShellFuncType.status:
return statusCmds.join(_cmdDivider);
case AppShellFuncType.docker:
return dockerCmds.join(_cmdDivider);
return '''
# If the cmd result contains "permission denied", try to use `sudo`
result=\$(docker version 2>&1)
deniedStr="permission denied"
containStr=\$(echo \$result | grep "\${deniedStr}")
if [[ \$containStr != "" ]]; then
${dockerCmds.join(_cmdDivider)}
else
${dockerCmds.map((e) => "sudo -S $e").join(_cmdDivider)}
fi''';
}
}