Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: sorting/uniq-ing an array?



On Aug 9, 12:36pm, Sweth Chandramouli wrote:
} Subject: Re: Re: sorting/uniq-ing an array?
}
} 	i actually had thought that there was some sort of typeset switch
} to do this, but did a man typeset, and didn't see any.  i now realize that
} the typeset manpage on my machine is for the ksh and csh versions, and that
} the zsh one is only in the zshbuiltins manpage.  what do people think of
} maybe merging [zsh builtins manpages] with the equivalent pages for other
} shell builtins?

I don't think this is a good idea.  For one thing, it means replacing the
installed man pages of another app with the man pages from zsh, which may
be impossible for many zsh installers.  For another, it makes the manpages
differ significantly from the info documentation.  Then there's the issue
of "merging" itself -- when do you propose that this happen?  At the time
zsh manual pages are installed?  Even if we could somehow find, parse, and
merge with the existing other shell's manpages, what happens when the other
shell or its manpages are updated?

} > ports=("${=${${(f)$(</etc/services)}:#\#*}%%/*}")
} > 
} > (Note that there I used ${=...} to re-split the ${(f)...} array of lines,
} > so sometimes that _is_ what you want.  I did say _almost_ never.)
} 	this works, which surprises me, since that implies that SH_WORD_SPLIT
} splits on either spaces or tabs (there are both in my /etc/services as
} delimiters between portnames and portnumbers); i thought that IFS was by
} default just a space.  or am i just misunderstanding what you are doing
} here entirely?

No, you understand; IFS is by default space, tab, newline, and nul:

zagzig% echo $#IFS
4
zagzig% echo x${IFS}x | cat -v
x 
^@x
zagzig% 

I don't think other shells have nul in IFS by default, but I'm not sure.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author