Skip to content

--input-file does not accept '-' for stdin; breaks Unix convention #335

@MattDevy

Description

@MattDevy

Summary

--input-file - is rejected with file not found: - instead of being read from stdin. The - filename convention for stdin is broadly expected across Unix tools (curl --data-binary @-, kubectl apply -f -, jq, cat, etc.), and works around the lack of body-field flags on commands like cloud serverless projects search create (filed separately as #328).

--input-file is on most mutating commands and all the helpers (es bulk, es search, es helpers bulk-ingest, es helpers scroll-search, kb saved-objects post-saved-objects-import, cloud serverless projects search create, ...), so this affects a wide surface.

Reproducer

$ elastic version
{"version": "0.1.1"}

$ echo '{"name":"x","region_id":"aws-us-east-1"}' \
    | elastic cloud serverless projects search create --input-file - --dry-run
Error: --input-file: file not found: -

Usage: elastic cloud serverless projects search create [options]
...

Process substitution works as a current workaround:

$ elastic cloud serverless projects search create \
    --input-file <(echo '{"name":"x","region_id":"aws-us-east-1"}') --dry-run
dry run: inputs valid, no action performed

But that's bash/zsh-specific and unfamiliar to many users; the - convention is what most reach for first.

Expected behavior

When --input-file - is supplied, read the body from stdin until EOF. This matches the convention used by curl, kubectl, jq, pass, and most other Unix tools that take --input-file / -f / --data.

Applying the change once in the shared input-file resolver should make every command that accepts --input-file benefit, without per-command work.

Environment

  • elastic v0.1.1 on macOS

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request
No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions