aboutsummaryrefslogtreecommitdiff
path: root/bin/mkdtemp
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-13 13:17:45 -0300
committerEuAndreh <eu@euandre.org>2022-08-13 13:17:45 -0300
commita2324725adab4fda610d39eb21d8d28bdf8f35ba (patch)
treeb8d770e51d7e0703020cfd6862e890b717bcb23e /bin/mkdtemp
parentbin/player: Add working utility (diff)
downloaddotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.gz
dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.xz
bin/: Add examples to help strings
Diffstat (limited to 'bin/mkdtemp')
-rwxr-xr-xbin/mkdtemp40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/mkdtemp b/bin/mkdtemp
index d012175..3729dd4 100755
--- a/bin/mkdtemp
+++ b/bin/mkdtemp
@@ -15,10 +15,50 @@ help() {
Options:
-h, --help show this message
+
Create a new temporary file and echo its name back.
+
+
+ Examples:
+
+ `cd` into temporary directory:
+
+ $ cd "$(mkdtemp)"
EOF
}
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
name="$(tmpname)"
mkdir "$name"
echo "$name"