On 11/13/25 03:17, Matt Panaro wrote:
> addresseshttps://savannah.gnu.org/bugs/index.php?66299
> the ls program itself has both a parameter and a recognized environment 
variable, TIME_STYLE,
> that formats the output of the file's timestamp in the listing.
> To achieve partial parity for the -ls output of find, the code is refactored 
to honor the
> environment variable (a style parameter is not implemented herein).

I think having the ability to support a time-style for 'find -ls' output is 
very useful.
Still, I doubt that environment variables are the desired way to achieve this.

As you wrote, ls(1) support the TIME_STYLE environment variable ... but this is 
only
the GNU implementation of ls; e.g. OpenBSD does not have it.
FWIW also GNU du(1) supports the TIME_STYLE env variable, but ls(1) accepts
one named style more - "locale", which du(1) ignores.
I wouldn't want to add more confusion by supporting a subset in find(1).

Another topic: supporting an environment variable in find(1) might be very 
frustrating
for someone trying to get the known time format in the output, not realizing 
that
something set the TIME_STYLE environment variable for the other program.

For that reason, we are very reluctant to introduce environment variables.
That was fancy in the beginning of UNIX, but has turned into an anti-pattern
due to the mentioned issues.
Instead, I think it would be much better to directly add the -time-style option.
By that, the caller even may explicitly pass their TIME_STYLE to find(1):

    $ find -time-style "$TIME_STYLE" -ls

We could also borough the supported named styles from GNU du(1):

      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'

Explicitly requiring a raw FORMAT to begin with "+" is also clearer than ...

> +      /* ls expects TIME_STYLE to start with a '+'; if it were re-used
> +         here, the '+' should be ignored when passing into strftime,
> +         below. */
> +      if(*ts == '+') ts++;

... silently jumping over the "+".

Thoughts?

Have a nice day,
Berny



Reply via email to