Commit bdc4c189 authored by Medicean's avatar Medicean

(fix: Core/CMDLINUX) 修正在没有 xxd 时 asenv 不生效的 bug

parent a42527e9
......@@ -4,7 +4,15 @@
module.exports = (arg1, arg2, arg3) => ({
exec: {
_: `ENVSTR=$(echo #{buffer::env}|xxd -r -p);
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
AENVSTR="#{buffer::env}";
if command_exists xxd; then
ENVSTR=$(echo -n $AENVSTR|xxd -r -p);
elif command_exists python3; then
ENVSTR=$(echo -n $AENVSTR|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))");
else
ENVSTR=$(echo -n $AENVSTR|sed 's/\\([0-9A-F]\\{2\\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf);
fi;
while [ $ENVSTR ]; do
ASLINE=\${ENVSTR%%"|||asline|||"*};
ENVSTR=\${ENVSTR#*"|||asline|||"};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment