From: patata on
On Aug 7, 2:25 pm, Janis Papanagnou <janis_papanag...(a)hotmail.com>
wrote:
> On 07/08/10 13:48, patata wrote:
> > On Aug 7, 1:10 pm, Janis Papanagnou <janis_papanag...(a)hotmail.com>
> > wrote:
> >> On 07/08/10 12:01, patata wrote:
> > This
> > extension will wrap the command and format their output in the
> > standard syntax. Something like:
>
> > reformat ls ...... | sort ...
>
> > or event a sugar syntax:
>
> > @ls ... | sort
>
>
> Sorry, no. This is even worse than I thought it could be made.
>
> Actually what we need is control over the format. So your examples would
> have to be extended to something like
>
>   reformat <format-specifier> ls ...... | sort ...
>
> and you can also just have
>
>   ls ...... | reformat <format-specifier> | sort ...
>
> which nowadays already exists, e.g. as
>
>   ls ...... | awk <format-specifier> | sort ...
>
> But that is inferior to creating the desired set of command specific
> attributes in the first place, as in
>
>   ls <format-specifier> ...... | sort ...
>


Thanks for your comment.

In my opinion, the advantage of external formatters instead of a new
option in existing commands is that the first one doesn't needs
changes in current command implementations.

About if the formatters must be intrinsic to the shell or external, I
thing the first option has several advantages: it allows shell to
contain or access an unified database of parse expressions, instead
of having to write them in each the script; it doesn't needs to fork a
new process; it simplifies the final script syntax.

Kind regards.
From: WANG Cong on
On 08/07/10 18:01, patata <qpatata(a)gmail.com> wrote:

> Hello,
>
> First, let me to thank all people involved in this group for your
> continuous support, that saves me a lot of troubles.
>
> After years as user of shells, several problems with all them appears
> always. Some examples of these problems are:
>
> lack of ortogonality (an example, a command "ls" with some sorting
> rule):
> "ls" has some intrinsic sort capabilities, but not very complete. In
> the same way, lots of commands have several sorting capabilities,
> always limited and duplicated to the others
> "sort" command could have a complete set of capabilities, but then it
> must parse the "ls" output, something not always easy.
> It seems we have not a shell who allows a powerful "sort" command or
> librarian to merge easily with any "data provider" (ls).
>

*For your 'ls' example only.*

This lets me remind the zsh feature, glob qualifiers. It helps you
to select the desired files without using 'ls'. For example, you can
select regular files by:

% echo *(.)

or directories:

% echo *(/)

etc. What's more, you can also select by permissions, e.g. selecting
files with read permission of the current user:

% echo *(r)

or a more complex one:

% echo *(r^w)

to select files with read permission but not write permission.

And much more. :)

See how zsh solves this problem? It doesn't even bother pipes.

Hope this helps.

--
Live like a child, think like the god.

First  |  Prev  | 
Pages: 1 2 3 4
Prev: Regular Expression
Next: Symbol for "not" within []