Hi, I think the attached patch fixes the bashism by creating a function that returns a random number instead of relying on the $RANDOM magic variable.
I'll try to get it accepted upstream. Regards, Javi (Vicho) On 11/05/10 07:42, Raphael Geissert wrote: > Package: mercurial-common > Severity: minor > Version: 1.5.1-2 > User: [email protected] > Usertags: goal-dash > > Hello maintainer, > > While performing an archive wide checkbashisms (from the 'devscripts' package) > check I've found your package containing a /bin/sh script making use > of a bashism. > > checkbashisms' output: >> possible bashism in ./usr/share/doc/mercurial-common/examples/hgeditor line >> 30 ($RANDOM): >> HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$" > > > Not using bash (or a Debian Policy compliant shell interpreter that doesn't > provide such an extra feature) as /bin/sh is likely to lead to errors or > unexpected behaviours. Please be aware that dash is now the default /bin/sh. > > Hints about how to fix bashisms can be found at: > https://wiki.ubuntu.com/DashAsBinSh > > If you still don't know how to fix the bashisms don't hesitate to reply to > this email, or tag the bug as 'help'. > > Thank you, > Raphael Geissert > > >
diff --git a/hgeditor b/hgeditor
--- a/hgeditor
+++ b/hgeditor
@@ -23,11 +23,15 @@ cleanup_exit() {
rm -rf "$HGTMP"
}
+get_rand_num() {
+ echo $(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
+}
+
# Remove temporary files even if we get interrupted
trap "cleanup_exit" 0 # normal exit
trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
-HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
+HGTMP="${TMPDIR-/tmp}/hgeditor.$(get_rand_num).$(get_rand_num).$(get_rand_num).$$"
(umask 077 && mkdir "$HGTMP") || {
echo "Could not create temporary directory! Exiting." 1>&2
exit 1
signature.asc
Description: OpenPGP digital signature

