diff options
| author | EuAndreh <eu@euandre.org> | 2022-08-13 13:17:45 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-08-13 13:17:45 -0300 |
| commit | a2324725adab4fda610d39eb21d8d28bdf8f35ba (patch) | |
| tree | b8d770e51d7e0703020cfd6862e890b717bcb23e /bin/mkstemp | |
| parent | bin/player: Add working utility (diff) | |
| download | dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.gz dotfiles-a2324725adab4fda610d39eb21d8d28bdf8f35ba.tar.xz | |
bin/: Add examples to help strings
Diffstat (limited to 'bin/mkstemp')
| -rwxr-xr-x | bin/mkstemp | 40 |
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" |
