DragonFly BSD
DragonFly users List (threaded) for 2012-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: /bin/ls vs .dotted files


From: "Andrey N. Oktyabrski" <ano@xxxxxxxxx>
Date: Fri, 14 Sep 2012 08:21:29 +0400

On 09/14/2012 04:41 AM, Matthew Dillon wrote:
>      I can't think of a good reason why f_listdot is set for root
>      automatically,
>
>      It goes all the way back to the original import in 2003 when we forked
>      from FreeBSD.
>
>      FreeBSD still turns it on automatically but added a -I option that
>      turns it off.
>
>         /* Root is -A automatically unless -I. */
>          if (!f_listdot && getuid() == (uid_t)0 && !f_noautodot)
>                  f_listdot = 1;
"-I" option has a different explication in the GNU ls:
        -I, --ignore=PATTERN
               do not list implied entries matching shell PATTERN
So this is one more incompatibility.

>      At the very least I will bring in this change.  But it may well be
>      that we should also change the default to NOT be -A for root.
Yes, it is one true solution.

There is one more solution which I have seen in Solaris. Many commands 
are environment-sensitive.

For example, we can have the CMD_BEHAVIOR environment variable, which 
can have values "POSIX" (or "POSIX:1812.321"), "BSD", "LINUX", 
"SOLARIS", ...
So we can use these conditions:
if $CMD_BEHAVIOR is unset or $CMD_BEHAVIOR == "" then CMD_BEHAVIOR=POSIX
if $CMD_BEHAVIOR == POSIX then f_listdot = 0
if $CMD_BEHAVIOR == BSD and UID == 0 then f_listdot = 1

In this case I can change a command behavior in my shell scripts, and my 
scripts can be OS-independent.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]