Skip to content

Instantly share code, notes, and snippets.

@enhao
Created April 28, 2015 12:18
Show Gist options
  • Save enhao/f290b51be0380cfae1cf to your computer and use it in GitHub Desktop.
Save enhao/f290b51be0380cfae1cf to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
set -u
function usage() {
echo "Usage: $(basename $0): [-d] args"
echo " -d Make a directory instead of a file."
}
is_dir=''
while getopts d opt; do
case $opt in
d) is_dir='-d' ;;
*)
usage
exit 1;;
esac
done
shift $(($OPTIND - 1))
if [ $# -ne 1 ]; then
usage
exit 1
fi
mktemp $is_dir "$*-XXXXXX"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment