1 |
On Tue, 2007-10-02 at 23:18 +0100, Steve Long wrote: |
2 |
> Roy Marples wrote: |
3 |
> > Everything in shell IS a command with the exception of variable |
4 |
> > assignment. Why do you think [ exist in /usr/bin? |
5 |
> > |
6 |
> Yes I know, it's the same reason greycat will often use test -e blah && |
7 |
> blahBlah to show where the command comes from. (Which is why you use 'help |
8 |
> test' to see what tests are actually available.) It doesn't change the fact |
9 |
> that quoting issues show up outside [[, and you need to be aware of them in |
10 |
> bash just as much as in sh. |
11 |
|
12 |
I agree. |
13 |
My argument is that [[ encourages no quoting, hence it showing up more |
14 |
As [ forces people to quote correctly, it should show up less outside of |
15 |
[ or [[ |
16 |
|
17 |
> IMO the real reason you have such an issue with quoting is the redundant |
18 |
> braces which are Gentoo house style; too many newbie scripters think that |
19 |
> cd ${S} is safe when it should be cd "${S}" or more simply cd "$S". I don't |
20 |
> buy the legibility argument since most people use syntax highlighting. It |
21 |
> just sets the parser up for a non-event (yes I am *that* fussy about |
22 |
> cycles.) My suspicion is that it came from echo "${RD}message$NO" |
23 |
|
24 |
Not helped by unpack ${A} which should not be quoted if >1 thing to to |
25 |
unpack. |
26 |
|
27 |
> |
28 |
> > Once you think "everything is a command" then quoting becomes a lot |
29 |
> > easier. [[ ]] removes this concept. |
30 |
> > |
31 |
> Yeah but the point is you learn about quoting for every other command, or |
32 |
> you simply won't be writing reusable scripts (assuming they actually work |
33 |
> for you at all.) |
34 |
|
35 |
Why not learn about quoting for everything? |
36 |
As it's so important, why should [[ be an exception? And as a prior |
37 |
email claimed, [[ sometimes needs quoting anyway just to muddy things |
38 |
even more. |
39 |
|
40 |
> > So in other words, [ ] always needs quotes whereas [[ ]] normally |
41 |
> > doesn't but could need quotes in corner cases. |
42 |
> > |
43 |
> > I know which I'd prefer - certainty over uncertainty. |
44 |
> > |
45 |
> Well to be absolutely honest I've never actually needed them, and I only |
46 |
> mentioned it for completeness as kojiro said there was some case (involving |
47 |
> array expansion iirc, so sh wouldn't even be able to express the metaphor, |
48 |
> let alone get in a twist about it.) It was definitely not the run-of-the |
49 |
> mill issue. I still would not give up pattern and regex matching (to name |
50 |
> my top two) in [[, and definitely not for the trade-down to sh, where you'd |
51 |
> be doing all kinds of odd syntax to get round the limitations of the |
52 |
> lowest-common denominator. |
53 |
|
54 |
Show me an ebuild that uses pattern and/or regex matching please? |
55 |
I don't think you're giving up all that much. |
56 |
|
57 |
[ ... ] |
58 |
|
59 |
This is the posix sh vs bash for eclasses thread, GNU userland vs BSD |
60 |
userland is next months flamewar ;) |
61 |
|
62 |
Thanks |
63 |
|
64 |
Roy |
65 |
|
66 |
-- |
67 |
gentoo-dev@g.o mailing list |