[PATCH] ash: add bash-compatible EPOCH variables
Ron Yorston
rmy at pobox.com
Mon Apr 15 09:47:05 UTC 2019
Denys Vlasenko wrote:
>On Tue, Apr 9, 2019 at 9:28 AM Ron Yorston <rmy at 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
More information about the busybox
mailing list