Skip to content

fix(e2e): replace bash-specific [[ with POSIX [ for OSTYPE check#288

Open
whg517 wants to merge 1 commit into
zncdatadev:mainfrom
whg517:fix/posix-sh-compat-in-e2e-tests
Open

fix(e2e): replace bash-specific [[ with POSIX [ for OSTYPE check#288
whg517 wants to merge 1 commit into
zncdatadev:mainfrom
whg517:fix/posix-sh-compat-in-e2e-tests

Conversation

@whg517
Copy link
Copy Markdown
Member

@whg517 whg517 commented May 14, 2026

Chainsaw uses /usr/bin/sh (dash). Replace [[ with [ and == with = for OSTYPE detection.

Chainsaw executes scripts with /usr/bin/sh (dash on Ubuntu), which does
not support [[ or ==. Also add linux-musl (Alpine) variant.
Copilot AI review requested due to automatic review settings May 14, 2026 03:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates a Chainsaw E2E test script to avoid bash-specific conditional syntax so it can run under /bin/sh (dash), specifically for choosing the correct date invocation on different OSes.

Changes:

  • Replaces [[ ... ]] with POSIX [ tests.
  • Replaces bash pattern matching (darwin*, linux-gnu*) with equality checks for OSTYPE values.
Comments suppressed due to low confidence (1)

test/e2e/chainsaw/pod-expires/chainsaw-test.yaml:24

  • The new checks use exact string equality (e.g., OSTYPE = darwin / linux-gnu) but OSTYPE commonly includes suffixes (e.g., darwin20.0, linux-gnu with additional qualifiers), which the previous darwin* / linux-gnu* pattern handled. If you keep using OSTYPE, use a POSIX pattern match via case (or another portable approach) so macOS/Linux variants still match.
          if [ "$OSTYPE" = "linux-gnu" ] || [ "$OSTYPE" = "linux-musl" ]; then
            NOW_AFTER_5s=$(date -d "+5 seconds" -u +"%Y-%m-%dT%H:%M:%SZ")
          elif [ "$OSTYPE" = "darwin" ]; then
            NOW_AFTER_5s=$(date -v+5S -u +"%Y-%m-%dT%H:%M:%SZ")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to 25
if [ "$OSTYPE" = "linux-gnu" ] || [ "$OSTYPE" = "linux-musl" ]; then
NOW_AFTER_5s=$(date -d "+5 seconds" -u +"%Y-%m-%dT%H:%M:%SZ")
elif [[ "$OSTYPE" == "darwin"* ]]; then
elif [ "$OSTYPE" = "darwin" ]; then
NOW_AFTER_5s=$(date -v+5S -u +"%Y-%m-%dT%H:%M:%SZ")
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants