On Wed, Jun 08, 2005 at 08:41:21PM +0200, Alexandre Duret-Lutz wrote:
> >>> "James" == James Youngman <[EMAIL PROTECTED]> writes:
> 
>  James> +# GNU ls unserstands $TIME_STYLE.  Leaving it set at "+%Y-%m-%d 
> %H:%M:%S" for 
>  James> +# example will cause this script to go into an infinite loop.
>  James> +unset TIME_STYLE
> 
> unset is not portable.  

I had not realised, thanks for letting me know.

> Can we override TIME_STYLE with some safe value? Which one? 
> What happens when this is set to the empty string?

Well, based on reading the manpage for GNU ls and some testing, try
the following:

: GNU ls changes its time format in response to the TIME_STYLE
: variable, but we cannot unset it since the V7 shell does not have an
: "unset" command.  "test" is present in V7 and supports -n but is not
: a shell builtin.  V7 /bin/sh does not support hash comments, but
: fortunately it supports :.
if test -n "$TIME_STYLE"
then
        if unset TIME_STYLE 2>/dev/null
        then
                : ok, we got rid of it.
        else
                : The shell does not provide "unset".
                : A posix- prefix means that the style
                : takes effect only outside the POSIX
                : locale, but we have just selected the 
                : POSIX locale, so that should be enough 
                : to turn it off.
                TIME_STYLE=posix-"$TIME_STYLE"
        fi
fi

: Regards, James.


_______________________________________________
Bug-findutils mailing list
Bug-findutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-findutils

Reply via email to