zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: convert sed to zsh
Date: Thu, 26 Nov 2015 09:49:25 -0800	[thread overview]
Message-ID: <56574625.308@eastlink.ca> (raw)

I'm trying to convert a 'sed' filter to native zsh.  Here's the sed:

     bar=$( echo $foo |
     sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" )

Here's my candidate zsh:

     bar=$foo//$'\x1B'\[([0-9](#c0,2)(;[0-9](#c0,2))#)#[mGK]/}

... so far it's working, but I'm nervous about it.  In another context 
it seems I have to backslash the semi-colon, but here it seems ok either 
way, but of course it should be one or the other. The 'sed' is of course 
the kosher way (I believe) of removing color codes and various other 
escapes like "\e[K" that seem to hang around colorized output of 'grep' 
and so on.  With several different forms of color codes, I want to be 
sure I get this right. Unless of course zsh already has a stock way of 
stripping escape sequences, which it very well might.


             reply	other threads:[~2015-11-26 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26 17:49 Ray Andrews [this message]
2015-11-26 20:17 ` Bart Schaefer
2015-11-26 21:18   ` Ray Andrews

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=56574625.308@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).