aboutsummaryrefslogtreecommitdiff
path: root/share/aux-repo/aux/lib.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-25 17:43:52 -0300
committerEuAndreh <eu@euandre.org>2023-03-25 17:43:52 -0300
commit4641e27bda25c6a85ddc0d3b35f1b58fe4ec2e49 (patch)
tree6e0633f2345996772a6591ea024c6f0bfe1fff04 /share/aux-repo/aux/lib.sh
parentbin/aux: Allow files to be copied to be parameterized (diff)
downloaddotfiles-4641e27bda25c6a85ddc0d3b35f1b58fe4ec2e49.tar.gz
dotfiles-4641e27bda25c6a85ddc0d3b35f1b58fe4ec2e49.tar.xz
share/aux-repo/: Add existing files AS-IS
Diffstat (limited to 'share/aux-repo/aux/lib.sh')
-rw-r--r--share/aux-repo/aux/lib.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/share/aux-repo/aux/lib.sh b/share/aux-repo/aux/lib.sh
new file mode 100644
index 0000000..9d183f9
--- /dev/null
+++ b/share/aux-repo/aux/lib.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+assert_arg() {
+ if [ -z "$1" ]; then
+ printf 'Missing %s.\n\n' "$2" >&2
+ cat <<-'EOF'
+ usage >&2
+ exit 2
+ EOF
+ fi
+}
+
+uuid() {
+ od -xN20 /dev/urandom |
+ head -n1 |
+ awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
+}
+
+tmpname() {
+ echo "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)"
+}
+
+mkstemp() {
+ name="$(tmpname)"
+ touch "$name"
+ echo "$name"
+}
+
+mkdtemp() {
+ name="$(tmpname)"
+ mkdir "$name"
+ echo "$name"
+}