[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] ash: add bash-compatible EPOCH variables
From:       Ron Yorston <rmy () pobox ! com>
Date:       2019-04-15 9:47:05
Message-ID: 5cb45319.OCy+KJU2HeJg2ZeS%rmy () pobox ! com
[Download RAW message or body]

Denys Vlasenko wrote:
>On Tue, Apr 9, 2019 at 9:28 AM Ron Yorston <rmy@pobox.com> wrote:
>> Bash 5.0 added the dynamic variable EPOCHSECONDS and EPOCHREALTIME
>> which return the number of seconds since the Unix Epoch as an
>> integer or float.  These are useful for logging or tracing.
>
>Thanks!
>Can you add them to hush too?

Sure.

Handling of dynamic variables (like RANDOM) in hush differs from bash,
ksh and BusyBox ash.  In hush unsetting a dynamic variable has no
effect while assigning a value to it makes it lose its special status.
Unsetting after setting makes it dynamic again.

   $ echo $RANDOM
   25197
   $ unset RANDOM; echo $RANDOM
   14730
   $ RANDOM=12345; echo $RANDOM
   12345
   $ unset RANDOM; echo $RANDOM
   6973

In the other shells assigning a value has no effect unless the variable
has first been unset and the loss of special status is permanent:

   $ echo $RANDOM
   25206
   $ RANDOM=12345
   $ echo $RANDOM
   28207
   $ unset RANDOM; RANDOM=12345; echo $RANDOM
   12345
   $ unset RANDOM; echo $RANDOM

   $

Fixing that is a whole other problem which I haven't tackled.

Ron
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic