rargs
rargs means replace arguments.
rargs runs a command after replacing strings in its arguments.
rargs [-r key=value]... -- command [args...]
Stdin, stdout, stderr, and env are passed through to the child process.
The child’s exit code is propagated.
Install
go install github.com/minoritea/rargs@latest
Usage
Pass replacements with -r key=value, then the command after --:
rargs -r NAME=world -- echo hello NAME
# => hello world
Each -r is applied in turn, overwriting the arguments, at most once per -r.
rargs -r k1=v1 -r k2=v2 -- echo k1 k2 k1
# => v1 v2 k1
rargs -r a=b -- echo aaa
# => baa
rargs -r f=1 -r f=2 -- echo foo foo
# => 1oo 2oo
Values may contain =:
rargs -r k=v=w -- echo k
# => v=w
Notes
key must be non-empty. -r without = (e.g. -r kv, -r =v) is an error.
- Flags must come before
--. Unknown flags or bare values there are errors. Everything after -- is the command, even -r.
-- is required, and a command must follow it.