我正在尝试使用Docker来运行shell脚本。这是我的Dockerfile:
FROM alpine
COPY . .
RUN chmod +x ./scripts/sanity-checks.sh
ENTRYPOINT ["./scripts/sanity-checks.sh"]
然而,当我尝试运行它时,我会得到以下错误:
./scripts/sanity-checks.sh: scripts/util.sh: line 225: syntax error: unexpected "(" (expecting "}")
这就是我在util.sh:中的内容
...
# delete the lines between and including 2 comment lines, or the comment lines themselves only
delete_lines_for_file() {
file_name=$1
delete_string_start=$2
delete_string_end=$3
delete_comments_only=$4
# find the start and end lines where we want to delete blocks of code
line_num_start=$(grep -n "$delete_string_start" $file_name | awk -F ":" '{print $1}')
line_num_end=$(grep -n "$delete_string_end" $file_name | awk -F ":" '{print $1}')
line_start_arr=($line_num_start) ### LINE 225 ###
...
当我在不使用Docker的情况下运行脚本时,它运行得很好。知道是什么导致了这个错误吗?
FROM alpine
不会为您提供bash或任何其他支持数组的shell的副本。
如果你想使用阵列,你需要安装并使用一个支持它们的shell。