aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-05-12 02:32:32 -0300
committerEuAndreh <eu@euandre.org>2022-05-12 02:32:32 -0300
commitfb44210db42ad2e006f7559d08fa825df4dc1ac3 (patch)
treee3d3112c149998a4c0ceb82fcc8f338020a4b8c8
parent.local/bin/copy: Add working version (diff)
downloaddotfiles-fb44210db42ad2e006f7559d08fa825df4dc1ac3.tar.gz
dotfiles-fb44210db42ad2e006f7559d08fa825df4dc1ac3.tar.xz
.local/bin/uuid: Add working version
-rwxr-xr-x.local/bin/uuid53
1 files changed, 53 insertions, 0 deletions
diff --git a/.local/bin/uuid b/.local/bin/uuid
new file mode 100755
index 00000000..74d0fbaa
--- /dev/null
+++ b/.local/bin/uuid
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ uuid
+ uuid -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+ Generate UUID from /dev/random.
+ 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))
+
+od -xN20 /dev/random |
+ awk 'NR == 1 { OFS="-"; print $2$3,$4,$5,$6,$7$8$9; exit }'