bash语法错误报告格式(基本)

发布于 2025-01-01 08:36:57 字数 711 浏览 0 评论 0原文

对于 shell 脚本来说是新手,我注意到意外标记的语法错误报告的格式为

`unexpectedtoken' # ie backtick unexpected_token singlequote

What do the backtick and the single quote indicates?它们不存在于脚本本身中。 它们与外壳有关,但是什么呢?

更具体地说,我目前从同一行收到两个错误报告,这应该有助于我的调试尝试,但我不知道如何解释它们。该脚本有一个参数传递给函数。

append2file \
"(common params for all samples; exemplar: ${monoArr2[@]:(-1)})" 

参数行(第 154 行)上的第一个括号是意外标记。这还会触发第二个错误报告。

./process_v7.sh: line 154: syntax error near unexpected token `('
./process_v7.sh: line 154: `        "(common params for all read_2 samples; exemplar: ${monoArr2[@]:(-1)})" \'

前导反引号和双引号字符串开头之间的间距一定告诉我一些有助于我调试的信息,但是什么??? TIA

M

Newish to shell scripting I've noticed that the syntax error report for an unexpected token has the format

`unexpectedtoken' # ie backtick unexpected_token singlequote

What do the backtick and the single quote represent? They're not present in the script itself.
They're something to do with the shell, but what?

More specifically, I'm currently getting two error reports from the same line, which should be helping my debug attempts but I don't know how to interpret them. The script has a param being passed to a function.

append2file \
"(common params for all samples; exemplar: ${monoArr2[@]:(-1)})" 

The first paren on the param line (line154) is the unexpected token. This also triggers a second error report.

./process_v7.sh: line 154: syntax error near unexpected token `('
./process_v7.sh: line 154: `        "(common params for all read_2 samples; exemplar: ${monoArr2[@]:(-1)})" \'

The spacing between the leading backtick and the start of that double-quoted string must be telling me something that will help my debugging, but what??? TIA

M

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月隐月明月朦胧 2025-01-08 08:36:57

定义函数的语法是:

append2file() {
   # some code that references parameters via $1, $*, $@, etc
}

听起来你在 () 里面放了一些东西。不要那样做。

The syntax for defining a function is:

append2file() {
   # some code that references parameters via $1, $*, $@, etc
}

It sounds like you are putting something inside the (). Don't do that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文