bug-gnulib
[Top][All Lists]
Advanced

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

Re: bootstrap symlink dependencies


From: Eric Blake
Subject: Re: bootstrap symlink dependencies
Date: Mon, 16 May 2011 13:12:19 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 05/16/2011 12:57 PM, Jim Meyering wrote:
> Paul Eggert wrote:
>> On 05/16/11 07:44, Pádraig Brady wrote:
>>> I tested your ls ordering trick on linux, solaris 10 and freebsd and it 
>>> works.
>>> Please push.
>>
>> Thanks, done.
> 
> Thanks.  I appreciate the added comments, too ;-)
> 
> What do you think of this addition?
> It may be more efficient to invoke one subshell rather than two,
> even though the new subshell includes an additional pipe to sed.
> For the record, I don't really care either way, since even for coreutils,
> saving 1000 subshells (one per file from gnulib) is probably a
> negligible gain in performance, overall.

Anything that shaves 1000 processes is worthwhile for cygwin.  However,

> @@ -677,9 +677,8 @@ symlink_to_dir()
>        # so that broken tools aren't confused into skipping needed builds.  
> See
>        # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
>        test -h "$dst" &&
> -      src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
> -      dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
> -      test "$src_i" = "$dst_i" &&
> +      inums=`ls -1diL "$src" "$dst" 2>/dev/null|sed 's/ .*//'` && set $inums 
> &&

Two subshells with no pipe vs. one subshell with a pipe produces the
same amount of fork/exec calls under bash, so you aren't saving
processes in this case.  On it's own merits, I have no strong opinions
about keeping or dropping this patch.

But you gave me an idea that _does_ speed up cygwin:

inums=`ls -1diL "$src" "$dst" 2>/dev/null`
inum1=${inums%%[!0-9]*}
inums=${inums#*
}
inum2=${inums%%[!0-9]*}
test "$inum1" = "$inum2"

which computes the same with only one child process, by avoiding both a
second ls and a pipeline.  On the other hand, it only works with POSIX
shells (Solaris /bin/sh doesn't understand the XSI notion of %% and ##).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]