【发布时间】:2017-10-18 10:49:03
【问题描述】:
我使用的是 Ubuntu 16.04。我使用 Sublime Text 3,我可以编译 c++ 程序并在终端中运行它。 以下是脚本。
{
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "RunInShell",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name};echo; echo Press ENTER to continue; read line;exit; exec bash\"'"]
}
]
}
但是,当 c++ 程序的路径包含空格时(如/algorithms/Search in Rotated Sorted Array),脚本不起作用!
bash: /media/algorithms/Search: No such file or directory 在我使用 RunInShell 时显示在终端中。
我正在尝试修改脚本,例如插入单引号。
"cmd": ["gnome-terminal -e 'bash -c \"'${file_path}/${file_base_name}';echo; echo Press ENTER to continue; read line;exit; exec bash\"'"]
但它不起作用。
我想知道如何修改脚本以使其正常工作。
【问题讨论】:
-
您可能需要在
${file_path}/${file_base_name}部分周围额外引用。 -
你的想法是对的,但是这部分的附加引号与前面的引号匹配。所以它不起作用。
标签: c++ bash ubuntu terminal sublimetext3