Skip to content

Instantly share code, notes, and snippets.

@adiog
Last active February 7, 2018 13:28
Show Gist options
  • Save adiog/232c725018b052110b10e8343e2411f9 to your computer and use it in GitHub Desktop.
Save adiog/232c725018b052110b10e8343e2411f9 to your computer and use it in GitHub Desktop.
mock with logging
#!/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