Skip to content

Instantly share code, notes, and snippets.

@nascheme
Created April 12, 2018 20:21
Show Gist options
  • Save nascheme/4d24e611364506183d66f7654ba3e9ac to your computer and use it in GitHub Desktop.
Save nascheme/4d24e611364506183d66f7654ba3e9ac to your computer and use it in GitHub Desktop.
#!/bin/sh
# Embedded archive in shell script.
# To create script:
# cat <this script>.sh <archive file> > <script>.run
# chmod +x <script>.run
archive () {
# lines of script to skip (computed automatically)
skip=$(awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0)
tail -n +${skip} $0
}
##############################################################################
# Insert your script here. 'archive' will produce the archive on stdout
archive | tar ztf -
##############################################################################
# Don't modify anything below this line.
##############################################################################
exit 0
__ARCHIVE_FOLLOWS__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment