Syntax error: word unexpected (expecting ")")
Syntax error: word unexpected (expecting ")")
简而言之问题 - 在Linux中,每当我们得到以下错误
“语法错误:单词意外(应为“)”)”,一般是什么意思?
问题详情 - 我一直在尝试根据 Ubuntu 10.04 (Lucid Lynx). I followed the exact steps mentioned at the link compiling Qt-4.6 上的 Sourcery 工具链交叉编译 Qt 4.6。但是我在 ./configure 步骤中得到以下错误 -
/home/weds/qt-everywhere-opensource-src-4.6.1/bin/qmake: 1: Syntax error: word unexpected (expecting ")")
在互联网上搜索我发现了很多关于这个错误的帖子并阅读了所有这些帖子。 这是什么错误,我该如何解决?
P.S 1 - Sourcery 工具链存在于 /opt/ 文件夹和我的 PATH 变量中正确指向它。
P.S 2 - 这个工具链不是我手动安装的。相反,它是由供应商作为 .tgz 文件提供的,我将其提取到 /opt/ 文件夹中。
99%的情况是文件传输方式错误,ASCII或者二进制。
尝试直接在目标系统上提取工具链。
这是 Almquist shell or any of its derivatives like Dash (and Dash happened to be the default implementation of /bin/sh
on Ubuntu 10.04 (Lucid Lynx)) 在解析 )
相反,例如在这种情况下声明:
dash -c 'case a in b c) :; esac'
dash: 1: Syntax error: word unexpected (expecting ")")
那是因为在 b
之后,唯一期望的是 )
,(尽管实际上 |
也是允许的)所以 c
字是出乎意料。
dash -c 'myfunc( something'
dash: 1: Syntax error: word unexpected (expecting ")")
可能发生这种情况的一种情况是,脚本是在 Microsoft OS 上编写或传输的,其中文本行结尾是 CRLF 而不是 LF。
一个
case a in b) cmd1;;
c) cmd2
esac
在 MS-DOS 上编写的脚本将显示为:
case a in b) cmd1;;<CR>
c) cmd2<CR>
esac<CR>
在 Unix 上,c
将是 <CR>
单词后的额外 单词。
这不太可能,因为您的错误报告问题出现在脚本的第一行,而且大多数脚本都以 #! /path/to/interpreter
shebang 行开头。
另一种可能性是,您尝试 运行 的脚本是在 sh
是 bash
的假设下编写的,并且使用的结构无法移植到其他 sh
实现。
由于您使用的是过时且不再维护的 OS,也有可能您 运行遇到了该版本 Dash 中的错误。您可以 运行 dpkg-reconfigure dash
并告诉系统不要将 Dash 用于 sh
(而是 Bash)以查看是否有帮助。
同样,它不太可能在第一行。
听起来更有可能的是 qmake
文件不是脚本,而是系统无法识别的二进制可执行文件,例如因为它是错误体系结构的二进制格式或者在传输中损坏了。
在那种情况下,当系统无法将其识别为本机可执行文件时,调用应用程序将尝试 运行 sh
就好像它是 shell 脚本一样,并且文件中存在 (
字符可能会导致 Dash 失败并出现此类错误。
在我的系统上:
dash /bin/touch
/bin/touch: 1: /bin/touch: Syntax error: word unexpected (expecting ")")
并且如果您将 /bin/touch
的内容当作脚本来查看,您会看到:
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@>^@^A^@^@^@5&@^@^@^@^@^@@^@^@^@^@^@^@^@(ô^@^@...
这个问题的答案似乎张贴在您链接到的说明中。
诚然这是一个 long way down in the comments 但没多久就搜索到了 qmake: Syntax error: word unexpected
.
引用:
Tej says: January 4, 2013 at 12:20 pm
Ok, I have solved the Problem. Its very unfortunate that ppl did not
tell what actually is the problem. Problem is we have to use Host
qmake. For that whatever Export (export
PATH=/usr/local/arm/4.3.2/bin:$PATH etc.) we did in step during tslib
installation, we have to undo all of that. Thats it.
Hope that help someone
如果不清楚,Tej 表明您正在尝试 运行 主机上的交叉编译 qmake
系统.
当这个问题出现时,我正在 Ubuntu 18.04 (Bionic Beaver) 上编写 C++ 程序。原因是程序的文件名中包含字符“(”和“)”。重命名文件后,它对我有用。
对我来说一个奇怪的修复是删除文件 package-lock.json 和 node_modules 文件夹,以及然后再次构建 Docker 图像。
有时出现此错误只是因为您当前工作的目录有“错误的命名约定” .. 可能是
- demo_project(复制)
- my_project_1(另一份)
正确的命名约定是
1。 demo_project_copy
2。 my_project_1_another_copy
简而言之问题 - 在Linux中,每当我们得到以下错误 “语法错误:单词意外(应为“)”)”,一般是什么意思?
问题详情 - 我一直在尝试根据 Ubuntu 10.04 (Lucid Lynx). I followed the exact steps mentioned at the link compiling Qt-4.6 上的 Sourcery 工具链交叉编译 Qt 4.6。但是我在 ./configure 步骤中得到以下错误 -
/home/weds/qt-everywhere-opensource-src-4.6.1/bin/qmake: 1: Syntax error: word unexpected (expecting ")")
在互联网上搜索我发现了很多关于这个错误的帖子并阅读了所有这些帖子。 这是什么错误,我该如何解决?
P.S 1 - Sourcery 工具链存在于 /opt/ 文件夹和我的 PATH 变量中正确指向它。
P.S 2 - 这个工具链不是我手动安装的。相反,它是由供应商作为 .tgz 文件提供的,我将其提取到 /opt/ 文件夹中。
99%的情况是文件传输方式错误,ASCII或者二进制。
尝试直接在目标系统上提取工具链。
这是 Almquist shell or any of its derivatives like Dash (and Dash happened to be the default implementation of /bin/sh
on Ubuntu 10.04 (Lucid Lynx)) 在解析 )
相反,例如在这种情况下声明:
dash -c 'case a in b c) :; esac'
dash: 1: Syntax error: word unexpected (expecting ")")
那是因为在 b
之后,唯一期望的是 )
,(尽管实际上 |
也是允许的)所以 c
字是出乎意料。
dash -c 'myfunc( something'
dash: 1: Syntax error: word unexpected (expecting ")")
可能发生这种情况的一种情况是,脚本是在 Microsoft OS 上编写或传输的,其中文本行结尾是 CRLF 而不是 LF。
一个
case a in b) cmd1;;
c) cmd2
esac
在 MS-DOS 上编写的脚本将显示为:
case a in b) cmd1;;<CR>
c) cmd2<CR>
esac<CR>
在 Unix 上,c
将是 <CR>
单词后的额外 单词。
这不太可能,因为您的错误报告问题出现在脚本的第一行,而且大多数脚本都以 #! /path/to/interpreter
shebang 行开头。
另一种可能性是,您尝试 运行 的脚本是在 sh
是 bash
的假设下编写的,并且使用的结构无法移植到其他 sh
实现。
由于您使用的是过时且不再维护的 OS,也有可能您 运行遇到了该版本 Dash 中的错误。您可以 运行 dpkg-reconfigure dash
并告诉系统不要将 Dash 用于 sh
(而是 Bash)以查看是否有帮助。
同样,它不太可能在第一行。
听起来更有可能的是 qmake
文件不是脚本,而是系统无法识别的二进制可执行文件,例如因为它是错误体系结构的二进制格式或者在传输中损坏了。
在那种情况下,当系统无法将其识别为本机可执行文件时,调用应用程序将尝试 运行 sh
就好像它是 shell 脚本一样,并且文件中存在 (
字符可能会导致 Dash 失败并出现此类错误。
在我的系统上:
dash /bin/touch
/bin/touch: 1: /bin/touch: Syntax error: word unexpected (expecting ")")
并且如果您将 /bin/touch
的内容当作脚本来查看,您会看到:
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@>^@^A^@^@^@5&@^@^@^@^@^@@^@^@^@^@^@^@^@(ô^@^@...
这个问题的答案似乎张贴在您链接到的说明中。
诚然这是一个 long way down in the comments 但没多久就搜索到了 qmake: Syntax error: word unexpected
.
引用:
Tej says: January 4, 2013 at 12:20 pm
Ok, I have solved the Problem. Its very unfortunate that ppl did not tell what actually is the problem. Problem is we have to use Host qmake. For that whatever Export (export PATH=/usr/local/arm/4.3.2/bin:$PATH etc.) we did in step during tslib installation, we have to undo all of that. Thats it.
Hope that help someone
如果不清楚,Tej 表明您正在尝试 运行 主机上的交叉编译 qmake
系统.
当这个问题出现时,我正在 Ubuntu 18.04 (Bionic Beaver) 上编写 C++ 程序。原因是程序的文件名中包含字符“(”和“)”。重命名文件后,它对我有用。
对我来说一个奇怪的修复是删除文件 package-lock.json 和 node_modules 文件夹,以及然后再次构建 Docker 图像。
有时出现此错误只是因为您当前工作的目录有“错误的命名约定” .. 可能是
- demo_project(复制)
- my_project_1(另一份)
正确的命名约定是
1。 demo_project_copy
2。 my_project_1_another_copy