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

[no subject]



[...]

    >> for i in **/*(/); do (cd $i; [[ -n "$(print *.c(N))" ]] &&etags
    >> *.c) ; done

    Joe> Looks interesting, though no less opaque than the bash
    Joe> version.  I'll read up on zsh.

Pretty much the same as the bash version, but to elaborate on a couple
of the zsh-isms:


**/*(/) -- '**' is a shorthand for (*/)# which means match zero or
           more directory names; "*" the same as any other shell, and
           "(/)" means limit to just directories; so this expands to
           the name of every directory under .

*.c(N)
        -- This expands to all files matching *.c, but the (N)
           modifier says don't gripe if there's no matches (it just
           disappears from the command line)


[[ -n "$(print *.c(N))" ]]
        -- This uses a subshell to make a string of the names of any
           .c files in the current directory; if there's none it'll
           be a zero length string, and the -n test (non-zero length
           string) will fail


Actually that last bit's not really strictly a zsh-ism, as you could
do something similar with bash like


[[ "$( echo *.c )" != "*.c" ]] && etags *.c


since it'll leave the glob unchanged if there's no matches (rather
than the csh-y way zsh complains).


And really it could be done without $()/`` in zsh by setting an array
a=(*.c(N)) and then testing [[ -n "$a" ]] instead.


But I'm going to stop piddling with it now. :)

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00566" href="msg00566.html">[ale] I need a bash clue.</a></strong>
<ul><li><em>From:</em> jknapka at kneuro.net (Joe Knapka)</li></ul></li>
<li><strong><a name="00572" href="msg00572.html">[ale] I need a bash clue.</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
<li><strong><a name="00574" href="msg00574.html">[ale] I need a bash clue.</a></strong>
<ul><li><em>From:</em> jknapka at kneuro.net (Joe Knapka)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00576.html">[ale] Coldfusion MX / Mandrake 10</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00578.html">[ale] OS conference endures PowerPoint requirement on Day 1</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00574.html">[ale] I need a bash clue.</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00568.html">[ale] Re: important</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00577"><strong>Date</strong></a></li>
<li><a href="threads.html#00577"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>