zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: Fwd: more splitting travails
Date: Fri, 12 Jan 2024 19:06:14 -0800	[thread overview]
Message-ID: <93206b56-b303-460f-a373-fc8ac77e2865@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7Yi+M1vthseF3Awp9JJh5KuFoCbFjLa--a22BGJgEJK_g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2546 bytes --]


On 2024-01-12 14:09, Bart Schaefer wrote:
> Yeah, oddly, there's no straightforward way to get an unaltered file
> into a shell variable.  Even
>    read -rd '' < file
> trims off trailing newlines.

In my situation that would be welcome, tho on principle I do wish the 
culture was: 'If I want something done to my data I'll ask for it'.

> I'm expecting Roman or someone to point out a different trick I've forgotten.

Roman would know.  I have my utility working quite well,   where the 
input isn't an array it's very simple:

     % varis variable

Without the dollar sign.  It evals it internally *after* capturing the 
name. You put the utility inside some function to trace variable values, 
it prints out like:

/
/

    function test1 ()
    {

    local my_variable="Shall I compare thee to a summer\'s day?"
    varis my_variable "some comment"
    }

    0 /aWorking/Zsh/Source/Wk 1 % . test1; test1

    ...

    test1():4 in: test1:6 > "$my_variable" is: |Shall I compare thee to
    a summer's day?| some comment - 18:33:06

    ... It reports name of function, logical line, running file,
    physical line, name of variable, content, some comment if present
    and the time.  I love it.  Anyway, it was all good except that
    arrays print on multiple lines if requested and they were not
    showing any blank lines, which I object to on principle -- so I'm
    trying to fix that.  It's 99% there:

    0 /aWorking/Zsh/Source/Wk 1 % print -l "$vvar[@]"     # What it
    really looks like.
    one two
    three

    four

    five six seven


    eight

    0 /aWorking/Zsh/Source/Wk 1 % varis ,m vvar ! this is comment     #
    squashed array, usually fine but ...

    zsh():15 in: zsh:15 > "$vvar" is:
    one two
    three
    four
    five six seven
    eight
    ! this is comment - 18:41:06

    0 /aWorking/Zsh/Source/Wk 1 % varis ,m "${(@f)vvar}" ! this is
    comment     # ... when I'm determined to see the blanks:

    zsh():16 in: zsh:16 > RAW:
    one two
    three

    four

    five six seven


    eight




    this is comment - 18:41:13


... as discussed I have to twist the shell's arm to get my file into a 
variable as it actually is.  In practice it's not a big deal but on 
principle it would be nice to avoid "  "${(@f) var}" "

This sure looks good:

    0 /aWorking/Zsh/Source/Wk 0 % read -rd '' < testfile2 aaa

    0 /aWorking/Zsh/Source/Wk 0 % print -l $aaa     # Sheesh, it's so
    simple here.
    one two
    three

    four

    five six seven


    eight


