On aws-vault, multiple arguments can be passed easily without quoting arguments with single quotes, but nix-shell does not support that.
aws-vault exec satellite-dev -- aws sts get-caller-identity --output text
-- here prevents aws-vault from getting confused when aws-vault parse arguments.
Without --, aws-vault would think that --output option is passed to itself, not aws command.
aws-vault: error: unknown long flag '--output', try --help
Since nix-shell does not seem to support this, making passing multiple argument a complicated thing.
Neither
nix-shell -p awscli2 --run aws sts get-caller-identity --output text
or
nix-shell -p awscli2 --run -- aws sts get-caller-identity --output text
works. Fails with error: unrecognised flag '--output'
If arguments don’t contain ones starting with hyphens, nix-shell tries to parse arguments as nix expressions.
nix-shell -p awscli2 --run -- aws sts get-caller-identity
error: undefined variable 'sts' at (string):1:110
(use '--show-trace' to show detailed location information)
So, I ended up quoting all arguments with single quotes, but quoting arguments every time is not very convenient. If arguments contains spaces it will get complicated further.
nix-shell -p awscli2 --run -- 'aws sts get-caller-identity --output text'
It also makes writing wrapper script that runs command on nix-shell complicated. The shell script below will not work with multiple arguments, because with $@, all arguments remain split (and nix-shell --run does not support multiple arguments).
#!/usr/bin/env bash -eux
nix-shell -p awscli2 --run "$@"
$* combines all arguments to single string, but also re-splits arguments, causing problems with spaces. Are there any workarounds? Or will nix-shell supports passing multiple arguments in the future?