i386/127063: shell: $RANDOM doesn't works in scripts

Anarchist Anarchist at nixp.ru
Wed Sep 3 11:30:01 UTC 2008


>Number:         127063
>Category:       i386
>Synopsis:       shell: $RANDOM doesn't works in scripts
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 03 11:30:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Anarchist
>Release:        FreeBSD 6.3-RELEASE #0
>Organization:
nixp.ru
>Environment:
FreeBSD gw-1.caotus.ru 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Wed Apr 16 10:24:30 MSD 2008     root at gw-1.caotus.ru:/usr/src/sys/i386/compile/GW-1_KERNEL  i386
also seen on
FreeBSD mx4.elpay.ru 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007     root at dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
# pkg_info | grep bash
bash-3.2.33         The GNU Project's Bourne Again SHell
and
# pkg_info | grep bash
bash-3.2.25         The GNU Project's Bourne Again SHell
>How-To-Repeat:
Executing "expr $RANDOM % 4" in command line does what it is to do generating random numbers from 0 to 3.

When I try to put generating of random numbers in a script like:
#!/usr/local/bin/bash
 
expr $RANDOM % 4
 
exit 0

or
#!/bin/sh
 
expr $RANDOM % 4
 
exit 0

I get the syntax error: "expr: syntax error"


Trying to execute both the command and the script on my Linux workstation gives normal result.
>Fix:
Unknown

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-i386 mailing list