zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: counting trouble
Date: Thu, 5 Apr 2018 06:45:28 -0700	[thread overview]
Message-ID: <c8585183-8af6-b525-48a2-cedacf87520f@eastlink.ca> (raw)
In-Reply-To: <180404214851.ZM25425@torch.brasslantern.com>

On 04/04/18 09:48 PM, Bart Schaefer wrote:
> But it's NOT lines, any more than the elements of a C array are lines
Ok, I suppose it's worth keeping clear.  In practical terms tho 3/4 of 
my grief with zsh is line/splitting issues.  I can see that this problem 
is fundamental to the way the shells work so no salvation is possible, 
but some way of really getting a grip on things would sure be welcome.
>
> In the shell grammar sense, it's an array of "shell words".
New concept!  Mind, I know what you mean, an array is element based, not 
'terminator' based (except for the null of course).  Thing is, that if 
we could just 'see' the structure things would become more clear.  
Interesting that in C none of this is any sort of issue at all, it's 
always entirely transparent.
> }    print -l "${tmp[@]}\n"
> }
> } ... does exactly what I'm expecting
>
> But print is receiving individual "shell words" as its argument list,
> one array element per word.  The -l option causes print to *add* the
> line breaks.  If you replace -l with -N you don't get line breaks,
> you get nul bytes.
Right, it is worth getting that straight.  I've tended to think of \n's 
as being actually 'in' the data structure.  And that also makes it clear 
why I should stop trying to make echo act on newlines -- they ain't 
there!  But besides output formatting, we also have actual data 
manipulations and the whole thing is invisible.
>
> There's no perfect way to do that because there's intentionally no
> character that you could use to show where the words begin and end
> that can't also theoretically appear IN one of the words.
Jesus! How was this sort of thing permitted back in the day? Astonishing 
that you guys made it all work.
> } If I could see the hidden structure of both input and output there'd
> } be a lot less guessing.
>
> I'm not sure what you consider to be an "input" and what an "output".
>
I mean the way we can read in one data structure and save it to another 
with a different construction.  In view of the above, I'm beginning to 
suspect that half the time my way of getting things to format has been 
via trying to change the data structure itself rather than simply 
controlling output formatting.  This might be easier than I've made it 
-- we don't 'act' on the newlines, we 'print -l' to get each element on 
a new line.  That's quite huge. Of course there can be 'real' newlines 
here and there and that way lies madness.

BTW you were right, in the 'count' issue it does seem I somehow 
stringified the element -- more invisible spells and curses.

print -l ... yes, now I get it.



      reply	other threads:[~2018-04-05 13:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04 18:21 Ray Andrews
2018-04-05  1:15 ` Bart Schaefer
2018-04-05  2:07   ` Ray Andrews
2018-04-05  4:48     ` Bart Schaefer
2018-04-05 13:45       ` Ray Andrews [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c8585183-8af6-b525-48a2-cedacf87520f@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).