Created
March 23, 2012 19:04
-
-
Save ryancdotorg/2173873 to your computer and use it in GitHub Desktop.
Command wrapper that allows multiple calls to a wrapped command
This file contains 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
#!/bin/bash | |
# Configuration | |
COMMAND="/usr/bin/openssl" | |
PRE_ARGS="" | |
POST_ARGS="-passin env:PASSWD" | |
ECHO=1 | |
# Add any needed execution environment setup code here | |
PASSWD=`get_passphrase.sh` | |
ARGS=() | |
ARGI=0 | |
for ARG in "$@" | |
do | |
if [ "$ARG" = ";" ]; then | |
if [ $ECHO -ge 1 ]; then | |
echo $COMMAND $PRE_ARGS "${ARGS[@]}" $POST_ARGS >&2 | |
fi | |
$COMMAND $PRE_ARGS "${ARGS[@]}" $POST_ARGS | |
ARGS=() | |
ARGI=0 | |
else | |
ARGS[$ARGI]="$ARG" | |
ARGI=$[$ARGI+1] | |
fi | |
done | |
if [ $ECHO -ge 1 ]; then | |
echo $COMMAND $PRE_ARGS "${ARGS[@]}" $POST_ARGS >&2 | |
fi | |
$COMMAND $PRE_ARGS "${ARGS[@]}" $POST_ARGS | |
# Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment