zsh-users
 help / color / mirror / code / Atom feed
From: Clinton Bunch <cdb_zsh@zentaur.org>
To: zsh-users@zsh.org
Subject: Re: why is eval needed?
Date: Sat, 19 Nov 2022 12:02:10 -0600	[thread overview]
Message-ID: <fa96928a-ffb9-4821-9ce3-7f064a69cd3f@zentaur.org> (raw)
In-Reply-To: <fda15801-21cb-4916-daae-b816c73f1ab0@eastlink.ca>

On 11/19/2022 11:02 AM, Ray Andrews wrote:
>
> On 2022-11-19 06:43, Roman Perepelitsa wrote:
>> With the default options this this the same as this:
>>      tree '-L 2'
>>
>> Is it clear why it doesn't work?
>
> Actually yes ... but that was only my last effort.  With double quotes 
> the error is:
>
> >  -L 2 [error opening dir]
>
> ... and with no quotes it's:
>
> > test:local:5: not valid in this context: -L
>
> ... to correct myself, it's really the double quoted offering that I'd 
> expect to work.  I'm pretty sure this is an invisible grouping of 
> arguments but I don't know what to do about it other than 'eval'.  I'm 
> thinking that when tree sees: " -L 2 " it's seeing that not as a 
> switch followed by a number, but as a single syntactic element which 
> it's trying to interpret as a directory name.  Which sorta is 
> semi-understandable since the quotes make " -L 2 " into 'one thing' 
> whereas tree want's it to be 'two things'.  How to drop that variable 
> in there so that tree is happy with it?  Is this perhaps a bit of 
> crabbiness on the part of tree?  Should " -L 2 " be an array?? Sheesh, 
> that might keep tree happy.  And ...
>
>     local level=( -L 2 )
>     tree $level
>
> ...
>
> Success!  Ha! You give me enough feedback that I can talk myself out 
> of the problem :-)


Another option is

     local level='-L 2'

     tree $=level


Word splitting level gives the results you want

>
>
>
>
>
>



  parent reply	other threads:[~2022-11-19 18:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19 14:34 Ray Andrews
2022-11-19 14:43 ` Roman Perepelitsa
2022-11-19 17:02   ` Ray Andrews
2022-11-19 17:10     ` Roman Perepelitsa
2022-11-19 18:02     ` Clinton Bunch [this message]
2022-11-19 18:18       ` Roman Perepelitsa
2022-11-19 16:48 ` Stephane Chazelas
2022-11-19 19:12   ` Ray Andrews
2022-11-19 19:50     ` Lawrence Velázquez
2022-11-19 22:21       ` Ray Andrews
2022-11-20  8:55         ` Stephane Chazelas
2022-11-20 13:47           ` Ray Andrews
2022-11-20 15:08             ` Stephane Chazelas
2022-11-20 16:27               ` Ray Andrews
2022-11-20 20:16                 ` Stephane Chazelas
2022-11-20 22:31                   ` Bart Schaefer
2022-11-21  2:13                     ` Ray Andrews
2022-11-20 22:47                   ` 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=fa96928a-ffb9-4821-9ce3-7f064a69cd3f@zentaur.org \
    --to=cdb_zsh@zentaur.org \
    --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).