Skip to content

Commit

Permalink
Merge changes in bash scripts which prevent some globbing and wordspl…
Browse files Browse the repository at this point in the history
…itting issues critized by shellchecked

This changes mostly lines which `shellchecked` has warnings for.
Also changes the typical /bin/bash shebang to /usr/bin/env bash since NixOs can't deal with that and the pinning is
partially questionable if python is invoked directly afterwards.

Related PR: #1016
  • Loading branch information
keldu authored Aug 4, 2022
2 parents fb1672d + ef18496 commit 396c6c0
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .github/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ if [[ "$LIST_FILES" != "" ]]; then
git commit -a -m "Format files
Co-authored-by: $USER_COMBINED"
git push fork $LOCAL_BRANCH:$HEAD_BRANCH 2>&1 || bot_error "Cannot push formatted branch, are edits for maintainers allowed?"
git push fork "$LOCAL_BRANCH:$HEAD_BRANCH" 2>&1 || bot_error "Cannot push formatted branch, are edits for maintainers allowed?"
fi
2 changes: 1 addition & 1 deletion .github/label.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source .github/bot-pr-base.sh

echo "Retrieving PR file list"
PR_FILES=$(bot_get_all_changed_files ${PR_URL})
PR_FILES=$(bot_get_all_changed_files "${PR_URL}")
NUM=$(echo "${PR_FILES}" | wc -l)
echo "PR has ${NUM} changed files"

Expand Down
12 changes: 6 additions & 6 deletions .github/rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ source .github/bot-pr-base.sh
git remote add base "$BASE_URL"
git remote add fork "$HEAD_URL"

git fetch base $BASE_BRANCH
git fetch fork $HEAD_BRANCH
git fetch base "$BASE_BRANCH"
git fetch fork "$HEAD_BRANCH"

git config user.email "$USER_EMAIL"
git config user.name "$USER_NAME"

LOCAL_BRANCH=rebase-tmp-$HEAD_BRANCH
git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH
LOCAL_BRANCH="rebase-tmp-$HEAD_BRANCH"
git checkout -b "$LOCAL_BRANCH" "fork/$HEAD_BRANCH"

bot_delete_comments_matching "Error: Rebase failed"

# do the rebase
git rebase base/$BASE_BRANCH 2>&1 || bot_error "Rebase failed, see the related [Action]($JOB_URL) for details"
git rebase "base/$BASE_BRANCH" 2>&1 || bot_error "Rebase failed, see the related [Action]($JOB_URL) for details"

# push back
git push --force-with-lease fork $LOCAL_BRANCH:$HEAD_BRANCH 2>&1 || bot_error "Cannot push rebased branch, are edits for maintainers allowed, or were changes pushed while the rebase was running?"
git push --force-with-lease fork "$LOCAL_BRANCH:$HEAD_BRANCH" 2>&1 || bot_error "Cannot push rebased branch, are edits for maintainers allowed, or were changes pushed while the rebase was running?"
2 changes: 1 addition & 1 deletion dev_tools/oneapi/add_host_function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ while IFS='' read -r line || [ -n "$line" ]; do
TEMPLATE_CONTENT="${BASH_REMATCH[2]}"
NAME="${BASH_REMATCH[3]}"
VARIABLE="${BASH_REMATCH[4]}"
VARIABLE=$(echo ${VARIABLE} | sed 's/__restrict__ //g')
VARIABLE=$(echo "${VARIABLE}" | sed 's/__restrict__ //g')
VAR_INPUT=$(extract_varname "${VARIABLE}")
TEMPLATE_INPUT=$(extract_varname "${TEMPLATE_CONTENT}")
if [ -n "${TEMPLATE_INPUT}" ]; then
Expand Down
4 changes: 2 additions & 2 deletions dev_tools/oneapi/convert_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ done < "${UNFORMAT_FILE}"
${CLANG_FORMAT} -style=file "${EMBED_FILE}" > "${FORMAT_FILE}"

# Add an extra host function so that the converted DPC++ code will look like CUDA.
${SCRIPT_DIR}/add_host_function.sh "${FORMAT_FILE}" > "${EMBED_HOST_FILE}"
"${SCRIPT_DIR}/add_host_function.sh" "${FORMAT_FILE}" > "${EMBED_HOST_FILE}"

while IFS='' read -r line; do
if [[ "${line}" =~ ${KERNEL_SYNTAX_START} ]] || [[ "${IN_SYNTAX}" = "true" ]]; then
Expand Down Expand Up @@ -365,7 +365,7 @@ if [ "${EXTRACT_KERNEL}" = "true" ]; then
dpct_device_path=$(echo "${variable}" | sed 's/common/dpcpp_code/g')
dpct_device_file=$(echo "${dpct_device_path}" | sed 's|/|@|g')
dpct_device_file="output/${dpct_device_file}"
cat ${dpct_file} | sed -n "/${device_regex} - start/,/${device_regex} - end/p" | sed "1d;\$d" > ${dpct_device_file}
cat "${dpct_file}" | sed -n "/${device_regex} - start/,/${device_regex} - end/p" | sed "1d;\$d" > "${dpct_device_file}"
sed -i "/${device_regex} - start/,/${device_regex} - end/d;s~// *#include \"${device_regex}\"~#include \"${dpct_device_path}\"~g" ${dpct_file}
dpct_dir=$(dirname "${dpct_device_path}")
mkdir -p "${ROOT_DIR}/${dpct_dir}"
Expand Down
18 changes: 6 additions & 12 deletions dev_tools/scripts/add_license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,27 @@ COMMENTED_LICENSE_FILE="${THIS_DIR}/commented_license.tmp"
DIFF_FILE="${THIS_DIR}/diff.patch.tmp"

# Test if required commands are present on the system:
command -v find &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v find &> /dev/null; then
echo 'The command `find` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
command -v diff &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v diff &> /dev/null; then
echo 'The command `diff` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
command -v patch &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v patch &> /dev/null; then
echo 'The command `patch` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
command -v grep &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v grep &> /dev/null; then
echo 'The command `grep` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
command -v sed &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v sed &> /dev/null; then
echo 'The command `sed` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
command -v cut &> /dev/null
if [ ${?} -ne 0 ]; then
if ! command -v cut &> /dev/null; then
echo 'The command `cut` is required for this script to work, but not supported by your system.' 1>&2
exit 1
fi
Expand Down
Loading

0 comments on commit 396c6c0

Please sign in to comment.