feat: accept message body via --file or stdin for send/edit#11
Merged
Conversation
`message send`/`message edit` previously required the body as a positional
shell argument. For formatted Slack mrkdwn this is a footgun: in a
double-quoted argument the shell interprets backticks, `$`, and quotes before
slack-cli sees them, so e.g. `` `org-slug` `` is run as a command and silently
dropped from the message (and emits a "command not found" to stderr) while the
send still "succeeds" with corrupted text.
Add a `--file <path>` flag ('-' means stdin) and implicit piped-stdin support
to both commands. Body resolution precedence: --file, positional text, then
piped stdin. The positional arg stays optional and fully backward compatible.
A quoted heredoc (`- <<'EOF'`) now lets callers send arbitrary formatted bodies
with zero shell interpretation. Interactive stdin (a TTY) with no body returns
a clear error instead of hanging.
Docs updated in SLACK_CLI_USAGE.md with the hazard note and new usage.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
message send/message editonly accept the message body as a positional shell argument. For formatted Slack mrkdwn this is a footgun: in a double-quoted shell argument the shell performs backtick command substitution and$/quote expansion beforeslack-cliever sees the text.A real example that bit an agent: a body containing
(`smithrx`)was sent as a double-quoted argument. The shell ransmithrxas a command (smithrx: command not foundto stderr), the substitution evaluated to empty, and the message went out asSmithRx ()— corrupted but with a successfults, so the failure was silent.Single-quoting only half-fixes it: single quotes can't contain a literal
', which Slack alerts routinely include.Fix
Add a
--file <path>flag (-means stdin) plus implicit piped-stdin support to bothsendandedit. Body resolution precedence:--file(-= stdin)textargument (unchanged — fully backward compatible)A quoted heredoc now sends arbitrary formatted bodies with zero shell interpretation:
Interactive stdin (a TTY) with no body returns a clear error instead of hanging.
Testing
go build ./...+go vet ./...cleanno message bodyerror (no hang)'quotes'/$HOME→ passes body resolution untouched, only fails at the (fake) auth call--file <bad path>→ clear read erroredit --file/ stdin → worksDocs
SLACK_CLI_USAGE.mdupdated with the hazard note and--file/stdin usage for both commands.🤖 Generated with Claude Code