zsh-users
 help / color / mirror / code / Atom feed
* Glob sort specifier ideas
@ 2005-12-28  3:57 Jonathan Hankins
  2005-12-28  4:44 ` Jonathan Hankins
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Hankins @ 2005-12-28  3:57 UTC (permalink / raw)
  To: zsh-users

Here are 2 ideas for new glob sort specifiers:

ou for "unsorted" directory order (like "-U" in GNU ls(1)).

oe:string: to run "string" as shell code, like the e:: glob specifier.
This would allow user code to hook into the glob sort system.  It
would work like sort and the "cmp" or "<=>" operators in perl, taking
2 files as arguments, returning -1, 0 or 1 file1 is "less than",
"equal to" or "greater than" file2 in the sort order.

An example use for the oe:string: specifier would be this.  I recently
had a set of patches that shipped as ARJ files.  I needed to extract
them in time stamp order on top of an existing directory hierarchy.
The ARJ files all had the same mtime, but the ARJ header stores a time
stamp when the archive is created.  I created a function to extract
the time stamp from each of the files, and sorted them on that.  It
would be cool to be able to do something like:

  for x in *.arj(oe:myfunc:); do arj x base_dir $x; done

Where myfunc would get called repeatedly as "myfunc file1.arj
file2.arj", returning -1, 0 or 1 to the glob sort system (or whatever)
that would allow it to sort the file list into order.

Thanks,

-Jonathan Hankins

-- 
+------------------+-----------------------------------------------------+
|Jonathan Hankins  | 		       	 jonathan-hankins@mindspring.com |
+------------------+-----------------------------------------------------+


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Glob sort specifier ideas
  2005-12-28  3:57 Glob sort specifier ideas Jonathan Hankins
@ 2005-12-28  4:44 ` Jonathan Hankins
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Hankins @ 2005-12-28  4:44 UTC (permalink / raw)
  To: zsh-users

Cold medicine killing brain...

Jonathan Hankins <jonathan-hankins@mindspring.com> writes:

> would work like sort and the "cmp" or "<=>" operators in perl, taking
> 2 files as arguments, returning -1, 0 or 1 file1 is "less than",
> "equal to" or "greater than" file2 in the sort order.

Oops, wouldn't work for shell code -- would need to put 2 file names
into reply[1] and reply[2], similar to the usage of the reply variable
in the e:string: glob specifier.

>   for x in *.arj(oe:myfunc:); do arj x base_dir $x; done
>
> Where myfunc would get called repeatedly as "myfunc file1.arj
> file2.arj"

Same thing here.

-Jonathan Hankins

-- 
+------------------+-----------------------------------------------------+
|Jonathan Hankins  | 		       	 jonathan-hankins@mindspring.com |
+------------------+-----------------------------------------------------+


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-12-28  4:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-28  3:57 Glob sort specifier ideas Jonathan Hankins
2005-12-28  4:44 ` Jonathan Hankins

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).