From e22601b31c55d7868d4c4f37f06c0470d8f7bbba Mon Sep 17 00:00:00 2001 From: kpenfound Date: Wed, 4 Mar 2026 11:07:10 -0800 Subject: [PATCH] handle multi-line dagger shell blocks Signed-off-by: kpenfound --- .github/workflows/test.yml | 52 ++++++++++++++++++++++++++++++++++++++ action.yml | 9 ++++--- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d196fd..583fb2c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -236,6 +236,58 @@ jobs: exit 1 fi + call-multiline-backslash: + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v4 + - name: "Test call with backslash continuation" + id: test-call-backslash + uses: ./ + with: + version: latest + verb: core + args: |- + container \ + from --address=alpine \ + with-exec --args echo,-n,"hello world" \ + stdout + - name: "Test call backslash (check)" + run: | + target='${{ steps.test-call-backslash.outputs.output }}' + if [[ "$target" == "hello world" ]]; then + echo "matches" + exit 0 + else + echo "does not match: $target" + exit 1 + fi + + call-multiline-newline: + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v4 + - name: "Test call with bare newlines" + id: test-call-newline + uses: ./ + with: + version: latest + verb: core + args: |- + container + from --address=alpine + with-exec --args echo,-n,"hello world" + stdout + - name: "Test call newline (check)" + run: | + target='${{ steps.test-call-newline.outputs.output }}' + if [[ "$target" == "hello world" ]]; then + echo "matches" + exit 0 + else + echo "does not match: $target" + exit 1 + fi + check: runs-on: "ubuntu-latest" steps: diff --git a/action.yml b/action.yml index 9434161..b72e309 100644 --- a/action.yml +++ b/action.yml @@ -133,10 +133,11 @@ runs: run: | verb=${{ inputs.verb }} shell=$(echo '${{ toJSON(inputs.shell) }}' | jq -rj .) - dagger_flags=$(echo '${{ toJSON(inputs.dagger-flags) }}' | jq -rj .) - args=$(echo '${{ toJSON(inputs.args) }}' | jq -rj .) - call=$(echo '${{ toJSON(inputs.call) }}' | jq -rj .) - check=$(echo '${{ toJSON(inputs.check) }}' | jq -rj .) + # Collapse backslash-continuations and newlines into spaces for CLI args + dagger_flags=$(echo '${{ toJSON(inputs.dagger-flags) }}' | jq -rj . | sed -z 's/\\\n/ /g; s/\n/ /g') + args=$(echo '${{ toJSON(inputs.args) }}' | jq -rj . | sed -z 's/\\\n/ /g; s/\n/ /g') + call=$(echo '${{ toJSON(inputs.call) }}' | jq -rj . | sed -z 's/\\\n/ /g; s/\n/ /g') + check=$(echo '${{ toJSON(inputs.check) }}' | jq -rj . | sed -z 's/\\\n/ /g; s/\n/ /g') if [[ -n "${{ inputs.call }}" ]]; then verb="call" elif [[ -n "$check" ]]; then