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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6736 invoked from network); 10 Feb 2021 15:19:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2021 15:19:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612970366; b=fxdaL04ZT34JV4r7BBeJjlNmQkbopkNrcVNX44EgLnF3EWWjknDuu4hO3Ay0Fc1iocu0zCpmGz q+yWhj8bgKvJ70JjOZ1MD+fp/l0WD9hZX1/db5uvhStBrXh5mokQtOSpcU0wrWJteANl6gci5D 3hixzbkV+Qr/oRPsGxr4VDdBi7B36ceReXEEPw0mPuhcUoSpNZwzt9xdiZyAXBsb5Ia3AtI4SJ KVq12vyxCkm5vh4RgQ/Uy4vxvAwZYnl2GREEN3JTNpAiI2Vecac1qWXoyQd9pexb7Quj6VvjCL VDDNiMyTXlt3LdFzHWQ/WRke5N2eL7RwT8TFsEzbtk/MkQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; 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=1612970366; bh=N1eGldWJjanb+RtMb+GodBTf/7P21vOfOkKt9X+nal8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature; b=AY5cHt/1Rsxt7r9JDuN5iTEHf9UYNdlPCbV/WzA/pdQ4zthTGEU1lRm1HeALoWakzmAxR7YUcF uBxuMIWmWYh3Ifu548otFboUArANTH4UiCFrqBV6rDq9x4/KCobLXmQVBOHp0WUSeJfL08pfsN EQ/MmO9Svw+Oh9z2V9zOU1rSYqnlzFIDBeJxV4QWVtXnxIv4XsFzL/Hy3G2VHnGyhraKQLNcMc VxhWDCRsehM5/HxaTPiFfv1sFsPXUQwBk9YLgtfcg8Egud2BjQk3ThzIArx2F0oPkkYSqfzFWA 5WBv37H88SEM/0h2PDLGPQt2CRpsnG4l02mhVf7PvRYP/Q==; 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:In-reply-to:MIME-version:Date:Message-id:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=9xBbtilCPN7ohKuyzpgnhZnZEdE8qj+XpAWGaim/xmc=; b=N1zvfBUgbn8XHwAB43ROMtwhNO hWMBr8grYHpInXAKMZqRxdfZ+nJb320/HaLX5+YlDyAFcZ/X+oGtP87sQFhTgqY1k4J904xhysb/4 NSO9v7t53Fafae1SRJkyU1crNaUYsgnApprsbDyomN71W5rk/3uZjzRSS7tgQd38HykDCkIfiLIUX AKZm5VNnGlIb1+xCYPBWv8Jw+2Ct+N0cRfRhxOcd/YNkSgf9pVAT4rgEIusHrfg7sVQ2u0HU8zQ1W vwPcgZLlTx00k7pnQyBBVsTYQfFPzzDTloJR1sga37CapWg5D1fZgNrAqNhE9wwDEha6lDfGVpeyy EZmusfGA==; Received: from authenticated user by zero.zsh.org with local id 1l9rGz-0008Ov-Mz; Wed, 10 Feb 2021 15:19:21 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:58363) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1l9rGW-00081K-J4; Wed, 10 Feb 2021 15:18:53 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta04.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0QOB0037TB585PF1@mta04.eastlink.ca> for zsh-users@zsh.org; Wed, 10 Feb 2021 11:18:50 -0400 (AST) Received: from [192.168.0.2] ([24.207.90.194]) by Eastlink with ESMTP id 9rGUlSMjznkRC9rGUlZZv8; Wed, 10 Feb 2021 11:18:50 -0400 X-Authority-Analysis: v=2.4 cv=B+J8bMhM c=1 sm=1 tr=0 ts=6023f95a a=zv49KfEsxEDzuN5AGO7r0Q==:117 a=zv49KfEsxEDzuN5AGO7r0Q==:17 a=IkcTkHD0fZMA:10 a=mBNx0INZLjsYhTETJkMA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrheejgdejhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfgtefuvffnkffpmfdpqfgfvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpeekvdeuuefffefhvdeuieetffdvtddvjeegueejkeeiudehieetieehgeetvdfhfeenucfkphepvdegrddvtdejrdeltddrudelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrledtrdduleegpdhhvghloheplgduledvrdduieekrddtrddvngdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.90.194 Subject: Re: protect spaces and/or globs To: zsh-users@zsh.org References: <52D5DA56-397F-40BB-BBA7-CE3BF7256581@larryv.me> <29a203d5-bf53-9cb7-7a49-2705c3b1d8f2@eastlink.ca> <87a6sc3d0c.fsf@lwm.klanderman.net> From: Ray Andrews Message-id: Date: Wed, 10 Feb 2021 07:18:49 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-version: 1.0 In-reply-to: <87a6sc3d0c.fsf@lwm.klanderman.net> Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 8bit Content-language: en-US X-Seq: 26491 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: On 2021-02-09 5:52 p.m., Greg Klanderman wrote:     It works Greg, but it misses the crux of my problem which is that all my wrappers run everything thru 'eval' as below (simplified from your original): grep_wrapper () {   grepargs=()   sstring=   while [[ $# -gt 0 ]] ; do     arg="$1"     shift       grepargs+=( "$arg" )                            # This is what Peter was saying.   done #  grep --color=always -i -- "${grepargs[@]}"         # Works fine but ...   sstring="grep --color=always -i -- ${grepargs[@]}"  # I need to save to a scalar ...   print -rS "$sstring"                                # Write to history ...   eval "$sstring"                                     # And 'eval'.   print -r "\n$sstring" } 9 /aWorking/Zsh/Source/Wk 4 $ . test; grep_wrapper 'on the current' 'i,2,light edit' 'i,1,old stable' grep: the: No such file or directory grep: current: No such file or directory grep: i,2,light: No such file or directory grep: edit: No such file or directory grep: i,1,old: No such file or directory grep: stable: No such file or directory grep --color=always -i -- on the current i,2,light edit i,1,old stable     ... as before the quotes are stripped if I do it my way.  But as I discovered last night: 9 /aWorking/Zsh/Source/Wk 4 $ . test; grep_wrapper "'on the current' 'i,2,light edit' 'i,1,old stable'" i,2,light edit:Find any command named 'mtr*' on the current path. i,1,old stable:Find any command named 'mtr*' on the current path. grep --color=always -i -- 'on the current' 'i,2,light edit' 'i,1,old stable'     ... by simply double quoting the argument string, the single quotes are preserved and 'eval' works. She is NOT being unreasonable.   Just do it her way and everything will be fine. A lesson for life.