Re: psychiatric help
"Mark J. Reed" <[email protected]> Sun, 5 Apr 2026 13:39:41 -0400
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAA=-s3zNV_qqqa9TT7pVCnLSByDDqyKSQbZH-0ybhFTx4mx8oA@mail.gmail.com> |
> BTW, polite of 'ls' to make multiline output when input is an array.. First, ls doesn't know from shell arrays. It takes a list of arguments. They show up inside the program as an array at the C level, but that's different. Once you get past any options (indicated by -), it interprets the arguments as filenames. With no options it just behaves as a glorified echo and spits those names back out to you - although unlike echo it will complain if any of them don't exist as files. If its output is not going to a terminal, you get the "polite" behavior that outputs one filename per line. Any time you're doing `ls |` or `$(ls)` or `<(ls)`, the output is not going to a terminal, so you get the one-per-line behavior. I still don't know why you need a string and eval instead of just using `$out` directly. -- Mark J. Reed <[email protected]> On Sun, Apr 5, 2026 at 13:28 Ray Andrews <[email protected]> wrote: > > > On 2026-04-04 20:57, Bart Schaefer wrote: > > If you need to copy $@ (et al.) into another variable, use array syntax: > > out=( $@ ) > > Tried this: > > alias tt='noglob _tt' > function _tt () > { > out=( $@ ) # Bart sez. Array will preserve hard space, no > backslash needed. > _execute 'ls $~out' # Need tilde here! > > foo='ls $~out' # Literal string! Don't forget tilde, same as > above. Consistent. > _execute $foo # Plain vanilla var sends literal string, and > 'eval' takes care of it. > } > > run: > > 4 /aWorking/Zsh/Source/Wk 4 % test\ ? > > test a > test b > > test a > test b > > ... so that's got it under control. '_execute' boils down to a call to > 'eval' as you suspect but it does a bunch of other stuff as well. Easy to > drop the ball tho, the chain of handoffs can be fuddled at any point. > Gotta get it right, I was making it harder than it is. 80% clarity. > > Thank you Sensei. > > BTW, polite of 'ls' to make multiline output when input is an array. > > > > >