Skip to content

Commit dfe1342

Browse files
hack: fix unquoted variables in hack scripts to prevent word-splitting
- generate-yamls.sh: quote YAML_OUTPUT_DIR in rm command - release.sh: quote dirname substitution, REPO_ROOT_DIR in cp, and $@ - verify-codegen.sh: quote REPO_ROOT_DIR inside mktemp call Unquoted variable expansions and command substitutions break when paths contain whitespace. Closes knative#8990 Closes knative#8992 Closes knative#9004
1 parent c6be563 commit dfe1342

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

hack/generate-yamls.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ readonly YAML_LIST_FILE=${2:?"Second argument must be the output file"}
4545
if [[ -z "${YAML_OUTPUT_DIR:-}" ]]; then
4646
readonly YAML_OUTPUT_DIR="$(mktemp -d)"
4747
fi
48-
rm -fr ${YAML_OUTPUT_DIR}/*.yaml
48+
rm -fr "${YAML_OUTPUT_DIR}"/*.yaml
4949

5050
# Generated Knative component YAML files
5151
readonly EVENTING_CORE_YAML=${YAML_OUTPUT_DIR}/"eventing-core.yaml"

hack/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ function build_release() {
6565
# branch since the detail of building may change over time.
6666
local YAML_LIST="$(mktemp)"
6767
export TAG
68-
$(dirname $0)/generate-yamls.sh "${REPO_ROOT_DIR}" "${YAML_LIST}"
68+
"$(dirname "$0")/generate-yamls.sh" "${REPO_ROOT_DIR}" "${YAML_LIST}"
6969
ARTIFACTS_TO_PUBLISH=$(cat "${YAML_LIST}" | tr '\n' ' ')
7070
if (( ! PUBLISH_RELEASE )); then
7171
# Copy the generated YAML files to the repo root dir if not publishing.
72-
cp ${ARTIFACTS_TO_PUBLISH} ${REPO_ROOT_DIR}
72+
cp "${ARTIFACTS_TO_PUBLISH}" "${REPO_ROOT_DIR}"
7373
fi
7474
}
7575

76-
main $@
76+
main "$@"

hack/verify-codegen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export GO111MODULE=on
2222

2323
source $(dirname $0)/../vendor/knative.dev/hack/library.sh
2424

25-
readonly TMP_DIFFROOT="$(mktemp -d ${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX)"
25+
readonly TMP_DIFFROOT="$(mktemp -d "${REPO_ROOT_DIR}/tmpdiffroot.XXXXXX")"
2626

2727
cleanup() {
2828
rm -rf "${TMP_DIFFROOT}"

0 commit comments

Comments
 (0)