README says secret add drops one trailing newline and import keeps it (closes #158)
check / check (push) Waiting to run
check / check (push) Waiting to run
`secret add` drops one trailing newline from stdin, so `echo value | secret add name` stores `value`. `secret import` stores a file's bytes unchanged, and `secret get` writes the value with no newline added. The README said none of this, so a PEM key piped into `add` came back one byte short with no hint why. Its entries for `add`, `get` and `import` now state each rule. A new test stores `a\n\n` through `add` and through `import` and checks that `add` kept two bytes and `import` three. No program code changes. The new test passes on the code before this change; it fails when `add` keeps the newline. Model: opus-5-5
This commit was merged in pull request #184.
This commit is contained in:
@@ -142,7 +142,11 @@ value may be over 100 MiB, whatever the limit.
|
||||
|
||||
#### `secret add <secret-name> [--force]`
|
||||
|
||||
Adds a secret to the current vault. Reads the secret value from stdin.
|
||||
Adds a secret to the current vault. Reads the secret value from stdin. When the
|
||||
value ends in a newline, that one newline is dropped, so
|
||||
`echo value | secret add name` stores `value`; from `printf 'a\n\n'` it stores
|
||||
`a` and one newline. To keep a file's final newline, as in a PEM key, use
|
||||
`secret import`, which stores the file's bytes unchanged.
|
||||
|
||||
- `--force, -f`: Overwrite existing secret
|
||||
|
||||
@@ -155,13 +159,13 @@ contain `//`, or have `..` as a path segment.
|
||||
|
||||
#### `secret get <secret-name> [--version <version>]`
|
||||
|
||||
Retrieves and outputs a secret value to stdout. A failed write of the value,
|
||||
such as to a file on a full disk, prints the error and exits 1, with two
|
||||
exceptions. If the program reading from a pipe has already exited, as in
|
||||
`secret get s | true`, the broken-pipe signal (SIGPIPE) ends `secret` with no
|
||||
message and the shell reports exit status 141. If the shell closed stdout before
|
||||
`secret` started (`secret get s >&-`), the value is written to `/dev/null` and
|
||||
`secret get` exits 0.
|
||||
Writes the secret's value to stdout exactly as stored, with no newline added
|
||||
after it. A failed write of the value, such as to a file on a full disk, prints
|
||||
the error and exits 1, with two exceptions. If the program reading from a pipe
|
||||
has already exited, as in `secret get s | true`, the broken-pipe signal
|
||||
(SIGPIPE) ends `secret` with no message and the shell reports exit status 141.
|
||||
If the shell closed stdout before `secret` started (`secret get s >&-`), the
|
||||
value is written to `/dev/null` and `secret get` exits 0.
|
||||
|
||||
- `--version, -v`: Get a specific version (default: current)
|
||||
|
||||
@@ -300,7 +304,7 @@ Selects an unlocker as the current default for operations.
|
||||
#### `secret import <secret-name> --source <filename>`
|
||||
|
||||
Imports a secret from a file and stores it in the current vault under the given
|
||||
name.
|
||||
name. The file's bytes are stored unchanged, a final newline included.
|
||||
|
||||
### Encryption Operations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user