From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4058 invoked from network); 9 Feb 2021 20:42:50 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 9 Feb 2021 20:42:50 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612903370; b=j6FU5Hvs+mmMz61LotX3/Z3ZXXdOOFoEyr/5XacQs5pValVs1md3IEXzr7Vbq3Ns4Zh+9H1jUz cfblnHqMI2urlr/8G61wHu+Oq6MaluV2AeOdbKZyYi6+E+Y6jxNclw0GOdWoWQmJlZsRhX4p6t h3KlEnA4Pjo7LowD31mRyqX+wlQLjDb9IxwvyOezwyrw6OrUUnZq2qv6LLHns06uNHJyWxdMVo ObNzcsvlcZCiy5iQuklamrvfACag61IC8FcR+JcqCClrkaf56GLMOnT9fJy+iCgL9HXmuz2NeG Na5VUa8NbbpDQ4v7Q/O/Tyz4/Q3vZSS7RkTQv+sdTi7z3w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1612903370; bh=N+U+pePuqFNy5PKoMxsDKvoySs5w7vcbqvlgGqUzhV8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Date: Message-ID:Subject:From:To:DKIM-Signature; b=w5QJvDmLcurCOTj4l37bl92Lf2wDH0bQIU+UtOqVk7YVMxJSzIt0gIjntWspwfHPSMm05cKTko AGtQbCQe2MOqLDuofAMuDeqsmzG2ywRH1Bf4oN9HNDhBGUiiVBTa33q/myfBVEL6hUL+Zzw+HV 8RjK+8JHGP8mWIL8PtYWHbCYQQvUjfoiWnJTa3QxubGXkfWQxP8+Xjpwqp8Y4cn6aw04Be+1OD zamayJ8c/5Ni38P2A+uHTR2K5GIWXXMsCtw0d5lp8BTVNdZYGcT/WhZVNvjB7AyCEo/vWa3KvA 8brHS67OIndvG18KVciv6MRXKIXy+ovJReqp4re/DV9ebQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:MIME-version:Date:Message-id:Subject:From:To:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=NMH+uGcQCVY0noiqcU1NkgGsbEw4v7O3a1elO3n8s5I=; b=Gm+0ULdcMsUc/pDZOo0LYhUoME 2nT1QETCTmikmmhKv7pqks0vtlbLYWlNiUc330HsNxZWXZKX5EfeXHukfJ4i1vpxF2fI6wJnc3w00 /rr9d3N4AD3+BARxdL2HnvAxYstpXSefY5uXMJRoCVIIalO7cEssrtuv1bh4kjc16VURg2JHLe7Wk Gj6MbnYqcHy7diH+RUIdRiO0h6A5PYC3kMXjt9qaYwa/PUpdbkyFexbxiegSgEdplEuC1Az81Gn2V hYA851jr5Si+fJjmfrOAvBiDWa66k1ItpLJmPWsTRK+CUIigvn4l6KiLkfbM5ndNah4hXC8tsQRL4 Pp3NErFw==; Received: from authenticated user by zero.zsh.org with local id 1l9ZqP-000JqP-VU; Tue, 09 Feb 2021 20:42:45 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:57096) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1l9Zpr-000JTH-Gt; Tue, 09 Feb 2021 20:42:12 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta03.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QOA003I20BLCE61@mta03.eastlink.ca> for zsh-users@zsh.org; Tue, 09 Feb 2021 16:42:08 -0400 (AST) Received: from [192.168.0.3] ([24.207.90.194]) by Eastlink with ESMTP id 9ZpolkhKJsAqK9ZpolcIFE; Tue, 09 Feb 2021 16:42:08 -0400 X-Authority-Analysis: v=2.4 cv=W6f96Tak c=1 sm=1 tr=0 ts=6022f3a0 a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=GjoKkLJ7wJgPCZn1y7wA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheehgddugedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefvhffukffffgggtgfgsehtkeertddtfeejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpeetvefgtdfgueegveduhfelffegteegheeugfegveehkeeftdehjedugedutddtheenucfkphepvdegrddvtdejrdeltddrudelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrledtrdduleegpdhhvghloheplgduledvrdduieekrddtrdefngdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: -100 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 To: Zsh Users From: Ray Andrews Subject: protect spaces and/or globs Message-id: Date: Tue, 9 Feb 2021 12:42:08 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26477 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 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 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. Can I have it both ways? I think I need to preserve any single quotes I add on CL verbatim rather than trying to add them myself in the code.  The various (q) family flags don't seem to work.  The closest I can get is to both single quote and backslash the spaces as the input to my wrapper: g 'some string' filename 'filename\ with\ spaces' more_files* ... and that's not so bad, but I'm betting there's an elegant way. Hafta somehow not break the middle filespec on those spaces even without the backslashes.  And preserve the single quotes. Basically the arguments should pass thru the function absolutely unmolested and grep should get them exactly as I type them.