From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19682 invoked by alias); 5 Apr 2018 04:49:00 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23310 Received: (qmail 23132 invoked by uid 1010); 5 Apr 2018 04:49:00 -0000 X-Qmail-Scanner-Diagnostics: from mail-pl0-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.160.48):SA:0(-1.9/5.0):. Processed in 1.915272 secs); 05 Apr 2018 04:49:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=HmCNw1a7unjI5TXdu3rWheXIEbRJei4mo8fbbD1zMhY=; b=haRQnBGhOxUMOxKJlNHJV163YfQY4dhhyOOOb0pkrnhP0YtLXaH30qgS6kTF64nNF0 G9xXBuWeEJu2E/FYyQLsbCAzcn3w6HSpJS1uhUQedLPJf8QfYxNsusMieU9fuWEQOrcy kfgEfwwe+0gKSZovnY9yhIcwJpvgT8nP1PsUq9J6GFbp0AI5BXLkkSCXQpUnWlQMgnh8 EsC3Xm6KsdT+7hE2iEn6h+IgKezGKTUjvuh7iGaKqQ+VntHJ/vTf2VXzRS7fKK7282Mf lBZ9qt9OS1EWDvyGQzyaGQihOuy/Ffwv6PJS/ZjCD0IeB3kNRWKNhaSvQ+iTGy4p+ERt wTig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=HmCNw1a7unjI5TXdu3rWheXIEbRJei4mo8fbbD1zMhY=; b=Lnxnzm3Ls/fN4bs+J/DyRrCjhf+Jz8mi4LCkDq3sZ96Fh76LsSCHXkfk6wbpCaLPlJ Fq89cI3T8rJZDt2L6yGIfydC7X016M1YThx5NVGBI4dkUxfBgvJO18435U7qW2r/+Yro 3srWaYSdC/GurzAzEEzkpKoteR8T9AxA6U8QR5wGkS3fItdrGMcEjSKq83OR4eJSRuvm G/g8gyN8a33dlSie4Bh9gEyPvwASKRKVk2lMPDKq+y9z/f2bpi2qhBo7/7ZkmS9iMgqR t4T84pP7NoISyrhPPSpXiQp9LM8GpI0Tl+R6bUNDKIzQb3YMnNhxRmxLzwO3KsODnv+H rZLw== X-Gm-Message-State: AElRT7E3iKBLhO1vzP7qNpH5ibb3qcZcKN/HxcmscryoHaCSi3U9GOsB nvh6HGWTZracUIMGw2Qvp6MU6+8K X-Google-Smtp-Source: AIpwx4+A6zQv3o6XlffoywNHEGaCQbuZ2yHDdRui0Pfj+fg4qIC1bqBxvU99krowGnlyZ3EPW/tqpA== X-Received: by 10.98.194.133 with SMTP id w5mr16098248pfk.6.1522903735517; Wed, 04 Apr 2018 21:48:55 -0700 (PDT) From: Bart Schaefer Message-Id: <180404214851.ZM25425@torch.brasslantern.com> Date: Wed, 4 Apr 2018 21:48:51 -0700 In-Reply-To: <83ca0dfb-b91f-31d8-5346-c2794f7d8658@eastlink.ca> Comments: In reply to Ray Andrews "Re: counting trouble" (Apr 4, 7:07pm) References: <469d8a16-69c9-79f2-bdce-467886913158@eastlink.ca> <83ca0dfb-b91f-31d8-5346-c2794f7d8658@eastlink.ca> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: counting trouble MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 4, 7:07pm, Ray Andrews wrote: } } On 04/04/18 06:15 PM, Bart Schaefer wrote: } > Please don't think about globbing as returning "lines". It doesn't. } } But: } } tmp=( ${1}*(N) ) } } ... seems to give me exactly that -- an array split on lines But it's NOT lines, any more than the elements of a C array are lines (and internally, to zsh at least, it *IS* a C array of nul-terminated strings -- other shells such as bash use a linked list, etc.). In the shell grammar sense, it's an array of "shell words". A directory does not contain "lines", it contains file names. When you use a glob, you're extracting the matching file names one by one, not grepping a text stream of all those names and then splitting it up at line breaks. } 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. (Except given that construction plus print's usual interpretation of backslash-escapes, you've pasted an extra newline on the final word.) } What would be manna from heaven is to be able to look at an array and } 'see' the construction of it -- how it's split, if one could see the } newlines and/or spaces in both input and output that would be huge. 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. You could step in with a debugger like gdb and use it to display the internal memory allocations. If you know you're writing to an ANSI color terminal and you know the array doesn't contain color changing sequences, you can try something like this: autoload colors colors wstart="$bg[black]$fg[green]<<$reset_color" wend="$bg[black]$fg[yellow]>>$reset_color" printf "${wstart}%s${wend}" "${array[@]}" print Adjust wstart and wend until you have something you think is visible enough. } 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".