[-- Attachment #2: Type: text/html, Size: 4152 bytes --]

  reply	other threads:[~2024-01-13  3:07 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12 19:05 Ray Andrews
2024-01-12 19:19 ` Bart Schaefer
2024-01-12 19:56   ` Ray Andrews
2024-01-12 20:07     ` Mark J. Reed
     [not found]   ` <CAA=-s3zc5a+PA7draaA=FmXtwU9K8RrHbb70HbQN8MhmuXTYrQ@mail.gmail.com>
2024-01-12 20:03     ` Fwd: " Bart Schaefer
2024-01-12 20:32       ` Ray Andrews
2024-01-12 20:50         ` Roman Perepelitsa
2024-01-13  2:12           ` Ray Andrews
2024-01-12 20:51         ` Bart Schaefer
2024-01-12 21:57           ` Mark J. Reed
2024-01-12 22:09             ` Bart Schaefer
2024-01-13  3:06               ` Ray Andrews [this message]
2024-01-13  3:36                 ` Ray Andrews
2024-01-13  4:07                   ` Bart Schaefer
2024-01-13  5:39               ` Roman Perepelitsa
2024-01-13 20:02                 ` Slurping a file (was: more spllitting travails) Bart Schaefer
2024-01-13 20:07                   ` Slurping a file Ray Andrews
2024-01-14  5:03                     ` zcurses mouse delay (not Re: Slurping a file) Bart Schaefer
2024-01-14  5:35                       ` Ray Andrews
2024-01-14 10:34                   ` Slurping a file (was: more spllitting travails) Roman Perepelitsa
2024-01-14 10:57                     ` Roman Perepelitsa
2024-01-14 15:36                     ` Slurping a file Ray Andrews
2024-01-14 15:41                       ` Roman Perepelitsa
2024-01-14 20:13                       ` Lawrence Velázquez
2024-01-15  0:03                         ` Ray Andrews
2024-01-15  0:55                           ` Empty element elision and associative arrays (was Re: Slurping a file) Bart Schaefer
2024-01-15  4:09                             ` Ray Andrews
2024-01-15  7:01                               ` Lawrence Velázquez
2024-01-15 14:47                                 ` Ray Andrews
2024-01-18 16:20                                 ` Mark J. Reed
2024-01-18 17:22                                   ` Ray Andrews
2024-01-18 17:36                                     ` Mark J. Reed
2024-01-18 17:55                                       ` Ray Andrews
2024-01-18 22:34                               ` Bart Schaefer
2024-01-18 23:08                                 ` Ray Andrews
2024-01-19  2:46                                   ` Bart Schaefer
2024-01-19  2:58                                     ` Ray Andrews
2024-01-19 10:27                                       ` Stephane Chazelas
2024-01-19 13:45                                         ` Mikael Magnusson
2024-01-19 14:37                                           ` Mark J. Reed
2024-01-19 14:57                                             ` Ray Andrews
2024-01-19 15:46                                               ` Mark J. Reed
2024-01-19 16:01                                                 ` Mikael Magnusson
2024-01-19 17:15                                                   ` Ray Andrews
2024-01-19 17:42                                                     ` Bart Schaefer
2024-01-19 18:45                                                       ` Ray Andrews
2024-01-14 22:09                     ` Slurping a file (was: more spllitting travails) Bart Schaefer
2024-01-15  8:53                       ` Roman Perepelitsa
2024-01-16 19:57                         ` Bart Schaefer
2024-01-16 20:07                           ` Slurping a file Ray Andrews
2024-01-16 20:14                             ` Roman Perepelitsa
2024-01-16 20:38                               ` Ray Andrews
2024-01-16 20:43                                 ` Roman Perepelitsa
2024-01-16 22:27                                   ` Ray Andrews
2024-01-15  2:00                     ` Slurping a file (was: more spllitting travails) Bart Schaefer
2024-01-15  4:24                       ` Slurping a file Ray Andrews
2024-01-15  6:56                         ` Lawrence Velázquez
2024-01-15 14:37                           ` Ray Andrews
2024-01-15 15:10                             ` Marc Chantreux
2024-01-15 15:29                               ` Mark J. Reed
2024-01-15 16:16                                 ` Marc Chantreux
2024-01-15 16:33                                   ` MUAs (was: Re: Slurping a file) zeurkous
2024-01-16  7:23                               ` Slurping a file Lawrence Velázquez
2024-01-16 14:37                                 ` Ray Andrews
2024-01-17  3:50                                   ` Lawrence Velázquez
2024-01-17  5:10                                     ` Ray Andrews
2024-01-15  7:26                       ` Slurping a file (was: more spllitting travails) Lawrence Velázquez
2024-01-15 14:48                         ` Slurping a file Ray Andrews
2024-01-15 13:13                       ` Slurping a file (was: more spllitting travails) Marc Chantreux
2024-02-10 20:48                     ` Stephane Chazelas
2024-02-11  0:59                       ` Mikael Magnusson
2024-02-11  4:49                         ` Bart Schaefer
2024-02-11  5:04                           ` Mikael Magnusson
2024-02-11  4:46                       ` Bart Schaefer
2024-02-11  5:06                         ` Mikael Magnusson
2024-02-11  7:09                         ` Stephane Chazelas
2024-01-13  2:19           ` Fwd: more splitting travails Ray Andrews
2024-01-13  3:59             ` Bart Schaefer
2024-01-13  4:54               ` Ray Andrews
2024-01-13  5:51                 ` Roman Perepelitsa
2024-01-13 16:40                   ` Ray Andrews
2024-01-13 18:22                     ` Bart Schaefer
2024-01-13 19:08                       ` Ray Andrews

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=93206b56-b303-460f-a373-fc8ac77e2865@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).