Last active
February 7, 2018 13:28
-
-
Save adiog/232c725018b052110b10e8343e2411f9 to your computer and use it in GitHub Desktop.
mock with logging
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
#!/bin/bash | |
MOCK=$1 | |
# moves MOCK (ed) to MOCK.real and creates MOCK with logging to MOCK.log and calling MOCK.real | |
REALMOCK=$(realpath ${MOCK}) | |
REAL=${REALMOCK}.real | |
LOG=${REALMOCK}.log | |
touch $LOG | |
chmod 777 $LOG | |
mv ${REALMOCK} $REAL | |
touch ${REALMOCK} | |
chmod +x ${REALMOCK} | |
echo '#!/bin/bash' >> ${REALMOCK} | |
echo "echo \"\$@\" >> ${LOG}" >> ${REALMOCK} | |
echo "${REAL} \"\$@\"" >> ${REALMOCK} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment