Make shellcheck happy
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Stolen from https://devops.stackexchange.com/a/8984 and adapted to my use case
|
# Stolen from https://devops.stackexchange.com/a/8984 and adapted to my use case
|
||||||
|
|
||||||
if [[ -z "$@" ]]; then
|
if (( $# == 0 )) ; then
|
||||||
echo "Missing file input arguments"
|
echo "Missing file input arguments"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for FILE in "$@"
|
for FILE in "$@"
|
||||||
do
|
do
|
||||||
RESOURCE=$(sed -n 's/^resource "\([^"]*\)" "\([^"]*\)".*/-target=\1.\2 /gp' $FILE)
|
RESOURCE=$(sed -n 's/^resource "\([^"]*\)" "\([^"]*\)".*/-target=\1.\2 /gp' "$FILE")
|
||||||
MODULE=$(sed -n 's/^module "\([^"]*\)".*/-target=module.\1 /gp' $FILE)
|
MODULE=$(sed -n 's/^module "\([^"]*\)".*/-target=module.\1 /gp' "$FILE")
|
||||||
if [[ -z "$RESOURCE" ]] && [[ -z "$MODULE" ]]; then
|
if [[ -z "$RESOURCE" ]] && [[ -z "$MODULE" ]]; then
|
||||||
echo "Cannot detect terraform resource and module in $FILE"
|
echo "Cannot detect terraform resource and module in $FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$RESOURCE" ]]; then
|
if [[ -n "$RESOURCE" ]]; then
|
||||||
echo -e $"$RESOURCE"
|
echo -e $"$RESOURCE"
|
||||||
fi
|
fi
|
||||||
if [[ ! -z "$MODULE" ]]; then
|
if [[ -n "$MODULE" ]]; then
|
||||||
echo -e $"$MODULE"
|
echo -e $"$MODULE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user