Commit 3f96ab8c authored by Medicean's avatar Medicean

(Fix: Core/CMDLINUX) 修正dash与bash下echo -e 参数不一致的问题

parent bba289dd
......@@ -8,13 +8,13 @@ module.exports = () => ({
_: `ACWD=$(pwd);
AUNAME=$(uname -a);
AUSER=$(whoami);
echo -ne "$ACWD\\t/\\t$AUNAME\\t$AUSER";`.replace(/\n\s+/g, '')
echo -n "$ACWD\t/\t$AUNAME\t$AUSER";`.replace(/\n\s+/g, '')
},
probedb: { // 检测数据库函数支持
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
DBLIST="mysql psql sqlite3";
for v in $DBLIST; do
if command_exists $v; then echo -e "$v\\t1"; else echo -e "$v\\t0"; fi;
if command_exists $v; then echo -n "$v\t1"; else echo -n "$v\t0"; fi;
done;`.replace(/\n\s+/g, '')
}
})
\ No newline at end of file
......@@ -7,11 +7,11 @@ module.exports = (arg1, arg2, arg3) => ({
_: `command_exists() { command -v "$@" > /dev/null 2>&1; };
AENVSTR="#{buffer::env}";
if command_exists xxd; then
ENVSTR=$(echo -ne $AENVSTR|xxd -r -p);
ENVSTR=$(echo -n $AENVSTR|xxd -r -p);
elif command_exists python3; then
ENVSTR=$(echo -ne $AENVSTR|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))");
ENVSTR=$(echo -n $AENVSTR|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))");
else
ENVSTR=$(echo -ne $AENVSTR|sed 's/\\([0-9A-F]\\{2\\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf);
ENVSTR=$(echo -n $AENVSTR|sed 's/\\([0-9A-F]\\{2\\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf);
fi;
while [ $ENVSTR ]; do
ASLINE=\${ENVSTR%%"|||asline|||"*};
......
......@@ -8,19 +8,19 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
show_databases: {
_: `APWD="#{passwd}";
if [ -z $APWD ]; then MYSQLPWD=""; else MYSQLPWD="-p\${APWD}"; fi;
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -e "show databases;"|while read DBRES; do echo -n "$DBRES\\t"; done;`,
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -e "show databases;"|while read DBRES; do echo -n "$DBRES\t"; done;`,
},
// 显示数据库所有表
show_tables: {
_: `APWD="#{passwd}";
if [ -z $APWD ]; then MYSQLPWD=""; else MYSQLPWD="-p\${APWD}"; fi;
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -D#{db} -e "show tables;"|while read DBRES; do echo -n "$DBRES\\t"; done;`
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -D#{db} -e "show tables;"|while read DBRES; do echo -n "$DBRES\t"; done;`
},
// 显示表字段
show_columns: {
_: `APWD="#{passwd}";
if [ -z $APWD ]; then MYSQLPWD=""; else MYSQLPWD="-p\${APWD}"; fi;
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -D#{db} -e "select concat(column_name,0x2028,column_type,0x29) from information_schema.COLUMNS where TABLE_SCHEMA=0x#{buffer::db} and TABLE_NAME=0x#{buffer::table};"|while read DBRES; do echo -n "$DBRES\\t"; done;`
mysql --raw -N -B -h#{host} -u#{user} $MYSQLPWD -D#{db} -e "select concat(column_name,0x2028,column_type,0x29) from information_schema.COLUMNS where TABLE_SCHEMA=0x#{buffer::db} and TABLE_NAME=0x#{buffer::table};"|while read DBRES; do echo -n "$DBRES\t"; done;`
},
// 执行SQL语句
query: {
......
......@@ -7,13 +7,13 @@ module.exports = (arg1, arg2, arg3, arg4, arg5, arg6) => ({
// 显示所有数据库
show_databases: {
_: `SQLITEFILE="#{host}";
if [ -f $SQLITEFILE ]; then echo -n "main\t"; else echo "ERROR:// $SQLITEFILE not found."; fi;
if [ -f $SQLITEFILE ]; then echo -n "main\t"; else echo -n "ERROR:// $SQLITEFILE not found."; fi;
`,
},
// 显示数据库所有表
show_tables: {
_: `SQLITEFILE="#{host}";
if [ ! -f $SQLITEFILE ]; then echo "ERROR:// $SQLITEFILE not found."; exit; fi;
if [ ! -f $SQLITEFILE ]; then echo -n "ERROR:// $SQLITEFILE not found."; exit; fi;
sqlite3 $SQLITEFILE <<EOF
.headers off
.separator "" "\\t"
......@@ -24,7 +24,7 @@ EOF
// 显示表字段
show_columns: {
_: `SQLITEFILE="#{host}";
if [ ! -f $SQLITEFILE ]; then echo "ERROR:// $SQLITEFILE not found."; exit; fi;
if [ ! -f $SQLITEFILE ]; then echo -n "ERROR:// $SQLITEFILE not found."; exit; fi;
sqlite3 $SQLITEFILE <<EOF
.separator "" "\\t"
.headers off
......@@ -35,7 +35,7 @@ EOF
// 执行SQL语句
query: {
_: `SQLITEFILE="#{host}";
if [ ! -f $SQLITEFILE ]; then echo "ERROR:// $SQLITEFILE not found."; exit; fi;
if [ ! -f $SQLITEFILE ]; then echo -n "ERROR:// $SQLITEFILE not found."; exit; fi;
sqlite3 $SQLITEFILE <<EOF
.separator "\\t|\\t" "\\t|\\t\\r\\n"
.headers on
......
......@@ -4,11 +4,11 @@
module.exports = (arg1, arg2, arg3) => ({
dir: {
_: `cd #{path} && find . -maxdepth 1 \\( -type d -printf "%f/\\t%AY-%Am-%Ad %AH:%AM:%AS\\t%s\t%.4m\\n" \\) , \\( -not -type d -printf "%f\\t%AY-%Am-%Ad %AH:%AM:%AS\\t%s\\t%.4m\\n" \\)||echo -ne "ERROR:// Path not found OR no Permission";`
_: `cd #{path} && find . -maxdepth 1 \\( -type d -printf "%f/\\t%AY-%Am-%Ad %AH:%AM:%AS\\t%s\t%.4m\\n" \\) , \\( -not -type d -printf "%f\\t%AY-%Am-%Ad %AH:%AM:%AS\\t%s\\t%.4m\\n" \\)||echo -n "ERROR:// Path not found OR no Permission";`
},
delete: {
_: `rm -rf #{path} && echo -ne 1||echo -ne 0;`,
_: `rm -rf #{path} && echo -n 1||echo -n 0;`,
},
create_file: {
......@@ -16,24 +16,24 @@ module.exports = (arg1, arg2, arg3) => ({
ACONTENT="#{buffer::content}";
ADSTPATH="#{path}";
if command_exists xxd; then
echo -ne $ACONTENT|xxd -r -p > $ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|xxd -r -p > $ADSTPATH && echo -n 1||echo -n 0;
elif command_exists python3; then
echo -ne $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">$ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">$ADSTPATH && echo -n 1||echo -n 0;
else
echo -ne $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>$ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>$ADSTPATH && echo -n 1||echo -n 0;
fi;`.replace(/\n\s+/g, '')
},
read_file: {
_: `cat #{path}||echo -ne "ERROR:// File not found or no Permission";`
_: `cat #{path}||echo -n "ERROR:// File not found or no Permission";`
},
copy: {
_: `cp -af #{path} #{target} && echo -ne 1||echo -ne 0;`
_: `cp -af #{path} #{target} && echo -n 1||echo -n 0;`
},
download_file: {
_: `cat #{path}||echo "ERROR:// File not found or no Permission";`
_: `cat #{path}||echo -n "ERROR:// File not found or no Permission";`
},
upload_file: {
......@@ -41,28 +41,28 @@ module.exports = (arg1, arg2, arg3) => ({
ACONTENT="#{buffer::content}";
ADSTPATH="#{path}";
if command_exists xxd; then
echo -ne $ACONTENT|xxd -r -p >> $ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|xxd -r -p >> $ADSTPATH && echo -n 1||echo -n 0;
elif command_exists python3; then
echo -ne $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">>$ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.unhexlify(input().strip()))">>$ADSTPATH && echo -n 1||echo -n 0;
else
echo -ne $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>>$ADSTPATH && echo -ne 1||echo -ne 0;
echo -n $ACONTENT|sed 's/\\([0-9A-F]\\{2\}\\)/\\\\\\\\\\\\x\\1/gI'|xargs printf>>$ADSTPATH && echo -n 1||echo -n 0;
fi;`.replace(/\n\s+/g, '')
},
rename: {
_: `mv #{path} #{name} && echo -ne 1||echo -ne 0;`
_: `mv #{path} #{name} && echo -n 1||echo -n 0;`
},
retime: {
_: `touch -d "#{time}" #{path} && echo -ne 1||echo -ne 0;`
_: `touch -d "#{time}" #{path} && echo -n 1||echo -n 0;`
},
chmod: {
_: `chmod #{mode} #{path} && echo -ne 1||echo -ne 0;`
_: `chmod #{mode} #{path} && echo -n 1||echo -n 0;`
},
mkdir: {
_: `mkdir -p #{path} && echo -ne 1||echo -ne 0;`,
_: `mkdir -p #{path} && echo -n 1||echo -n 0;`,
},
wget: {
......@@ -75,7 +75,7 @@ module.exports = (arg1, arg2, arg3) => ({
elif command_exists busybox && busybox --list-modules | grep -q wget; then
ascurl='busybox wget --no-check-certificate -qO'
fi;
$ascurl #{path} #{url} && echo -ne 1||echo -ne 0;
$ascurl #{path} #{url} && echo -n 1||echo -n 0;
`.replace(/\n\s+/g, '')
}
})
\ No newline at end of file
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