From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25863 invoked by alias); 22 Jan 2017 19:33:51 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22405 Received: (qmail 19603 invoked from network); 22 Jan 2017 19:33:51 -0000 X-Qmail-Scanner-Diagnostics: from mercury.zanshin.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(64.84.47.142):SA:0(-0.0/5.0):. Processed in 2.499446 secs); 22 Jan 2017 19:33:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at ipost.com designates 64.84.47.142 as permitted sender) Date: Sun, 22 Jan 2017 10:26:20 -0800 (PST) From: Bart Schaefer Reply-To: Bart Schaefer To: zsh-users@zsh.org Subject: Re: Avoiding the zshells intelligence...in one case In-Reply-To: <20170122080153.GA5042@solfire> Message-ID: References: <20170122080153.GA5042@solfire> User-Agent: Alpine 2.00 (LRH 1167 2008-08-23) X-Face: "f/X=UCVgd*^c>+x(gMq0at?e:woX+;'snkkRzc3SX<0AZ (/PS4.M2hzGS9X:Qj]at_H/%a9K}:-eS<"v_7vX84PG9Bf Zpb`wI!I4geY=or+nWq`3CX`oq&TJR;g^ps|7(MH?jh;bs %vHJfCh5>a*6Re5m|Bidja\\o]>n\A)ib1:yX*T`zR(*h~ %tOw<~!D9{e6h!8M2:d8G2@K>y^1I_Vdy\d\MYe]z7c MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 22 Jan 2017, Meino.Cramer@gmx.de wrote: > Previously I used commands like > > zscript 'http://' > > but over the time I get annoyed by the '' since the > stuff in between was cute'n'pasted from somewhere else. > > Is there any way to write a script/alias which takes > its first/nth argument verbatim and character by character > without any intelligent intervention of the zshell? You have a few choices: One is to use url-quote-magic (and possibly one of bracketed-paste-magic or bracketed-paste-url-magic) so that the quoting is done for you by the editor when you enter the URL. Another is to use the "noglob" modifier, although that won't quote things that look like other expansions, so if your URLs contain "$" or "{" "}" all the following will fall short. Simplest: alias zscript='noglob zscript' However, this will apply to all arguments, not just the first. So one workaround is this convoluted looking thing: # Quote the first N-1 arguments [of the alias] and glob the Nth+ globN+ () { ${(b)@[2,$1+1]} ${~@[$1+2,-1]} } alias zscript='noglob globN+ 2 zscript' You can perhaps see how to extend that to quoting specific positions. (Aside to zsh-workers, it'd be nice if "noglob function { body } args" worked to call an anonymous function without globbing. Hard, I bet.) The most radical choice is to "setopt nonomatch", but that's probably more than what you want. However, you can combine that with noglob: nonomatch() { setopt localoptions nonomatch; ${~@} } alias zscript='noglob nonomatch zscript' Note this doesn't recursively expand the alias because alias expansion occurs before parameter expansion, so $1 will always be looked up as a function, builtin, or command within the nonomatch function.