Fixed a bashism with the use of $RANDOM in hgeditor.
authorJavi Merino <cibervicho@gmail.com>
Wed, 19 May 2010 18:06:35 +0200
changeset 11266 2b440bb8a66b
parent 11265 ffd85ab578be
child 11268 f73baa069113
Fixed a bashism with the use of $RANDOM in hgeditor. The variable $RANDOM is not POSIX so a portable /bin/sh may not define it. When creating a directory with a random name it's better to use mktemp, which, even though is not POSIX, exists in common Unixes including Linux, OpenBSD, FreeBSD and MacOS X.
hgeditor
--- a/hgeditor	Thu May 27 22:50:23 2010 +0300
+++ b/hgeditor	Wed May 19 18:06:35 2010 +0200
@@ -27,10 +27,10 @@
 trap "cleanup_exit" 0 # normal exit
 trap "exit 255" HUP INT QUIT ABRT TERM
 
-HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
-(umask 077 && mkdir "$HGTMP") || {
-    echo "Could not create temporary directory! Exiting." 1>&2
-    exit 1
+HGTMP=$(mktemp -d ${TMPDIR-/tmp}/hgeditor.XXXXXX)
+[ x$HGTMP != x -a -d $HGTMP ] || {
+  echo "Could not create temporary directory! Exiting." 1>&2
+  exit 1
 }
 
 (