commit: 81c638e5bfb648a2e050031d1c43e0c6a093760d
parent: 6b793ae993944959f944a720538a1b83073e6a93
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 9 May 2018 07:00:30 +0200
sshpaste: OpenBSD’s mktemp(1) compatibility
* Give 8 Xs (just to be a bit future-proof here)
* Have the extension added later, OpenBSD mktemp’s
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/Changelog.md b/Changelog.md
@@ -1,6 +1,10 @@
+## HEAD
+* Compatibility with OpenBSD’s mktemp
+
## 1.0.0 — 2018-05-10 04:14
* Read from stdin when ``-`` is given
* Fix broken logic for exclusive options
+* Be compatible with OpenBSD’s mktemp
## 1.0.0rc2 — 2018-05-06 21:02
* Add ``-h`` option
diff --git a/sshpaste b/sshpaste
@@ -23,7 +23,11 @@ die() {
sshpaste_file() {
[ -s "$1" ] || die "$1 is empty"
target_name=$(basename "$1")
+
chmod +r "$1"
+
+ file -i "$1" 2>&1 >/dev/null | grep 'text/' && target_name="${target_name}.txt"
+
if scp -q "$1" "${target_ssh}-${target_name@Q}"
then echo "${target_www}-${target_name}"
else die "Failed uploading $1"
@@ -31,14 +35,14 @@ sshpaste_file() {
}
sshpaste_xclip() {
- temporary_file="$(mktemp -t sshpaste_xclip.XXXXX.raw)"
+ temporary_file="$(mktemp -t sshpaste_xclip.XXXXXXXX)"
xclip -o > "${temporary_file}" || die "xclip output"
sshpaste_file "${temporary_file}"
rm -f "${temporary_file}"
}
sshpaste_command() {
- temporary_file="$(mktemp -t sshpaste_command.XXXXX.log)"
+ temporary_file="$(mktemp -t sshpaste_command.XXXXXXXX)"
sh -x -c "$*" > "${temporary_file}" 2>&1
#echo "${PS4}$*" > "${temporary_file}"
#sh -c "$*" >> "${temporary_file}" 2>&1
@@ -47,7 +51,7 @@ sshpaste_command() {
}
sshpaste_stdin() {
- temporary_file="$(mktemp -t sshpaste_stdin.XXXXX.txt)"
+ temporary_file="$(mktemp -t sshpaste_stdin.XXXXXXXX)"
tty 2&1 >/dev/null && echo "Reading from stdin, press EOF(^D) when you're done"
cat - > "${temporary_file}" || die "reading from stdin"
sshpaste_file "${temporary_file}"