我正在写一个如下的类:
genrule(
name = "create_run_script",
outs = ["run_script.sh"],
executable = True,
cmd = """
cat > $@ << EOF
#!/bin/bash
cd ../dir/
exec ./program "$$@"
EOF
""",
)
当我执行此操作时,我看到了输出
# @external_repo//:create_run_script [action 'Executing genrule @ external_repo//:create_run_script']
(cd /home/marc/.cache/bazel/_bazel_marc/0877f3fef7c185b84693d3a53e00a8be/execroot/zoox && \
exec env - \
FLAGS_minloglevel=1 \
LD_LIBRARY_PATH='' \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
/bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh;
cat > bazel-out/k8-fastbuild/bin/external/external_repo/run_script.sh << EOF
#!/bin/bash
cd ../external_repo/
exec ./program "$@"
EOF
')
但是,当我打开实际的 shell 脚本文件时,我看到
#!/bin/bash
cd ../external_repo/
exec ./program ""
EOF
$@ 符号不再存在!如何使用 Bazel genrule 指令创建一个可以接收来自 shell 的输入的 shell 脚本?