gpt4 book ai didi

linux - 在 Eclipse 中设置 bash 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 11:06:45 25 4
gpt4 key购买 nike

我有一个 bash 脚本 .sh 需要在 Eclipse 中作为 Target Simulator 执行。问题是,如果我在终端中使用 sh run.sh 命令运行脚本,它会抛出 Bad Substitution 错误。但它与 bash run.sh 完美配合。显然,Eclipse 使用 sh 命令运行它导致它在控制台中给出相同的错误。但是我怎样才能使 Eclipse 改为使用 bash 运行脚本呢?

我在 Ubuntu 13.10 上。

Shot

最佳答案

bashsh 不是同一个 shell。有许多在 bash 中有效但 sh 无法理解的结构。

您是否提供了正确的 sheebang 作为脚本的第一行?

#!/bin/bash

如果是这样——并且如果 Eclipse 坚持使用 sh 运行脚本,您仍然可以选择将脚本包装在 heredoc 中并将其显式传递给 bash:

sh$ cat run.sh
bash << EOF

#
# Here is your bash script
#

EOF

在您找到如何指示 Eclipse 使用正确的 shell 之前,这主要是一个 hack。我相信有办法!

关于linux - 在 Eclipse 中设置 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24963960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com