Bug#619082: dash: implement variable $RANDOM

2011-03-27 Thread Jonathan Nieder
(resending because I can't spell. :/  Sorry for the noise.)

Hi Pedro,

Pedro Zorzenon Neto wrote:

 After upgrading to squeeze and answering yes to install question of
 using dash as default shell for non-interactive users, all my cronjobs
 that use $RANDOM variable to delay some random seconds of running time
 stopped working.

I don't think this functionality belongs in dash.  For example, I
find that the sleep command in

 Example of a simple cronjob which runs with a random delay of
 0 ~ 327 seconds (to prevent network peaks of all the machines):

   */30 * * * * sleep $(($RANDOM/100))  do_something_network_related

is better written (more portably and more intuitively) as

sleep $(awk 'BEGIN {srand(); printf %d\n, rand()*327}')

or

awk 'BEGIN { srand(); system(sleep  int(rand() * 327)) }'

even though this is a little longer.

On the other hand, I would definitely like a way for users to be able
to easily choose a different shell to be used by cron, so they would
be less at the mercy of the cruel sysadmin.  What do you think?

Thanks for writing,
Jonathan



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#619082: dash: implement variable $RANDOM

2011-03-27 Thread Pedro Zorzenon Neto
 I don't think this functionality belongs in dash.  For example, I
 find that the sleep command in
 
 Example of a simple cronjob which runs with a random delay of
 0 ~ 327 seconds (to prevent network peaks of all the machines):

   */30 * * * * sleep $(($RANDOM/100))  do_something_network_related
 
 is better written (more portably and more intuitively) as
 
   sleep $(awk 'BEGIN {srand(); printf %d\n, rand()*327}')
 
 or
 
   awk 'BEGIN { srand(); system(sleep  int(rand() * 327)) }'
 
 even though this is a little longer.

nice idea...
  */30 * * * * perl -e sleep rand(327); do_something_network_related
for the ones that like perl :-)

I think that is dash is supposed to replace bash, it should implement
$RANDOM... but this is only my personal opinion :-)

 On the other hand, I would definitely like a way for users to be able
 to easily choose a different shell to be used by cron, so they would
 be less at the mercy of the cruel sysadmin.  What do you think?

If you put:
SHELL=/bin/something
at the begining of your crontab, all the lines will be run with your
prefered shell.

Thanks,
Pedro



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#619082: dash: implement variable $RANDOM

2011-03-27 Thread Jonathan Nieder
clone 619082 -1
retitle -1 dash: package description does not explain goals well
severity -1 minor
submitter -1 !
quit

Pedro Zorzenon Neto wrote:
[out of order for convenience]

 If you put:
 SHELL=/bin/something
 at the begining of your crontab, all the lines will be run with your
 prefered shell.

Ah, that's excellent!  I should have checked crontab(5).

 I think that is dash is supposed to replace bash, it should implement
 $RANDOM... but this is only my personal opinion :-)

Ah, interesting --- dash is not intended to replace bash but now that
I check I see the current package description suggests it might be.
By contrast, Herbert's webpage says:

 DASH is a POSIX-compliant implementation of /bin/sh that aims to be as
 small as possible. It does this without sacrificing speed where
 possible. In fact, it is significantly faster than bash (the GNU
 Bourne-Again SHell) for most tasks.

From this we see that dash is meant to to be

 * POSIX-compliant
 * small
 * reasonably fast

Meanwhile bash is more powerful and definitely has its place
(especially for features like programmatic completion imho).

The package could use some help from a wordsmith to convey:

 - for a full-featured, bash-compatible shell, see the bash package. :)
 - for a POSIX compliance checker, see the posh package.

Thanks for a useful reminder.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#619082: dash: implement variable $RANDOM

2011-03-20 Thread Pedro Zorzenon Neto
Package: dash
Version: 0.5.5.1-7.4
Severity: wishlist

Hi,

After upgrading to squeeze and answering yes to install question of
using dash as default shell for non-interactive users, all my cronjobs
that use $RANDOM variable to delay some random seconds of running time
stopped working.

Please implement this in dash.

Example of a simple cronjob which runs with a random delay of
0 ~ 327 seconds (to prevent network peaks of all the machines):

  */30 * * * * sleep $(($RANDOM/100))  do_something_network_related

Thanks,
Pedro



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org