This commit is contained in:
lollipopkit
2023-08-28 19:26:17 +08:00
parent d06ffdacd0
commit d9c26e01f4
3 changed files with 130 additions and 51 deletions

View File

@@ -43,8 +43,7 @@ enum AppShellFuncType {
switch (this) {
case AppShellFuncType.status:
return '''
result=\$(uname 2>&1 | grep "Linux")
if [ "\$result" != "" ]; then
if [ "\$isLinux" != "" ]; then
\t${_statusCmds.join(_cmdDivider)}
else
\t${_bsdStatusCmd.join(_cmdDivider)}
@@ -59,23 +58,16 @@ else
fi''';
case AppShellFuncType.process:
return '''
# Try sequencially
# main Linux: `ps -aux`
# BSD: `ps -ax`
# alpine: `ps -o pid,user,time,args`
#
# If there is any error, try another one
result=\$(ps -aux 2>&1 | grep "ps: ")
if [ "\$result" = "" ]; then
ps -aux
if [ "\$isLinux" != "" ]; then
\tif [ "\$isBusybox" != "" ]; then
\t\tps w
\telse
\t\tps -aux
\tfi
else
result=\$(ps -ax 2>&1 | grep "ps: ")
if [ "\$result" = "" ]; then
ps -ax
else
ps -o pid,user,time,args
fi
fi''';
\tps -ax
fi
''';
}
}
@@ -201,6 +193,10 @@ final _shellCmd = """
export LANG=en_US.UTF-8
isLinux=\$(uname 2>&1 | grep "Linux")
# Link /bin/sh to busybox?
isBusybox=\$(ls -l /bin/sh | grep "busybox")
${AppShellFuncType.shellScript}
""";