Re: Reintroducing fish, the friendly interactive shell
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 09 Mar 2006 14:54:37 GMT
On 9 Mar 2006 05:17:32 -0800, liljencrantz@xxxxxxxxx wrote:
[...]
In zsh, RE's * is #, RE's + is ##, RE's ? is (...|) (or
nothing). That makes zsh patterns to involve fewer keystrokes.
That also means the grouping can be implemented as (...).
Note that zsh implemented globbing attributes (like case
insensitive, approximate matching, activation of backreference
the same way as perl does: (#...) in zsh, (?...) in perl,
because # can't otherwise follow a ( in zsh the same way as ?
can't otherwise follow a ( in perl.
Isn't this just a new syntax for regular expressions?
It is. It is also one that is compatible (mostly) with historical
globbing and is more suitable for matching filenames than the
standard REs.
Why not simply
use grep to provide you with real regexps?
grep doesn't do filename expansion, and basic REs are not handy
to match filenames.
The unix philosphy of using
a set of orthogonal commands that do one thing each, and connecting
them using pipes is very powerful. Globbing is a _very_ useful hack
that breaks this philsophy by allowing you to perform some types of
very _simple_ matchings inside the shell. The above seems to make
globbing into this huge, hairy beast that can be used for almost
anything find, grep, head, tail, ls and sort do, with a syntax that is
as readable as Perl. What is the point of stuffing all this stuff into
the shell that can be implemented in a more readable and even more
poerful way using external commands?
Maybe because with a few keystrokes, you can do more reliably
than you could have done in a 20 line unreadable script.
[...]
Also, at the prompt, you don't read what you type, it's
write-only. For scripts, zsh has longer forms that you might
consider more readable (like kshglob). Note that zsh also
supports perl regexp (with a builtin in a loadable module).
Why the fixation with avoiding external commands?
Yes, in that case, this doesn't make more sense. the pcre module
is sold as an "example module" though. It may come handy if you
don't have perl.
[...]
ls -S (find . -mmin -120)|head
(or ls -S `find . -mmin -120`|head if you haven't switched to fish yet)
ls -Sd and it doesn't select regular files (or symlinks to
regular file), and it makes the assumtion file paths don't have
newline or blank characters. And -S and -mmin are not Unix.
You use a pipeline containing find, ls and head. That's the beauty of
pipelines
But it's broken by design. Either Unix should prohibit all types
of non-alnum chars in filenames, or command substituion and all
the standard filtering utilities should be changed to be able to
cope with a NUL character separator (zsh is the only shell that
supports the NUL character (maybe fish does as well?)).
use one tool to solve each part of the task, and string them
together in a pipeline to solve a nearly infinite number of problems
with a small set of simple tools.
Yes, in theory it's nice. zsh gives you something more powerful
that doesn't use that framework. You're free to use grep and the
like with zsh. I made my choice ;).
Also notice that the find command is comparable in length to the zsh[...]
version espacially if you use 'echo' to output it to stdout.
On a GNU system, the strict equivalent of zsh's would be:
eval "set -- $(find . -name '*.c' \( -type f -o -type l \) --exec \
find {} -follow -prune -type f -mmin -120 -printf '%s:\p\0' \; |
sort -rnz | awk -v'RS=\0' '
function escape(s) {
gsub(/'\''/, "'\''\\\'\'\''", s)
return "'\''" s "'\''"
}
{NR <= 10} {
sub(/[^:]*:/, "")
printf " %s", escape($0)
}')"
and there's no Unix equivalent.
Is that more readable or short or ortogonal?
It will probably not work with old versions of gawk.
--
Stephane
.
- Follow-Ups:
- Re: Reintroducing fish, the friendly interactive shell
- From: liljencrantz@xxxxxxxxx
- Re: Reintroducing fish, the friendly interactive shell
- References:
- Reintroducing fish, the friendly interactive shell
- From: liljencrantz@xxxxxxxxx
- Re: Reintroducing fish, the friendly interactive shell
- From: Stephane Chazelas
- Re: Reintroducing fish, the friendly interactive shell
- From: liljencrantz@xxxxxxxxx
- Re: Reintroducing fish, the friendly interactive shell
- From: Stephane Chazelas
- Re: Reintroducing fish, the friendly interactive shell
- From: liljencrantz@xxxxxxxxx
- Re: Reintroducing fish, the friendly interactive shell
- From: Stephane Chazelas
- Re: Reintroducing fish, the friendly interactive shell
- From: liljencrantz@xxxxxxxxx
- Reintroducing fish, the friendly interactive shell
- Prev by Date: Re: seperating stdout/stderr to variables
- Next by Date: Re: How to control number of args piped to xargs?
- Previous by thread: Re: Reintroducing fish, the friendly interactive shell
- Next by thread: Re: Reintroducing fish, the friendly interactive shell
- Index(es):
Relevant Pages
|