Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions actions/setup-cli/install.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions actions/setup-cli/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ test_version_mismatch_detection() {
fi
}

# Test 8: Verify no-color gate for CI environments
test_no_color_gate() {
echo ""
echo "Test 8: Verify no-color gate"

if grep -q 'NO_COLOR+set' "$SCRIPT_PATH" && \
grep -q 'RED=""' "$SCRIPT_PATH"; then
print_result "No-color gate present and spec-compliant" "PASS"
else
print_result "No-color gate missing or not spec-compliant" "FAIL"
fi
}

# Run all tests
echo "========================================="
echo "Testing setup-cli action install.sh"
Expand All @@ -137,6 +150,7 @@ test_gh_install
test_version_pinning
test_checksum_validation
test_version_mismatch_detection
test_no_color_gate

# Summary
echo ""
Expand Down
12 changes: 12 additions & 0 deletions install-gh-aw.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set +o histexpand

# Kept in sync with actions/setup-cli/install.sh — edit this file, then copy to that path.

# Script to download and install gh-aw binary for the current OS and architecture
# Supports: Linux, macOS (Darwin), FreeBSD, Windows (Git Bash/MSYS/Cygwin)
Expand Down Expand Up @@ -54,6 +55,17 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Disable colors when output is captured or color is explicitly disabled.
# NO_COLOR is the no-color.org standard; NO_COLORS covers tools that use the non-standard variant.
# Per the spec, NO_COLOR disables colors even when set to an empty string, so we test with +set.
if [ -n "${CI:-}" ] || [ "${NO_COLOR+set}" = "set" ] || [ "${NO_COLORS+set}" = "set" ] || [ ! -t 1 ] || [ "${TERM:-}" = "dumb" ]; then
RED=""

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.

NO_COLOR empty-string edge case violates the no-color.org spec: [ -n "${NO_COLOR:-}" ] only disables colors when NO_COLOR is non-empty, but the spec says colors must be suppressed whenever the variable is set, even if set to an empty string.

💡 Suggested fix

Replace the NO_COLOR and NO_COLORS checks with parameter-set tests:

if [ -n "${CI:-}" ] || [ "${NO_COLOR+set}" = "set" ] || [ "${NO_COLORS+set}" = "set" ] || [ ! -t 1 ] || [ "${TERM:-}" = "dumb" ]; then

${NO_COLOR+set} expands to set if the variable is defined at all (even as empty), and to empty string if unset — exactly what the spec requires. [ -n "${NO_COLOR:-}" ] by contrast silently treats export NO_COLOR="" the same as unset, leaving colors enabled.

The same fix applies to actions/setup-cli/install.sh line 60 (identical change).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d3abcff. Both install-gh-aw.sh and actions/setup-cli/install.sh now use [ "${NO_COLOR+set}" = "set" ] and [ "${NO_COLORS+set}" = "set" ] so colors are suppressed even when the variables are set to an empty string.

GREEN=""
YELLOW=""
BLUE=""
NC=""
fi

# Function to print colored output
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
Expand Down
11 changes: 11 additions & 0 deletions scripts/test-install-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,16 @@ else
exit 1
fi

# Test 12: Verify no-color gate for CI environments
echo ""
echo "Test 12: Verify no-color gate"
if grep -q 'NO_COLOR+set' "$PROJECT_ROOT/install-gh-aw.sh" && \
grep -q 'RED=""' "$PROJECT_ROOT/install-gh-aw.sh"; then
echo " ✓ PASS: No-color gate present and spec-compliant"
else
echo " ✗ FAIL: No-color gate missing or not spec-compliant"
exit 1
fi

echo ""
echo "=== All tests passed ==="
Loading