From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25318 invoked by alias); 5 Feb 2014 20:21:28 -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: 18403 Received: (qmail 13575 invoked from network); 5 Feb 2014 20:21:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZKATzRkagPKqMW3wIjhxiBdMFowT6KjwQ05LX1InEVY=; b=S8w5ctB5YkwK53zOPevZuHu2TQM25ggV6aaqD4kKvWRaKoBoqzq/nDF6XZhqgncMLc r9rq6Cif8ywAhmfEoAsoW+7vaMMHl1Wu5wdTUfod3Cbnm5tMv4v3EkNGtht2RSmg/l7n 3XMgjJmZhPuHvmSqcC0Pt0al2QC1T+Rk19IlokHcqKK9hBRTB1bkHH7OLo2hCgAyluzB H3Ue9b90nSHYx1JlRGUu1Nrolp3+j7PZO6tMaK5kk0UKNBsZYPZO4cNSdBQ66BeYpzWD +NL2jLmh2jT2TcSwBKNmFxmxWnmoQUm+/DIiEz8xVKaQUa4DL00JyhPZlAa5MwydzUDT xkkQ== X-Gm-Message-State: ALoCoQk3AMYovUPJ+tbK/ZZ5OG5NsfNkx1L0VYNqHIc5GQoL6U7RzcwSYeuiehYriClyPVBXX8gs MIME-Version: 1.0 X-Received: by 10.112.137.137 with SMTP id qi9mr2320876lbb.36.1391631677744; Wed, 05 Feb 2014 12:21:17 -0800 (PST) In-Reply-To: <52F283E8.4050500@eastlink.ca> References: <140204073937.ZM21329@torch.brasslantern.com> <52F1146D.5020801@eastlink.ca> <140204194650.ZM21787@torch.brasslantern.com> <52F283E8.4050500@eastlink.ca> Date: Wed, 5 Feb 2014 12:21:17 -0800 Message-ID: Subject: Re: Access command that called a function within the function. From: Bart Schaefer To: Zsh Users Content-Type: multipart/alternative; boundary=089e012287b8cf7c3304f1ae7fad --089e012287b8cf7c3304f1ae7fad Content-Type: text/plain; charset=ISO-8859-1 On Wed, Feb 5, 2014 at 10:33 AM, Ray Andrews wrote: > I make wrappers for just about all the commands I use constantly, the idea > being to customize things to my taste, and to regularize the common > switches. But I like the wrapper to push the 'real' command to history and > to do that, it must be able to grab the command line unexpanded. If you really want it entirely unexpanded (except for history, there's no way to head that off), then a preexec function is the way to go; you won't even need to mess with noglob, the literal input string is right there in $1. But ... The function pushes the full 'ls ....' line to history for recall, and if > there are wildcards in the command line, I must capture them unexpanded There seems to be a basic flaw in this plan, which is that if you use one or more of these wrappers in a compound command such as a pipeline or (worse) a loop, you're going to get separate history entries written by each wrapper, which won't reflect the surrounding structure. E.g. with your "l" command, if you wrote for directory in *(/); do l $directory/*(.); done You'd get one new history entry for every expanded "ls" command (and maybe *not* one of the "for" loop itself, depending on how you implement it). Is that really what you intend? Further the value of $1 in preexec is going to be the whole "for" loop, which won't be what you need inside each individual command. Which brings us back to TRAPDEBUG and $ZSH_DEBUG_CMD and noglob. --089e012287b8cf7c3304f1ae7fad--