[extsay] Improve script portability
authorMikael Berthe <mikael@lilotux.net>
Fri, 02 Apr 2010 23:45:20 +0200
changeset 22 b6b45c2eb022
parent 21 9798e3aaa851
child 23 cf95a475825c
[extsay] Improve script portability
extsay-ng/extsay.sh
--- a/extsay-ng/extsay.sh	Fri Apr 02 23:23:58 2010 +0200
+++ b/extsay-ng/extsay.sh	Fri Apr 02 23:45:20 2010 +0200
@@ -9,8 +9,11 @@
 # MiKael, 2010-04-02
 
 FIFOPATH="$HOME/.mcabber/mcabber.fifo"
-tmpdir=${TMPDIR:="/tmp"}
+
+tmpdir=${TMPDIR:=$TMP}
+tmpdir=${tmpdir:="/tmp"}
 editor=${EDITOR:="vi"}
+
 jid="."
 
 # Use argument as a recipient JID, if it is provided
@@ -19,7 +22,7 @@
 # Leave if the FIFO is not available
 [ -p $FIFOPATH ] || exit 255
 
-tf=$(mktemp --tmpdir=$tmpdir extsay-XXXXXX) || exit 255
+tf=$(mktemp $tmpdir/extsay-XXXXXX) || exit 255
 
 # This will not work if the editor runs in the background!
 $editor $tf
@@ -30,5 +33,7 @@
     echo $cmd >> $FIFOPATH
 fi
 
-rm $tf
+# Do not remove the file too soon
+(sleep 20 ; rm $tf)&
+
 exit 0