mbland / go-script-bash

Framework for writing modular, discoverable, testable Bash scripts
ISC License
95 stars 16 forks source link

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

Open phlenoir opened 4 years ago

phlenoir commented 4 years ago

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'