Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: protect spaces and/or globs



> 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