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