<story><title>Bash 5.0 released</title><url>http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00063.html</url></story><parent_chain><item><author>_kst_</author><text>With this release, bash now has three built-in variables (um, I mean &amp;quot;parameters&amp;quot;) whose values are updated every time they&amp;#x27;re read:&lt;p&gt;$RANDOM yields a random integer in the range 0..32767. (This feature was already there.)&lt;p&gt;$EPOCHSECONDS yields the whole number of seconds since the epoch.&lt;p&gt;$EPOCHREALTIME yields the number of seconds since the epoch with microsecond precision.&lt;p&gt;I&amp;#x27;m thinking of a new shell feature that would allow the user to define similar variables.  For example, I have $today set to the current date in YYYY-MM-DD format, and I have to jump through some minor hoops to keep it up to date.&lt;p&gt;Does anyone else think this would be useful enough to propose as a new bash feature? Would it create any potential security holes? Should variables like $PATH be exempted?&lt;p&gt;(Of course this doesn&amp;#x27;t add any new functionality, since I could use &amp;quot;$(date +%F)&amp;quot; in place of &amp;quot;$today&amp;quot;. It&amp;#x27;s just a bit of syntactic sugar.)</text></item></parent_chain><comment><author>nothrabannosir</author><text>Please no. The parallel universe Me where I didn&amp;#x27;t happen to read this random thread would never know, consequently never expect random variables to do that. And curse you forever if I found out while banging my head debugging some buggy script.</text></comment>
<story><title>Bash 5.0 released</title><url>http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00063.html</url></story><parent_chain><item><author>_kst_</author><text>With this release, bash now has three built-in variables (um, I mean &amp;quot;parameters&amp;quot;) whose values are updated every time they&amp;#x27;re read:&lt;p&gt;$RANDOM yields a random integer in the range 0..32767. (This feature was already there.)&lt;p&gt;$EPOCHSECONDS yields the whole number of seconds since the epoch.&lt;p&gt;$EPOCHREALTIME yields the number of seconds since the epoch with microsecond precision.&lt;p&gt;I&amp;#x27;m thinking of a new shell feature that would allow the user to define similar variables.  For example, I have $today set to the current date in YYYY-MM-DD format, and I have to jump through some minor hoops to keep it up to date.&lt;p&gt;Does anyone else think this would be useful enough to propose as a new bash feature? Would it create any potential security holes? Should variables like $PATH be exempted?&lt;p&gt;(Of course this doesn&amp;#x27;t add any new functionality, since I could use &amp;quot;$(date +%F)&amp;quot; in place of &amp;quot;$today&amp;quot;. It&amp;#x27;s just a bit of syntactic sugar.)</text></item></parent_chain><comment><author>dualbus</author><text>You mean like Ksh&amp;#x27;s discipline functions?&lt;p&gt;&lt;pre&gt;&lt;code&gt;  dualbus@system76-pc:~$ ksh -c &amp;#x27;date=; date.get() { .sh.value=$(date +%s); }; echo $date; sleep 5; echo $date&amp;#x27;
  1546926637
  1546926642
&lt;/code&gt;&lt;/pre&gt;
See: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;docs.oracle.com&amp;#x2F;cd&amp;#x2F;E36784_01&amp;#x2F;html&amp;#x2F;E36870&amp;#x2F;ksh-1.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;docs.oracle.com&amp;#x2F;cd&amp;#x2F;E36784_01&amp;#x2F;html&amp;#x2F;E36870&amp;#x2F;ksh-1.html&lt;/a&gt; (&amp;quot;Discipline Functions&amp;quot;)</text></comment>