Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: protect spaces and/or globs
- X-seq: zsh-users 26478
- From: Lawrence Velázquez <vq@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: protect spaces and/or globs
- Date: Tue, 9 Feb 2021 16:05:12 -0500
- Archived-at: <https://zsh.org/users/26478>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-02/165BE765-9068-4BAC-ABD9-836BD44ADA99%40larryv.me>
- In-reply-to: <a417e71d-f1dd-73ab-6ef0-7ff34e0804fc@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <a417e71d-f1dd-73ab-6ef0-7ff34e0804fc@eastlink.ca>
> On Feb 9, 2021, at 3:42 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> grep allow multiple filespecs of course, and if there are spaces they have to be quoted naturally:
>
> $ grep 'some string' filename 'filename with spaces' more_files*
>
> My wrapper around grep has a problem with that tho because when I'm grabbing the filespecs if I do something like this:
>
> while [[ -n "$1" ]]; do
> ffilespec+=" $1"
> shift
> done
What does your wrapper do that requires accreting a scalar like
this? Simply running
grep $@
would work without issue.
> Obviously the final list of files is chaos once the original enclosing single quotes are stripped off as they are. Trying:
>
> while [[ -n "'$1'" ]]; do
>
> ... as a brute force addition of single quotes works fine with filenames with spaces but it also kills any glob expansions.
This conditional will always return 0. I assume your loop runs
'break' at some point.
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author