Created
August 3, 2022 15:34
-
-
Save sulincix/e96b520a44736c3f42cea06ce6dd51d9 to your computer and use it in GitHub Desktop.
Sh compiler
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 | |
if [[ $# -ne 2 ]] ; then | |
echo "Usage shc (source.sh) (output.c)" | |
exit 2 | |
fi | |
echo "#include <stdlib.h>" > "$2" | |
echo "int main(){" >> "$2" | |
echo " return system(\" \\" >> "$2" | |
cat $1 | sed 's/\\/\\\\/g;s/"/\\"/g;s/$/\\/g' >> "$2" | |
echo " \");" >> "$2" | |
echo "}" >> "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment