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, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28752 invoked from network); 12 Sep 2021 03:03:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Sep 2021 03:03:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1631415798; b=CNkxJ50U4ABVkoc4SsTOxC9B4BAMBcB4jm1YtscOKFKwPnRspEbSC1xDOi3DZbTTMZSNdntHkw KSYe0fQSQOWVcwi1Q2sSzEWndsxNNITranpCTTf9tNEnBHR8Vk+ZiHgwXFR8gNvlanwAOaKxyv 7UMArJtIKHZnaxyMLwLcHIM+bpijfAG4EQ5d5MprWjilPIaWXttoxAZ/amsViEZumfGIDUK4LI LvFWrbhc1XbjV9tOhrzK+l4+5ylJwHc3dyLhXfRIv3EqTSjNepnBGe5Ufan9DQr+Nu3rPSwP5T mny8aExV71twd+YVsTyKyluFb0urqGjmvIYtaY4Di1obMg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (email.dondley.com) smtp.remote-ip=34.203.132.18; dkim=pass header.d=dondley.com header.s=default header.a=rsa-sha256; dmarc=pass header.from=dondley.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1631415798; bh=DF9VaYYLwiKce5UaRCHK82SYTKN2JvMGMER9YUGmy9g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Message-ID:References: In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:DKIM-Signature: DKIM-Signature; b=eZskCFZso0I7UMzwPdZuctrYdey3REDodsar1aT/eY1loiqXoc79mrQ8hN/6BEqkFpGT2WuEsm dTr6zbtQhLhNsbOU1+s2j3U/3NQtGK4oZKGfxC6ByKYGboVUzaWIzOSTbqWDmoi9/PIdpyYFHY yf9S6/UfiXEiIUE501pMrqQh4lmYus7alVKwf+/WbCefYN0xs8w+d9SJwE7ksnKnesGmyVXnXX t5zgnrxD9CwyskMPaNLYwQ5aShnvc/y097S5P62ZVpM7UScpu6x2kllYboUwD0flhVTKWiFVT0 d9ASrVjd05Ob6e15qf8GQDxGJUlDzucxVM9jmBE+opbXNw==; 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-Transfer-Encoding: Content-Type:Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=wbANfcRvXb0SxHJVXjcD90NO8e7g4pxBLIC/c1IPux0=; b=RSpK5oHo+tW0BQ5iyh1hVg2h2x u09NY2waA5wiGqcOsPC3t3ORqpjDH15UOy1bzSKVH5xpQRZLgLekWfyRO0U7cwQFbpHPrUVt4nUkm haE0ux1qAJayllTHKeYHuGAKWVm0DEHJz+FvLPlJesnHUCOfW8a5BJj2KC4B5b4EQBWoR2I74AwQF f+dACgksqdeUu1j/RN498oC9a9kIgPlv7WJaUS2x+0cwEJkUrDR0PyMmlxgUsxXQk4x8doLnYdlzc Fi0vQbxkXi8NAiatXjjV8tbcHHTcI5rA+eGMuoewl34p1smTQ1+mRNecXBvxVe7NAURGYrSdGa2V6 GJHlmxGA==; Received: from authenticated user by zero.zsh.org with local id 1mPFm1-000M5A-G3; Sun, 12 Sep 2021 03:03:17 +0000 Authentication-Results: zsh.org; iprev=pass (email.dondley.com) smtp.remote-ip=34.203.132.18; dkim=pass header.d=dondley.com header.s=default header.a=rsa-sha256; dmarc=pass header.from=dondley.com; arc=none Received: from email.dondley.com ([34.203.132.18]:35646) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mPFl2-000LNn-KL; Sun, 12 Sep 2021 03:02:17 +0000 Received: from email.dondley.com (email.dondley.com [34.203.132.18]) by email.dondley.com (Postfix) with ESMTPSA id 1C8EF20118; Sat, 11 Sep 2021 23:02:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dondley.com; s=default; t=1631415735; bh=DF9VaYYLwiKce5UaRCHK82SYTKN2JvMGMER9YUGmy9g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F7v6x4OkYMEbnN+mPzpi62FsHdsI/QmWvzbhOkjog0A2gE65DAG/HmeNYFxteaX1P LZQ03an0sq0jW6hS9PM8gAb8t8+v3nTVAMmAmx6ckRIVpTmD8dqcaCIaYW7W8Q6nPM e8t2pMcU/GD5nCZAkBLJC5xgtXd7dErxw21C3c15dCiLlqOCMWdufo3Cp6uzDZGcrm ors8lHKnWVjXwrWMeNLrjpqFTFUbIGbPMXSBo4wR3ow+/cESZ7D0uPfkpudKow/H0Y Mjy9l0bpT6WHHJTZ2s6i8CCUMbmpePnFsjBWHVZNCAzNevL+ltr9mSpw/rh5H9d/7d u2lGNjpRjmpXg== MIME-Version: 1.0 Date: Sat, 11 Sep 2021 23:02:14 -0400 From: Steve Dondley To: Bart Schaefer Cc: Zsh Users Subject: Re: Is there any possible way to automatically escape characters when executing an alias in zsh? In-Reply-To: References: <8432871497e50ae7a6136a9e03a09ad6@dondley.com> <4df9fd0786c03076984bfd7d5cccc34c6780f519.camel@ntlworld.com> <01fed731885d32a336c7b0f31c8f4156@dondley.com> <88e7249e-09d7-4fc2-8b7f-d9e00c86f44f@www.fastmail.com> <15168b1d0f01d2561fd2186eb80b2479@dondley.com> User-Agent: Dondley Message-ID: <8057d5df08dc6e28c914b4b3983c3ec3@dondley.com> X-Sender: s@dondley.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Seq: 27117 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: > See for example url-quote-magic. That does the typing for you, and > you can see what it did to make sure it didn't do anything wrong. > PWS's solution (and even my edit thereof) change the input at a time > and place where it's too late for you to fix anything that's awry. I can't think of a scenario off the top of my head but I'm not saying you're wrong. Yes, it's hacky. However, issuing a bad command to TW is not some mission critical problem that can't be easily reversed. Doing the risk/reward calculus, it seems to have far more upsides than potential downs. I wouldn't recommend this as an official part of the TW release, but since this is just a hack for my own use and convenience, I see no harm in deploying it. > You're not understanding. Given that you said -- >> minor completions (none of which will ever contain special characters >> that need to be escaped) > -- taskwarrior-literal should work fine. As with PWS's suggestion, > this kicks in when you press enter (accept-line), so all your > completions are already out of the way, OK, right. and it only quotes things that > need quoting. The difference is that it blindly quotes ANYTHING that > might be interpreted by the shell, including filename globs, etc. I have modified PWS' solution to this: accept-with-quote() { if [[ $BUFFER = (tasn|tast|ta|tat|tm|taa|tai|tau|task)' '* && $BUFFER != *\\* ]]; then BUFFER=${BUFFER//\'/\\\'} BUFFER=${BUFFER//\(/\\\(} BUFFER=${BUFFER//\)/\\\)} BUFFER=${BUFFER//\&/\\\&} fi } This doesn't look nearly as elegant as your solution. But I can (mostly) understand it and modify it myself, which is probably more important for a zsh newb like me. But huge thanks for your time and input. I enjoying kicking the ball around on this stuff. Helps me learn.