TL;DR: The most notable new features are several new shell variables: BASH_ARGV0 expands to $0 and sets it on assignment. EPOCHSECONDS expands to the time in seconds since the Unix epoch....
TL;DR: The most notable new features are several new shell variables:
BASH_ARGV0 expands to $0 and sets it on assignment.
EPOCHSECONDS expands to the time in seconds since the Unix epoch.
EPOCHREALTIME is the same as the previous but with microsecond granularity.
Well, date isn't a built-in command. It could actually be done without external utilities before with printf '%(%s)T', but I suppose that they just wanted a counterpart to EPOCHREALTIME (which had...
Well, date isn't a built-in command. It could actually be done without external utilities before with printf '%(%s)T', but I suppose that they just wanted a counterpart to EPOCHREALTIME (which had no built-in equivalent before).
Embedded systems, and docker images. For embedded devices, you usually have less than 20MBs of ROM to go about, and for docker images - they must be spawned in an instance and sometimes they are...
Embedded systems, and docker images. For embedded devices, you usually have less than 20MBs of ROM to go about, and for docker images - they must be spawned in an instance and sometimes they are kept entirely in RAM on huge servers, so yeah, recently there had been a lot of systems without the most basic GNU things you can imagine. Even busybox on such system would be compiled to only have the absolute bare minimum. A nice side effect of that is reduced attack surface on the system as well.
Wouldn't such systems also prefer a more bare-bones POSIX Shell or Bourne Shell to the feature-rich and honestly huge (regarding potential attack surface area) Bash?
Wouldn't such systems also prefer a more bare-bones POSIX Shell or Bourne Shell to the feature-rich and honestly huge (regarding potential attack surface area) Bash?
Not very, but it's still an external dependency that would probably have to be specified if releasing a script to the general public, and not all systems' date would be GNU's. It's also less...
Not very, but it's still an external dependency that would probably have to be specified if releasing a script to the general public, and not all systems' date would be GNU's. It's also less efficient to use external commands, even more so to use command substitution, and every moment could count when dealing with microseconds.
P.S. Shouldn't you be more against the addition of rm and others as loadable builtins?
If there's a frequent need for timestamps, it probably just makes some scripts way more manageable, e.g. you only need to insert via "$EPOCHSECONDS" vs. storing the result of date +%s in a...
If there's a frequent need for timestamps, it probably just makes some scripts way more manageable, e.g. you only need to insert via "$EPOCHSECONDS" vs. storing the result of date +%s in a temporary variable first or enclosing the execution in back ticks.
TL;DR: The most notable new features are several new shell variables:
BASH_ARGV0
expands to$0
and sets it on assignment.EPOCHSECONDS
expands to the time in seconds since the Unix epoch.EPOCHREALTIME
is the same as the previous but with microsecond granularity.Re.
$EPOCHSECONDS
. I don't want to disrespect Bash authors, but why wasn'tdate +%s
enough?Well,
date
isn't a built-in command. It could actually be done without external utilities before withprintf '%(%s)T'
, but I suppose that they just wanted a counterpart toEPOCHREALTIME
(which had no built-in equivalent before).Embedded systems, and docker images. For embedded devices, you usually have less than 20MBs of ROM to go about, and for docker images - they must be spawned in an instance and sometimes they are kept entirely in RAM on huge servers, so yeah, recently there had been a lot of systems without the most basic GNU things you can imagine. Even busybox on such system would be compiled to only have the absolute bare minimum. A nice side effect of that is reduced attack surface on the system as well.
Wouldn't such systems also prefer a more bare-bones POSIX Shell or Bourne Shell to the feature-rich and honestly huge (regarding potential attack surface area) Bash?
ASH is pretty common, but sometimes you have to run scripts for whatever is hosted, and the more things you can do with BASH alone the better it is.
Not very, but it's still an external dependency that would probably have to be specified if releasing a script to the general public, and not all systems'
date
would be GNU's. It's also less efficient to use external commands, even more so to use command substitution, and every moment could count when dealing with microseconds.P.S. Shouldn't you be more against the addition of
rm
and others as loadable builtins?If there's a frequent need for timestamps, it probably just makes some scripts way more manageable, e.g. you only need to insert via
"$EPOCHSECONDS"
vs. storing the result ofdate +%s
in a temporary variable first or enclosing the execution in back ticks.Wouldn't you also need to use command substitution for the former? Also, backticks are deprecated now; use
$(command)
instead.