From 7eee4e430c15628cdc61f24a45399d6aecea1219 Mon Sep 17 00:00:00 2001 From: ethan Date: Thu, 16 Apr 2026 21:35:29 +0200 Subject: [PATCH 1/2] fix(setup-fork): set count to 0 if it is non numeric --- docs/contribution/setup-fork.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/contribution/setup-fork.sh b/docs/contribution/setup-fork.sh index f068aeef..951759f7 100644 --- a/docs/contribution/setup-fork.sh +++ b/docs/contribution/setup-fork.sh @@ -124,6 +124,11 @@ update_links() { # Count occurrences of the old repo URL local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0) + # Set to 0 if count is non numeric + if ! [ "$count" -eq "$count" ] 2>/dev/null; then + count=0 + fi + if [[ $count -gt 0 ]]; then # Replace all variations of the URL sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file" @@ -140,6 +145,11 @@ update_links() { if [[ -f "$file" ]]; then local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0) + # Set to 0 if count is non numeric + if ! [ "$count" -eq "$count" ] 2>/dev/null; then + count=0 + fi + if [[ $count -gt 0 ]]; then sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file" sed -i "s|raw.githubusercontent.com/$old_repo/$old_name|raw.githubusercontent.com/$new_owner/$new_repo|g" "$file" From 321631aa2efb361b0d2e3e668406a09aa9ee0761 Mon Sep 17 00:00:00 2001 From: ethan Date: Thu, 16 Apr 2026 22:57:31 +0200 Subject: [PATCH 2/2] refactor(setup-fork): check if count is a number with regex --- docs/contribution/setup-fork.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/contribution/setup-fork.sh b/docs/contribution/setup-fork.sh index 951759f7..cfd01d32 100644 --- a/docs/contribution/setup-fork.sh +++ b/docs/contribution/setup-fork.sh @@ -125,7 +125,7 @@ update_links() { local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0) # Set to 0 if count is non numeric - if ! [ "$count" -eq "$count" ] 2>/dev/null; then + if ! [[ "$count" =~ ^[0-9]+$ ]]; then count=0 fi @@ -146,10 +146,10 @@ update_links() { local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0) # Set to 0 if count is non numeric - if ! [ "$count" -eq "$count" ] 2>/dev/null; then + if ! [[ "$count" =~ ^[0-9]+$ ]]; then count=0 fi - + if [[ $count -gt 0 ]]; then sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file" sed -i "s|raw.githubusercontent.com/$old_repo/$old_name|raw.githubusercontent.com/$new_owner/$new_repo|g" "$file"