[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] for sh portability issue in davautocheck.sh

From: Louis Guillaume <lguillaume_at_berklee.edu>
Date: 2007-03-28 03:50:01 CEST

Max Bowsher wrote:
> Max Bowsher wrote:
>> Louis Guillaume wrote:
>>> Hi,
>>>
>>> The attached patch should fix a portability problem in subversion/tests/cmdline/davautocheck.sh.
>>>
>>> * subversion/tests/cmdline/davautocheck.sh
>>> Fixed some instances of Bourne shell features that are not portable:
>>> (1) Removed all instances of `==' in `test' or `[' statements.
>> Committed.
>>
>>> (2) Replaced use of `$RANDOM' with `(( $$ % 32768 ))'.
>> Why 32768?
>>
>> IMO:
>> HTTPD_PORT=$(( $$ % 64511 + 1024 ))
>>
>> is a more suitable calculation.
>

Agreed. That's better. I was just reproducing what $RANDOM does...

from bash(1)

  RANDOM Each time this parameter is referenced, a random integer between
         0 and 32767 is generated. The sequence of random numbers may be
         initialized by assigning a value to RANDOM. If RANDOM is unset,
         it loses its special properties, even if it is subsequently
         reset.

>
> Note that the use of $RANDOM seems entirely fine to me, so long as the
> shebang line is still specifying /bin/bash explicitly.

But that assumes that /bin/bash is on every system, which it isn't by default.
It's not there on NetBSD or AIX and I'm pretty sure it's not in Solaris.
Probably others too, but I can't speak to those.

Louis

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 28 03:50:20 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.