Created
January 9, 2012 17:52
-
-
Save udoprog/1584104 to your computer and use it in GitHub Desktop.
bashin implemented in bash
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 | |
FILE=$1 | |
[[ ! -f $FILE ]] && exit 1 | |
function create_args() { | |
while [[ $# -gt 1 ]]; do | |
shift | |
echo -n " \"$1\"" | |
done | |
} | |
ARGS=$(create_args "$@") | |
PROGRAM=$(base64 < $FILE | tr -t '\n' '') | |
cat <<ENDL | |
#!/bin/bash | |
EXEC=/tmp/.exec.\$\$; | |
base64 -id <<< "$PROGRAM" > \$EXEC; | |
chmod +x \$EXEC; | |
\$EXEC$ARGS; | |
ENDL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment