Skip to content

Instantly share code, notes, and snippets.

@udoprog
Created January 9, 2012 17:52
Show Gist options
  • Save udoprog/1584104 to your computer and use it in GitHub Desktop.
Save udoprog/1584104 to your computer and use it in GitHub Desktop.
bashin implemented in bash
#!/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