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

Re: Useful zsh/datetime things



On 2003-10-09 at 17:27 +0000, Bart Schaefer wrote:
> A useful addition to strftime would be an option to assign the result to a
> parameter, similar to the -A and -H options of "stat" (from zsh/stat).

Reminding myself about this stuff led me to try something, the results
of which have me slightly confused.  I'm trying to figure out what's
happening with "print -l" here.

% stat -H foo -s .
% print -l ${(kv)foo} | pr -at2
% print -l "${(@kv)foo}" | pr -at2

The second command doesn't give proper results, since there is no value
shown for the key 'link', so after that things are mis-placed.

But why is there not a blank line?  If the key exists but is undefined,
it's the empty string?  The third command shows that when treated as the
argument "", a blank line is shown and pr(1) can recombine things
correctly.

Given that there's no white-space splitting happening, why does the
second print differ from the others?

% print -l alpha '' beta '' gamma
% s=''
% print -l alpha $s beta $s gamma
% print -l alpha "$s" beta "$s" gamma

% print $ZSH_VERSION
4.0.6

If I had SH_WORD_SPLIT set, this would make more sense, but I don't.
Behaviour verified with "zsh -f".

I'm missing something really obvious, aren't I?
-- 
2001: Blogging invented. Promises to change the way people bore strangers with
banal anecdotes about their pets. <http://www.thelemon.net/issues/timeline.php>



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