Zsh Mailing List Archive
Messages sorted by:
Re: Sorting files
- X-seq: zsh-users 9241
- From: Stephane CHAZELAS <Stephane_Chazelas@xxxxxxxx>
- To: Meino Christian Cramer <Meino.Cramer@xxxxxx>
- Subject: Re: Sorting files
- Date: Fri, 5 Aug 2005 11:47:33 +0100
- Cc: duvall@xxxxxxxxxxxxxx, zsh-users@xxxxxxxxxx
- In-reply-to: <20050805.050146.74727615.Meino.Cramer@xxxxxx>
- Mail-followup-to: Meino Christian Cramer <Meino.Cramer@xxxxxx>, duvall@xxxxxxxxxxxxxx, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20050804.211050.78707635.Meino.Cramer@xxxxxx> <20050804191816.GI18173@xxxxxxxxxxxxxxxxxxxxx> <20050804204122.GA6174@sc> <20050805.050146.74727615.Meino.Cramer@xxxxxx>
On Fri, Aug 05, 2005 at 05:01:46AM +0200, Meino Christian Cramer wrote:
> > > print -l **/*(.oL)
> > Should be:
> > print -rl -- **/*(.oL)
> This gave me no sorted output...sorry :O)
I was just pointing out that
print -l arbitrary list of file names
is not correct. print without -r is to print a text that is in
the form "text with \t \n... escape sequences" like in C string
constants. That's an old design error in shells inherited from
ksh to have that as the default behavior. For a correct way, see
perl for instance where \t, \n are expanded at the language
level (or by the double quotes if you like).
$var = "\t"
assigns a <Tab> character to $var and print $var prints the
content of $var. ($var = '\t' assigns "\" and "t" to $var).
assigns the "\" and "t" characters to $var and print "$var"
prints the expansion of the "\t" escape sequence, i.e. a <Tab>
ksh93, bash and zsh have the cumbersome:
that does the same as perl's "\t", but print (and echo) are
still /broken/ and need the "-r" (and -n to prevent adding a
newline character) to print strings asis.
Without --, the list can be options or arguments, while you
definitely mean them to be arguments there.
Another annoying thing with print -l is that without arguments,
it still prints an empty line as if it had been given an empty
So that to print arguments one per line, you actually need:
(( $# == 0 )) || print -rl -- "$@"
or to be portable (POSIX):
[ "$#" -eq 0 ] || printf '%s\n' "$@"
Messages sorted by: