open-power/sb-signing-utils

AIX support: Need replacement for 'date -d'

mtvaught-ibm opened this issue · 6 comments

The version of "date" on AIX does not support the -d flag, used for formatting epoch into something human readable.

One potential solution would be to use a short perl script instead:
perl -le 'print scalar localtime $ARGV[0]'

Looks good, thanks for investigating. If the return code from "date" is reliable (non-zero when trying to use date -d) then I can check that and fall back to the perl in that case. (assuming perl is available, which I should also check.)
If neither '''date -d''' nor perl is available... well, the user just doesn't get a human readable timestamp of the cache creation date. But it won't affect the operation of the program.

My proposed patch is in pr #17.

So something interesting that I came across, date -d is available in the bash shell. It was only when I was using the default shell that I was running into this issue.

Not sure if this changes the approach.

Interesting. Is that because it ignores the shebang and uses a different shell, like ksh? Or is there in fact more than one bash on AIX, and you need to do something special to make it use the GNU bash?

I closed the previous PR and replaced it with #19. Can you please test it on AIX for me? Since the patch is already written, if there's a chance a user could hit this on AIX, I'm inclined to go ahead and commit it (assuming it works OK).

Preliminary tests show my patch is working on AIX. Will test a bit more and then check it in.

Looks good. Committed via pull request #19.

Thanks again to Matt Vaught for finding the workaround.