From e82de4ea125e4ff82490d9ab5f50ae8ff9420191 Mon Sep 17 00:00:00 2001 From: reynold Date: Thu, 28 Aug 2025 18:59:00 +0800 Subject: [PATCH] Fix sf-org-info array handling for bash strict mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 Fixed Critical Issue: - Resolved 'unbound variable' error with cmd_args[@] in strict mode - Used expansion for safe array handling - Now works correctly with 'set -euo pipefail' ✅ Verified Working: - sf-org-info -l: Lists all authenticated orgs - sf-org-info -o ORG: Shows specific org information - sf-org-info -o ORG -v: Shows detailed org limits and info - Default org fallback when no org specified The script now works reliably with proper error handling and strict bash mode. --- sf-org-info | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sf-org-info b/sf-org-info index 19336f3..f97a3a5 100755 --- a/sf-org-info +++ b/sf-org-info @@ -109,10 +109,10 @@ show_org_info() { echo "=======================================" # Get basic org info - if sf org display "${cmd_args[@]}" --json >/dev/null 2>&1; then + if sf org display ${cmd_args[@]:+"${cmd_args[@]}"} --json >/dev/null 2>&1; then echo echo "📊 Basic Information:" - sf org display "${cmd_args[@]}" 2>/dev/null || { + sf org display ${cmd_args[@]:+"${cmd_args[@]}"} 2>/dev/null || { echo "❌ Unable to retrieve org information" return 1 } @@ -127,8 +127,8 @@ show_org_info() { echo echo "📈 Org Limits:" echo "-------------" - if sf org list limits "${cmd_args[@]}" >/dev/null 2>&1; then - sf org list limits "${cmd_args[@]}" 2>/dev/null | head -20 || echo "Unable to retrieve org limits" + if sf org list limits ${cmd_args[@]:+"${cmd_args[@]}"} >/dev/null 2>&1; then + sf org list limits ${cmd_args[@]:+"${cmd_args[@]}"} 2>/dev/null | head -20 || echo "Unable to retrieve org limits" else echo "Unable to retrieve org limits" fi @@ -136,8 +136,8 @@ show_org_info() { echo echo "⚙️ Org Shape (if available):" echo "-----------------------------" - if sf org list shape "${cmd_args[@]}" >/dev/null 2>&1; then - sf org list shape "${cmd_args[@]}" 2>/dev/null || echo "No org shapes available" + if sf org list shape ${cmd_args[@]:+"${cmd_args[@]}"} >/dev/null 2>&1; then + sf org list shape ${cmd_args[@]:+"${cmd_args[@]}"} 2>/dev/null || echo "No org shapes available" else echo "No org shapes available" fi