Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions update_execution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ function selectCustomTag(){
error "❌ Unsupported or unknown client '$EL'."
;;
esac
local _listTags _tag
_listTags=$(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -hr)
if [ -z "$_listTags" ]; then
local _tag
# Create array from tags, using mapfile for proper handling
mapfile -t _listTags < <(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -V | tac)
Comment on lines +59 to +61
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

_listTags leaks to global scope — add local -a _listTags.

The original code had local _listTags _tag together. The new code only declares local _tag, so mapfile writes _listTags into the global scope. Any code that runs after selectCustomTag returns will see a stale _listTags array. Fix by declaring it local before the mapfile call:

🛠️ Proposed fix
-	local _tag
-	# Create array from tags, using mapfile for proper handling
-	mapfile -t _listTags < <(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -V | tac)
+	local _tag
+	local -a _listTags
+	# Create array from tags, using mapfile for proper handling
+	mapfile -t _listTags < <(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -V | tac)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
local _tag
# Create array from tags, using mapfile for proper handling
mapfile -t _listTags < <(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -V | tac)
local _tag
local -a _listTags
# Create array from tags, using mapfile for proper handling
mapfile -t _listTags < <(curl -fsSL https://api.github.com/repos/"${_repo}"/tags | jq -r '.[].name' | sort -V | tac)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@update_execution.sh` around lines 59 - 61, The _listTags array is
accidentally global because only _tag is declared local; make _listTags local
(as an array) before the mapfile call so it doesn't leak scope. Update the
selectCustomTag function to declare local -a _listTags (and keep local _tag)
prior to the mapfile -t _listTags < <(... ) invocation so the array is confined
to the function.


if [ -z "${_listTags[0]}" ]; then
error "❌ Could not retrieve tags for ${_repo}. Try again later."
fi
info "ℹ️ Select the Version: Type the number to use. For example, 2 (for the 2nd most recent release)"
select _tag in $_listTags; do
select _tag in "${_listTags[@]}"; do
if [ -n "$_tag" ]; then
__OTHERTAG=$_tag
break
Expand Down