Skip to content

Instantly share code, notes, and snippets.

@htnosm
Last active July 3, 2022 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htnosm/4151e87349b7f3aae71cc43a23b6cde9 to your computer and use it in GitHub Desktop.
Save htnosm/4151e87349b7f3aae71cc43a23b6cde9 to your computer and use it in GitHub Desktop.
Output aws cli command in bash script
#!/usr/bin/env bash
# Output aws cli command in bash script
# Usage: echo-awscli.sh scriptPath [arg1 arg2 ...]
shopt -s expand_aliases
# mocks
function aws_cli_mock() {
case $@ in
# e.g.
# "<command> <subcommand>"* ) echo "<expected output>" ;;
* ) echo "aws $*" ;;
esac
}
alias "aws"="aws_cli_mock"
[ -z "${1}" ] && exit 1
SCRIPT="${1}"
shift
(. "${SCRIPT}" ${@})
echo "StatusCode: $?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment