Gentoo Archives: gentoo-user

From: Etaoin Shrdlu <shrdlu@×××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] ext3 with errors
Date: Sun, 30 Sep 2007 13:18:13
Message-Id: 200709301511.03666.shrdlu@unlimitedmail.org
In Reply to: Re: [gentoo-user] ext3 with errors by Florian Philipp
1 On Sunday 30 September 2007, Florian Philipp wrote:
2
3 > Which shell do you use? Bash's default behavior (I don't know whether
4 > you can change that) is that it doesn't expand * to all files and
5 > directories but only the nonhidden.
6 >
7 > Just try the following:
8 > ls -l --directory --all ~/*
9 >
10 > On my system it only shows my a long lost of all directories and files
11 > without a dot at the beginning although, strictly speaking, the
12 > command should show all files, even the hidden ones.
13
14 No, it should not (assuming the syntax of your example), unless
15 bash "dotglob" option is on. One thing are the options to ls, another is
16 how the shell expands wildcard characters.
17 In your example, the tilde is expanded to the user's home dir
18 (eg, /home/user), the asterisk is expanded to all the file and directory
19 names under /home/user not starting with ".", so what ls really sees is
20
21 ls -l --directory --all /home/user/dir1 /home/user/dir2 /home/user/file1 /home/user/file2
22 etc.
23
24 Since you gave the "--directory" (aka "-d") option, and "*" expansion
25 does not include names starting with ".", nothing else is printed.
26 The "--all" option does not come into play at all here.
27
28 A different story would be if you did not use the -d option; then names
29 at first level starting with "." still would not have been shown
30 (because "*" is expanded by the shell before ls sees the names), but
31 directory contents would have been listed including names starting
32 with ".", due to the --all option.
33
34 Another variation would be not using -d and giving only "~" as pathname
35 to ls (ie, not "~/*"). In that case, ls would see just "/home/user" and
36 the --all option could do its job at the first level, listing all the
37 names, even those starting with ".".
38
39 The bash option to have "*" expand to all the names, including those
40 starting with ".", is "dotglob" (eg, "shopt -s dotglob). man bash
41 explains it all.
42
43 > Is it possible that you mean regular expressions and not Bash's
44 > expansion feature?
45
46 This is possible (well, sort of) enabling the "extglob" option in bash.
47 --
48 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] ext3 with errors Etaoin Shrdlu <shrdlu@×××××××××××××.org>
Re: [gentoo-user] ext3 with errors Florian Philipp <f.philipp@××××××.de>