On 6/29/20 6:06 AM, Robert Elz wrote: > Perhaps, but that would be a bizarre way to accomplish that. I got > the impression that the assumption was that there would somehow be just > one fork, no matter how many times the conversion was required. I > think that might be possible using bash - but not using date(1) to do > the conversions, it would need a purpose written command which read date > specs from stdin and wrote time_t's (in decimal) to stdout.
If we are going with purpose-written commands I'd advise the OP to write a bash loadable builtin for date. There is already a strftime one, but it only lets you convert an epoch to an arbitrary format. And once we are in bash loadable builtins land, one can also add an option to save the output into a bash variable (like printf -v) instead of printing it to stdout. There are a couple of example loadable builtins that do this sort of thing already. No forks involved, not even one for the lifetime of the script. -- Eli Schwartz Arch Linux Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature