Last active
July 3, 2022 04:15
-
-
Save htnosm/4151e87349b7f3aae71cc43a23b6cde9 to your computer and use it in GitHub Desktop.
Output aws cli command in bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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