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 11270 invoked from network); 12 Sep 2021 00:24:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2021 00:24:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631406283; b=r8JI1PzCZ+fjAiQhR7rPpi6A26ctavxyvLY8yASFk/cEv3gIWo7CN5yfrQQzaW3WyHuKdyUMfY j9Fj2YuXAtN4P43JJ35I7wk8FQLnamFlX7S54ktkFx60uI337CAsf9tdu3pSLumfwbFAhx6/7X V7vy+L1MjGK48MSflphNQENVZpKZMqZxSk5/1itRgsNWQe6aqi7OeUOOsAAnT5rhsd5325Ffyz Ld6K9pTFYif+F6YYuiQ8qY7zB1fsZlqXEidXERrQywQGAj63O2SXJbD0vMQuX/5wT12w64nmS1 196BCSGONBeCRZF8nuIEasupViebO9t9fCY+abMGBatDrQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f172.google.com) smtp.remote-ip=209.85.219.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1631406283; bh=RdtzmOqmxvZODSM3471xh1RTnN4ZC0MThag9R/MoPrQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=a0hNKlOO4BCuNvDAcEzZ9nhz2EKOpWxhEYV1DhyfKAuKkinH/cA4tD9Uudjb1siF3iDZ9KTCAo 6FUlVYyLrEHw6hrjz2uBBaQO4rIThvxgfAzpaqCN/9ybmBpGp4ibBqdTowc6wNhYRsyMzzgdbW FJnA/Av4gY7YICJnQEvYibCOaYHL/IFS8q+0O812dOsfMnAiNZcex9+pEZ7VBQ8tHTe/u8B6JI PPS0VKkTjy3+E9BWqRUWCxCbd0VMoBdOO4QaOD4mOleN9VA2b3ypUTjhBZlrO9HemOP3fdJe1D T9Ghkq1sRV1VOrP4ncAxCw4yif4DQoj+jKaRiShrNDyX7g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=JnwzCYtABbe8G/mBWOu/n59Yyue/iCD28Zt2kOWe0Y8=; b=EuGELByBhHeDg0EvhbQdf+8i4M AqRYmlO8Yt1Y8oSNRAKLuBaMpLv+xeD3Bqk8trwi8t7GNMdkuWYw0NDEuUzOmaL5hHRRN2Cpy473i Sd9PIkWz9A4NI+oUSrnYar8xexiti3zBuOJPbjzw1iu6qUAs3Ll8uKTsYLWbH4ue0NhLG7TGjv8ed GtNdxZmOxsVkZ02k3nYonThf329fxgTFvvTyNIFarYETlfW9hMoeF8+aW5j25TyHwiBfqLuU733Fm OZIQf+ULsCMvq/a2qaRgYqXuIMLvXEzcDjdmOPORJ83bdTEzH6nvQyXiLtA+/cRj43iVTXKi+5Ctf qrtTFGLg==; Received: from authenticated user by zero.zsh.org with local id 1mPDIZ-000Bo5-0O; Sun, 12 Sep 2021 00:24:43 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f172.google.com) smtp.remote-ip=209.85.219.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-yb1-f172.google.com ([209.85.219.172]:46656) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mPDHk-000B6c-41; Sun, 12 Sep 2021 00:23:52 +0000 Received: by mail-yb1-f172.google.com with SMTP id k65so12244505yba.13 for ; Sat, 11 Sep 2021 17:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JnwzCYtABbe8G/mBWOu/n59Yyue/iCD28Zt2kOWe0Y8=; b=mAjfLKY9pdhRyoQWb6Q0ztuVVZVYUePfJJlrIMhmV2wuRfg2Fi6ADINOyI7TCm36uK 3QKK8XowQ14TIuSnLwJ6C44rBrTL370w8A0473qH9giW2prqCxBQqwgaxfxDuGRs5KS9 7AXMfgkqTHv+T62G2vkzymL1goEqdfDlnbF1qOD0rm2zqQVJ7ihm9teyhqVNhdDm0cK8 e9XY4Ld147SDjeWaTZzc3LbfptxjoS7v+zxI2B+r7V4aIxhMBA+MV51k4ZlAszV0slyX 1GioRpSobBNboASV91dg38/bcQDp6nuukTfEM3/4BkIVfPKmJdS/Lp652ggwk0kyBJm5 FWiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JnwzCYtABbe8G/mBWOu/n59Yyue/iCD28Zt2kOWe0Y8=; b=0a/bJAqPlUMvr+HkF0X7NxsVXVj5ocl8utux+SgWcmC27Nguwq9avWoe4R8KMso5jU aSmV1AQz69oU8IL2N1LkNWUR8kjMBOnGnzy0vt/UVRborRaI4lXcn3itQuJapS1AwtFc B+Ma4hKu+xxdRvaNOb+t8H/tS3viSyTNJuoYJ/qNyY9TarN8wRITN67v+y9Fsk5tjll9 D6tRgVtKGkX3Q1+0lDkjEf6QG33Ecddq3ecAPUhsqnNiBngJh6KcP08y15ZUnAcZBw2T v0pnEP2Q0ksVoTicnVhMsxE/hq6ZZv8Rcgu47wovSdo3sllZJSB/W3fdhgmRpS8Q2a/2 oSkQ== X-Gm-Message-State: AOAM530nEWf+7w60/0JdwxU7xP+NtCAHD0zCLFFCu7IYdibAcdR4qXyK 4Jas4hce4YjIqD8DFZT0EMIIe8F1aZDrvahyBt3lww== X-Google-Smtp-Source: ABdhPJwZ5j8K7Oot4OEU4HAHG8crZ5hsc4MCNH8V6GRL0/Tj+AZvoncYFjIZAAEbSm8d80FommtT1hJIfGLpEl5dMe4= X-Received: by 2002:a25:4ed4:: with SMTP id c203mr6212435ybb.249.1631406230709; Sat, 11 Sep 2021 17:23:50 -0700 (PDT) MIME-Version: 1.0 References: <8432871497e50ae7a6136a9e03a09ad6@dondley.com> <4df9fd0786c03076984bfd7d5cccc34c6780f519.camel@ntlworld.com> <01fed731885d32a336c7b0f31c8f4156@dondley.com> <88e7249e-09d7-4fc2-8b7f-d9e00c86f44f@www.fastmail.com> In-Reply-To: From: Bart Schaefer Date: Sat, 11 Sep 2021 17:23:39 -0700 Message-ID: Subject: Re: Is there any possible way to automatically escape characters when executing an alias in zsh? To: Steve Dondley Cc: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= , Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27114 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: On Sat, Sep 11, 2021 at 4:33 PM Steve Dondley wrote: > > Ok, it's not technically producing an error in the shell but it is an > error with taskwarrior. It doesn't respond properly. Other kinds of > punctuation will also cause more serious problems and confusion. Like > '&'. If you're never using these commands in any sort of pipeline or other structured shell input, why are you using a general-purpose shell for this at all? Why not write a taskwarrior front-end that does nothing but read literal lines without interpretation and pass them along? On Sat, Sep 11, 2021 at 5:04 PM Steve Dondley wrote: > > I just tried on another computer without the escaping function PWS wrote > and taskwarrior strips out all double quotes unless they are escaped. I think you'll find it's the shell that's removing (interpreting) the quotes, not taskwarrior. On Sat, Sep 11, 2021 at 4:15 PM Steve Dondley wrote: > > The non-technical answer is that computers should accommodate us, not > vice versa. I shouldn't have to be knowledgeable about my shell to > interact with an application. But you aren't interacting with "an application" in the sense that you mean it. You're interacting with the shell, which has explicit syntax rules so that you can precisely describe what you intend to have it do. > A good application should be accessible to > non-technical users who may have no idea why they need to type in a > slash into a sentence meant for humans to input and read. You're in effect arguing that this input should not be on a shell command line and instead should always be consumed separately, so that the shell doesn't have to interpret it first. If the only thing that ever follows "tasn" is something that's supposed to be a human-readable sentence interpreted exactly as typed, you can skip the whole business of messing about with checking for quotes etc., but the fact that you're worried about autocompletion suggests that is not the case. On Sat, Sep 11, 2021 at 11:41 AM Steve Dondley wrote: > > I have many aliases set up for taskwarrior in zsh: > > alias tasn="task +sn add"` I'm going to assume that the trailing backquote there is a typo. Here's a modification of PWS's widget, that really does take everything after the word "tasn" (or any other word beginning with "ta" or "tm") as raw human-readable text: taskwarrior-literal() { setopt localoptions extendedglob local -a match # Assumes human never types tab or backslash # and everything after the first word is literal if [[ -z ${BUFFER/(#s)(#b)((ta|tm)[a-z](#c1,) )(*)/} && $match[3] != *\\* ]] then BUFFER="$match[1] ${(@q)${=match[3]}}" fi } zle -N taskwarrior-literal autoload add-zle-hook-widget add-zle-hook-widget line-finish taskwarrior-literal