"sh: no closing quote" 尝试制作 ASCII 回显转换脚本时
"sh: no closing quote" When trying to make an ASCII echo convert script
我正在尝试将 ASCII 艺术文件转换为可以 运行 无任何错误的回显命令,当它尝试 运行 处的脚本时出现错误最后一行,错误是:
sh: no closing quote
我可能以错误的方式编写了脚本,我该如何解决?
脚本:
import sys, os
text = sys.stdin.read()
full = "echo -e \""
chars_to_escape = ["!",'"',"#","$","&","'","(",")","*",";","<",">","?",
for char in text:
if char in chars_to_escape:
full += f"\"\{char}\""
else:
full += char
print(full)
os.system(full)
ASCII 艺术:
,--.
{ }
K, }
/ `Y`
_ / /
{_'-K.__/
`/-.__L._
/ ' /`\_}
/ ' /
____ / ' /
,-'~~~~ ~~/ ' /_
,' ``~~~%%',
( % Y
{ %% I
{ - % `.
| ', % )
| | ,..__ __. Y
| .,_./ Y ' / ^Y J )|
\ |' / | | ||
\ L_/ . _ (_,.'(
\, , ^^""' / | )
\_ \ /,L] /
'-_`-, ` ` ./`
`-(_ )
^^\..___,.--`
我忘记将最后一个引号添加到 full
变量。
我正在尝试将 ASCII 艺术文件转换为可以 运行 无任何错误的回显命令,当它尝试 运行 处的脚本时出现错误最后一行,错误是:
sh: no closing quote
我可能以错误的方式编写了脚本,我该如何解决?
脚本:
import sys, os
text = sys.stdin.read()
full = "echo -e \""
chars_to_escape = ["!",'"',"#","$","&","'","(",")","*",";","<",">","?",
for char in text:
if char in chars_to_escape:
full += f"\"\{char}\""
else:
full += char
print(full)
os.system(full)
ASCII 艺术:
,--.
{ }
K, }
/ `Y`
_ / /
{_'-K.__/
`/-.__L._
/ ' /`\_}
/ ' /
____ / ' /
,-'~~~~ ~~/ ' /_
,' ``~~~%%',
( % Y
{ %% I
{ - % `.
| ', % )
| | ,..__ __. Y
| .,_./ Y ' / ^Y J )|
\ |' / | | ||
\ L_/ . _ (_,.'(
\, , ^^""' / | )
\_ \ /,L] /
'-_`-, ` ` ./`
`-(_ )
^^\..___,.--`
我忘记将最后一个引号添加到 full
变量。