-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add shellcheck to pre-commit and fix warnings #1788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
# Copyright (c) 2024-2025, NVIDIA CORPORATION. | ||
######################## | ||
# RMM Version Updater # | ||
######################## | ||
|
@@ -13,14 +13,10 @@ NEXT_FULL_TAG=$1 | |
|
||
# Get current version | ||
CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') | ||
CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}') | ||
CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}') | ||
CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}') | ||
CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} | ||
Comment on lines
-16
to
-19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These variables are used in a few rapids projects ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a lot of discrepancies in the In the meantime, I am okay with removing unused variables. |
||
|
||
# Get <major>.<minor> for next version | ||
NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}') | ||
NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') | ||
NEXT_MAJOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[1]}') | ||
NEXT_MINOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[2]}') | ||
NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} | ||
|
||
# Need to distutils-normalize the original version | ||
|
@@ -30,7 +26,7 @@ echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG" | |
|
||
# Inplace sed replace; workaround for Linux and Mac | ||
function sed_runner() { | ||
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak | ||
sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak | ||
} | ||
|
||
# Centralized version file update | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like this style because it requires two lines where only one was used before.
export VAR="value"
seems like a very common and well-understood pattern in shell scripts. Is there a justification for why this is better practice?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing it as a single line masks the return value of the captured command. so if the captured command fails, even with
set -e
, the script won't fail because the export still succeeds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! I need to read the shellcheck docs, probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bash
is a gnarly language. footguns all the way down