Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog kde5-functions.eclass kde5.eclass
Date: Sun, 28 Jun 2015 15:14:22
Message-Id: 20150628171403.57ca7f54@gentoo.org
In Reply to: Re: [gentoo-dev] Re: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog kde5-functions.eclass kde5.eclass by Patrice Clement
1 On Sun, 28 Jun 2015 14:46:01 +0200
2 Patrice Clement <monsieurp@g.o> wrote:
3
4 > man 3 glob
5 > man 3 fnmatch
6 > man 1 bash -> read the section called "Pattern Matching" under
7 > "EXPANSION".
8 >
9 > in this case, $(ls) would unnecessarily spawn a subshell for listing
10 > files. You can often get the same result by using wildcard expansion
11 > (or globbing) like Michal said:
12 >
13 > for lang in *; do
14 > ...
15 > done
16 >
17 > It is often faster.
18
19
20 and it avoids aliases:
21
22 /etc $ echo $(ls)
23 total 1.7M drwxr-xr-x 4 root root 4.0K Aug 29 2014 acpi -rw-r--r-- 1
24 root root 44 Oct 6 2014 adjtime drwxr-xr-x 2 root root 4.0K Jun 26
25 19:27 adobe drwxr-xr-x 3 root root 4.0K Mar 22 15:46 ardour3 drwxr-xr-x
26 3 root root 4.0K May 8 13:14 ardour4 drwxr-xr-x 2 root root 4.0K Jun 15
27 17:06 at-spi2 drwxr-xr-x 3 root root etc.
28
29 I doubt that is what is wanted
30
31
32
33 However, beware of empty directories:
34
35 /tmp/toto $ ls
36 total 0
37 /tmp/toto $ for a in *; do echo $a; done
38 *

Replies