zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: protection racket
Date: Tue, 06 Feb 2018 09:13:06 -0800	[thread overview]
Message-ID: <2c7c517c-454c-059f-12f7-5b53b47d55e8@eastlink.ca> (raw)
In-Reply-To: <3c2b2846-0315-453a-e009-7a935f18dd8d@eastlink.ca>

On 05/02/18 01:20 PM, Ray Andrews wrote:
>
>     _execute apt-cache show  \"$1\" \| egrep --color=always \"^\|$1\" 
> \| sed -r \'/^Package: / 
> s/\\x1b\\[\([0-9]\{1,2\}(\;[0-9]\{1,2\})?\)\?[m\|K]//g\' \| sed -r 
> \'s/(Package: .*)/\\x1b\[33\;1m\\1\\x1b\[0m/\'

This solves all issues and is both robust (I think) and understandable:

     ... sed -re \''/^Package: / 
s/\x1b\[([0-9]{1,2}(;[0-9]{1,2})?)?[m\|K]//g'\' ...
^^ ^^

Outer protected single quotes go forward to sed as sed demands, but 
inner single quotes guarantee all characters between them are protected, 
one and all, but are removed as the string goes forward once they've 
done their job of protecting the string.  I'd still like to know why the 
individual characters needed protection  above, but never mind, it might 
be beyond human understanding given how loaded sed strings are with 
potentially special characters, special both to sed and/or to zsh, so 
maybe better not to even think about it when an easy solution is at hand.


      reply	other threads:[~2018-02-06 17:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 21:20 Ray Andrews
2018-02-06 17:13 ` Ray Andrews [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c7c517c-454c-059f-12f7-5b53b47d55e8@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).