17 votes

Bash-5.0 release available

9 comments

  1. Crestwave
    Link
    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.
    6 votes
  2. [8]
    unknown user
    Link
    Re. $EPOCHSECONDS. I don't want to disrespect Bash authors, but why wasn't date +%s enough?

    Re. $EPOCHSECONDS. I don't want to disrespect Bash authors, but why wasn't date +%s enough?

    3 votes
    1. [7]
      Crestwave
      Link Parent
      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).

      4 votes
      1. [7]
        Comment deleted by author
        Link Parent
        1. [3]
          NeoTheFox
          Link Parent
          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.

          7 votes
          1. [2]
            unknown user
            Link Parent
            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?

            5 votes
            1. NeoTheFox
              Link Parent
              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.

              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.

              4 votes
        2. [3]
          Crestwave
          (edited )
          Link Parent
          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?

          3 votes
          1. [3]
            Comment deleted by author
            Link Parent
            1. [2]
              Emerald_Knight
              Link Parent
              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.

              2 votes
              1. Crestwave
                Link Parent
                Wouldn't you also need to use command substitution for the former? Also, backticks are deprecated now; use $(command) instead.

                ... storing the result of date +%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.

                2 votes