Skip to content

Timestamp format not compatible with older (<=4.2) version of bash #257

Open
@phlenoir

Description

@phlenoir

Due diligence

I have searched the Bash changelog for information and found in the section.

This document details the changes between this version, bash-4.3-alpha,
and the previous version, bash-4.2-release.

That:

dd. The `printf' %(...)T format specifier now uses the current time if no argument is supplied.

Framework, Bash, and operating system version information

_GO_CORE_VERSION:         v1.7.0
BASH_VERSION:             4.2.46(2)-release
OSTYPE:                   linux-gnu
_GO_PLATFORM_ID:          amzn
_GO_PLATFORM_VERSION_ID:  2018.03

Description

Unfortunately Amazon provides bash version 4.2 in standard EC2 and the bash bultin printf %(...)T returns the EPOCH zero time instead of the current time.

$ printf "%('%Y-%m-%d %H:%M:%S')T\n" 
'1970-01-01 00:00:00'
$ printf "%('%Y-%m-%d %H:%M:%S')T\n" -1
'2020-04-09 08:35:09'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions