From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10550 invoked by alias); 31 Aug 2018 23:01:31 -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: List-Unsubscribe: X-Seq: 23598 Received: (qmail 26458 invoked by uid 1010); 31 Aug 2018 23:01:31 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f181.google.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(209.85.208.181):SA:0(-1.9/5.0):. Processed in 2.108962 secs); 31 Aug 2018 23:01:31 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_PASS,T_DKIMWL_WL_MED,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qlZBYOmUEBtD33/1OGNAs63Hgj1r5ElrLU4csxZZR+A=; b=me0H0NHKnlTwynS45cvTL/cU10H41e7aKnKRsKe+zhGyIrg/NTi8Y91cN4fCFT/BRr d61AcTa4dFtVkPQ4VhWaDxZwMlDQm/3Fe4BiV4leF3KG7LxYyzYRZivVNVC0PhAZTetk IQTEMlfKBybqdz2q1JT76tC3ECyhSnCvXnl7ZaXW9UsZ+gq05ZNw5ae0lR314ke7YT4Q Nz4hkJTdqlR4nx8c+J8XxovVQ1ltBlDmIp180BmPS4Ms9OOti+E+QUTDUQav7HL3K5bY O/wiPr21GciyfRgYMLHz7FzJ6SIQipcnExnlJLavfIl+dAR3L+4wMdtM6rFv7Xfm7wYP LXgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qlZBYOmUEBtD33/1OGNAs63Hgj1r5ElrLU4csxZZR+A=; b=WlbkzMtMcCdeCXlTbmN2K9m03xrhL3xt4HBTlO2NTSDRLIINziavD5RUksf24K+2pX jVlyyVViwVV/j6l6x7rpmLoOSTnfrWQUtXXdjPYZGs1+sNVEbV9AsEVq+KYbQ7hz+gl8 oBmmFRnsk3H8xDJTDgMLCoKgY09YGFpsM48xtZUQI8VlgoibBxv+TkbkgNeR/4uJ50QC f8wSPdJIxJmMVUZ8BpgCIkWGfyZAzcC1Hik1EKX0cE719EIZ6tEEvOmppzPHEJem2eo3 6cPJky+/eW5/6g01HTsVrTGZPf+ch40/fmOhZJg2PB+D/vzSdFRuLf9DSJS31Mb4mY98 7O1A== X-Gm-Message-State: APzg51B2r19LGEy1LDF3Y7IDnNUWbgrPpaXLBU/iRgnbY2giJFZpkaoV p/j7PSlqyAfjfl2DMFXCCQq3FKml2vyqirK79SUTXw== X-Google-Smtp-Source: ANB0Vdbi/ULNf57V8mAl/G9xTAd2HFw4dvXoM7eqG3KH2QYk42DtV64oLUu0K3R292bBIB+i4IEljyNZ6rizBYRmxhQ= X-Received: by 2002:a2e:5d9d:: with SMTP id v29-v6mr11215151lje.137.1535756485958; Fri, 31 Aug 2018 16:01:25 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Bart Schaefer Date: Fri, 31 Aug 2018 16:01:25 -0700 Message-ID: Subject: Re: Subcommand dispatcher and alias factory To: Leonardo dos Reis Gama Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" On Fri, Aug 31, 2018 at 2:54 PM, Leonardo dos Reis Gama wrote: > > It's a common theme: you have a program with subcommands and want to alter > its default behaviour somehow (what would be easy to do for a common > command with a simple alias or function). > > Is there any zsh plugin that implements either of these features for *any > command*? This can't really be done by the shell in a generalized way, because in a construct like % git myfancything ... the shell MUST first execute "git". Unless all commands with subcommands were to share some standard exit status or error message that would allow the shell to discover that the reason for failure was that the subcommand is not found, the shell has no generic way to know why the primary command failed in order to try it again differently. You can program it separately for each command that has subcommands, as was shown in examples in a couple of the links you mentioned. This, by the way, is why commands with subcommands are basically horrible, and a perversion of the UNIX command model. It's like creating a custom shell within the shell. Which latter is fine if you tell the user that's what you're doing (I was one of the major contributors to a custom shell for managing email, back in the day), but in the git-style incarnation always grates on me in the same way that layering violations in object-oriented programs do.