Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: unmatched '
- X-seq: zsh-users 23224
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: unmatched '
- Date: Fri, 9 Mar 2018 12:23:10 -0800
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SQsr2J9VdyKd58hx+6jCpuX0LXoRXhQ2eBodG0Dbe88=; b=B8A/eqqoZtlLZborune1UCFa0x4bTdfvPZepCz4CLLJiiU0+6ihP0pbib70yezeSGp B/UzpKXfpUQLj2poko5oOnWPOXYLdSlfppIv7+JhVEvFihB8yV0FFa+TtS5+eQwFdCQb Wu8S2u/ufbv0bu3/HBDh3UDlMcjZT5wRWPNKVNLau2VXGKXaF/pluGUeIrgJiN6mP8IJ exP0T0QXHJxOE+su9h8bfe6UwoVIHuyPbA60q4juInNEcpQ44HWH76UmqaLBbYuseYdj IcBerGph8soWklMHxZ6maORmMyjU3ovh0fliGNdqUqgoC3iTIVy3O5GDJA2FLuOBJaJL +k+Q==
- In-reply-to: <2dcec644-7acb-5916-2858-2301206f1da8@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <2dcec644-7acb-5916-2858-2301206f1da8@eastlink.ca>
On Fri, Mar 9, 2018 at 9:50 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> $ c etc
>
> (eval):1: unmatched '
>
> I suspect this abomination:
>
> /etc/DSHR's Blog: Using the official Linux overlayfs_files
>
> ... God knows why that's permitted, but I'm thinking that the single quote
> is doing the obvious thing as far as 'eval' in concerned. Can I prevent
> that? Or, if it must be an error, can I get eval to ignore it somehow? The
> offending line is this:
>
> baz=(`eval print -l $bar $grepstring`)
You really should never do this with "eval". Consider what happens if the
file name is /etc/Why you should never `rm -rf /`
(Obligatory warning: DO NOT TRY THAT AT HOME.)
Why are you putting stuff like that file in /etc/ in the first place?
It's not meant to be a scratch or documentation directory, it's
supposed to contain system-wide configuration files.
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
> ... I want to sent the output of printing '$bar' after it's been piped
> through the chain of greps that are built up and saved in the '$grepstring'
If $bar is a file name with spaces in it, `eval print -l $bar` is
going to split the name up on the spaces and write one "word" of the
file name on each line. Is that actually what you intend? Otherwise
unless $bar is an array, you don't need the -l option of print,
because you're always printing just one line anyway.
If $bar is a file name that begins with a hyphen, "print" is going to
try to interpret that as options.
Based on your description there must be a leading "|" in $grepstring.
Don't do that.
Assuming you've carefully sanitized $grepstring to avoid gotchas like
unintentional `...` or $(...) substitutions, the closest you should
ever get to what you're doing is
baz=( `print -lr -- "${bar[@]}" | eval "$grepstring"` )
There's probably a better way to do your cascade of greps, too, such
as building a file with one pattern per line and running a single
"grep -f patternfile", but you haven't provided sufficient context.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author