aboutsummaryrefslogtreecommitdiff
path: root/bin/mkstemp
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/mkstemp
parentbin/player: Add working utility (diff)
downloaddotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.gz
dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.xz
bin/: Add examples to help strings
Diffstat (limited to 'bin/mkstemp')
-rwxr-xr-xbin/mkstemp40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/mkstemp b/bin/mkstemp
index ec92c14..4097e59 100755
--- a/bin/mkstemp
+++ b/bin/mkstemp
@@ -15,10 +15,50 @@ help() {
Options:
-h, --help show this message
+
Create a new temporary file and echo its name back.
+
+
+ Examples:
+
+ Capture output into temporary file:
+
+ $ OUT="$(mkstemp)"; cmd > "$OUT"
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)"
touch "$name"
echo "$name"