[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Dot vs asterisk (was: odd/fixups 880f1a7 4/4: Add a text file
Re: [lmi] Dot vs asterisk (was: odd/fixups 880f1a7 4/4: Add a text file with some notes)
Tue, 7 May 2019 02:14:43 +0200
On Mon, 6 May 2019 23:59:39 +0000 Greg Chicares <address@hidden> wrote:
GC> On 2019-05-06 23:27, Vadim Zeitlin wrote:
GC> > but I don't really understand what makes you think using the dot wasn't a
GC> > good idea?
GC> Obviously it's a good idea in Ilya's patch; the whole internet says
GC> so, at least according to the way I searched.
GC> But if '/.' is better than '/*', then it must always be better;
GC> that's just axiomatic for me.
The perfect knight move in one position might be a blunder in another and
I don't see why should the dot always have the upper hand in its battle
with the asterisk here.
GC> But...I thought the shell handled all expansions.
This is true for any Unix-like environment (under MSW, when not running
under Cygwin/MSYS/similar, the expansion may be done by MSVC CRT instead).
GC> Maybe what I'm missing is that
GC> contains the wildcard '*', so the shell must expand it; but
GC> contains no wildcard, so the shell doesn't expand it. Is that right?
GC> So why doesn't
GC> for z in ./. ; do echo $z; done
GC> display anything except the literal string "./."?
What else could it display? echo(1) has no hidden superpowers, it just
echoes back what you give it. And the shell for loop just iterates over
what you give it too. So the loop is executed once, with z="./.". Sorry if
I'm missing something obvious, but I can't imagine what else could be
expected to happen here?
GC> And when I try this:
GC> /opt/lmi/src/lmi$ls ./. |wc -l
GC> /opt/lmi/src/lmi$ls ./* |wc -l
GC> the results differ. Why?
Because in the latter case you're calling ls with a bunch of arguments,
some of which are directories, and as you didn't use the "-d" option, the
contents of these directories is shown by ls too, and not just their names.
While in the former case only the directory names are listed, because you
didn't use the "-R" option neither.
GC> > I.e. our problem is that the command "cp -a foo bar" behaves differently
GC> > depending on whether "bar" exists or not. And "cp -a foo/. bar" definitely
GC> > fixes this problem because it behaves in the same way independently of
GC> > whether "bar" exists or not, so what's not about it?
GC> I want there to be One True Way, and I want to follow it in all cases.
GC> cp -a foo/. bar
GC> is the One True Way, that's okay with me, as long as I write it that
GC> way everywhere. Isn't it a corollary that
GC> mv foo/. bar
GC> ls foo/.
GC> are orthodox, and that
GC> mv foo/* bar
GC> ls foo/*
GC> are heretical?
I'm more of "live and let live" persuasion, so I don't want to start a
holy war over this, but I'd still say that "ls foo/*" doesn't make much
sense. In this case, however, "ls foo/." is rather useless too however
because just "ls foo" works perfectly well.
Hope this helps,