changeset 11266:2b440bb8a66b

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.
author Javi Merino <cibervicho@gmail.com>
date Wed, 19 May 2010 18:06:35 +0200
parents ffd85ab578be
children f73baa069113
files hgeditor
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
 }
 
 (