refactor(setup-fork): check if count is a number with regex
This commit is contained in:
@@ -125,7 +125,7 @@ update_links() {
|
|||||||
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
||||||
|
|
||||||
# Set to 0 if count is non numeric
|
# Set to 0 if count is non numeric
|
||||||
if ! [ "$count" -eq "$count" ] 2>/dev/null; then
|
if ! [[ "$count" =~ ^[0-9]+$ ]]; then
|
||||||
count=0
|
count=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -146,10 +146,10 @@ update_links() {
|
|||||||
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
||||||
|
|
||||||
# Set to 0 if count is non numeric
|
# Set to 0 if count is non numeric
|
||||||
if ! [ "$count" -eq "$count" ] 2>/dev/null; then
|
if ! [[ "$count" =~ ^[0-9]+$ ]]; then
|
||||||
count=0
|
count=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $count -gt 0 ]]; then
|
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|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"
|
sed -i "s|raw.githubusercontent.com/$old_repo/$old_name|raw.githubusercontent.com/$new_owner/$new_repo|g" "$file"
|
||||||
|
|||||||
Reference in New Issue
Block a user