From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2026-04-02T13:22:59+00:00 Subject: [ruby-core:125182] [Ruby Feature#21976] Add $SECONDS, $RANDOM, and other bashisms Issue #21976 has been updated by nobu (Nobuyoshi Nakada). Sorry to be late: https://github.com/nobu/bashism ---------------------------------------- Feature #21976: Add $SECONDS, $RANDOM, and other bashisms https://bugs.ruby-lang.org/issues/21976#change-116916 * Author: jhawthorn (John Hawthorn) * Status: Open ---------------------------------------- Some time ago there was a lot of discussion around a script named [safe_sleep.sh](https://github.com/actions/runner/blob/af6c8e6eddef233fdef862c1287d9b013c8aabff/src/Misc/layoutroot/safe_sleep.sh) in the GitHub Actions runner. Like [many others](https://github.com/actions/runner/issues/2380), I immediately saw the serious problem with this script: it isn't written in Ruby! To better support this use case, and to be able to sleep safely, Ruby should support `$SECONDS` as well as other bashisms like `$RANDOM`, `$1`, etc. This would allow us to rewrite ```bash #!/bin/bash SECONDS=0 while [[ $SECONDS != $1 ]]; do : done ``` In Ruby ```ruby #!/usr/bin/env -S ruby -rbashisms $SECONDS = 0 while $SECONDS != $1.to_i ; end ``` ``` $ ruby -rbashisms -e 'echo $BASH_VERSION' 4.1.2026(4.0.1)-release (ruby) $ ./safe_sleep.rb 5 ``` For ease of evaluating this proposed feature I've have created the [`bashisms` gem](https://github.com/jhawthorn/bashisms) please give it a try! -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/