aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-05-12 02:41:24 -0300
committerEuAndreh <eu@euandre.org>2022-05-12 02:41:24 -0300
commit4e518f4560aa75c606a4d5515235ccf7f7c1963a (patch)
treeff15eb54b05c025b45dfc57888a7dd6f367f5fa3
parent.local/bin/tmpname: Add working version (diff)
downloaddotfiles-4e518f4560aa75c606a4d5515235ccf7f7c1963a.tar.gz
dotfiles-4e518f4560aa75c606a4d5515235ccf7f7c1963a.tar.xz
.local/bin/{mkstemp,mkdtemp}: Add working versions
-rwxr-xr-x.local/bin/mkdtemp24
-rwxr-xr-x.local/bin/mkstemp24
2 files changed, 48 insertions, 0 deletions
diff --git a/.local/bin/mkdtemp b/.local/bin/mkdtemp
new file mode 100755
index 0000000..9c7ddd8
--- /dev/null
+++ b/.local/bin/mkdtemp
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ mkstemp
+ mkstemp -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+ Create a new temporary file and echo its name back.
+ EOF
+}
+
+name="$(tmpname)"
+mkdir "$name"
+echo "$name"
diff --git a/.local/bin/mkstemp b/.local/bin/mkstemp
new file mode 100755
index 0000000..ec92c14
--- /dev/null
+++ b/.local/bin/mkstemp
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ mkstemp
+ mkstemp -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+ Create a new temporary file and echo its name back.
+ EOF
+}
+
+name="$(tmpname)"
+touch "$name"
+echo "$name"