zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [BUG] String equal when compared, processed differently via //
Date: Wed, 21 Sep 2016 14:13:09 -0700	[thread overview]
Message-ID: <160921141309.ZM3643@torch.brasslantern.com> (raw)
In-Reply-To: <CAKc7PVDfnz1Vm3=YzmZou5NG3YphyTwsA6-kWX=gHyknJdUJ9g@mail.gmail.com>

On Sep 21, 12:37pm, Sebastian Gniazdowski wrote:
}
} Ah no it doesn't help, it simply doesn't match at all and repeat output ...

I suspect we've mis-communicated somehow.

I made up the little test script appended at the end of this message.
It copies you gitcmd from workers/39403 but modified a little to put
markers around the five bits of output [1|one][2|two][3|three]...

Then it applies first your all-in-one substitution from workers/39403
(with double close brace after $match[2]) my suggested all-in-one
(with double close brace after $match[5]) from workers/39404 and my
for-loop (pattern tweaked to more closely match 39403, before I was
using the pattern from minimal4.zsh that you sent earlier).

What specifically is wrong ("doesn't match at all") with the latter two?

--- 8< -- snip -- 8< ---
#!/usr/bin/env zsh

emulate -LR zsh
setopt extendedglob

gitcmd=( git log --max-count=3 --pretty=format:'[1|%h]%x01[2|%s]%x02[3|%d]%x03[4|%cr]%x04[5|%an]' --abbrev-commit )
gitout=( "${(@f)"$( "${gitcmd[@]}" )"}" )

CMDR_GREEN='{G>'
CMDR_GREEN_E='<G}'
CMDR_MAGENTA='{M>'
CMDR_MAGENTA_E='<M}'

print -rl -- INPUT: "${gitout[@]}" ""

sebastian_out=(
"${gitout[@]//(#b)([^$'\1']#)$'\1'([^$'\2']#)$'\2'([^$'\3']#)$'\3'([^$'\4']#)$'\4'(*)/${CMDR_GREEN}${match[1]}${CMDR_GREEN_E}
${(q-)match[2]}} >${match[3]}<
${CMDR_MAGENTA}${(q-)match[4]}${CMDR_MAGENTA_E} ${match[5]}" )

print -rl -- +++++++++++++
print -rl -- workers/39403: "${sebastian_out[@]}"

bart_out=(
"${gitout[@]//(#b)([^$'\1']#)$'\1'([^$'\2']#)$'\2'([^$'\3']#)$'\3'([^$'\4']#)$'\4'(*)/${CMDR_GREEN}${match[1]}${CMDR_GREEN_E}
${(q-)match[2]} >${match[3]}<
${CMDR_MAGENTA}${(q-)match[4]}${CMDR_MAGENTA_E} ${match[5]}}" )

print -rl -- +++++++++++++
print -rl -- workers/39404: "${bart_out[@]}"

integer i
for ((i=$#gitout; i ; i--)) {
  gitout[i]="${gitout[i]//(#b)([^$'\1']#)$'\1'([^$'\2']#)$'\2'([^$'\3']#)$'\3'([^$'\4']#)$'\4'(*)/${CMDR_GREEN}${match[1]}${CMDR_GREEN_E}
${(q-)match[2]} >${match[3]}<
${CMDR_MAGENTA}${(q-)match[4]}${CMDR_MAGENTA_E} ${match[5]}}"
}

print -rl -- +++++++++++++
print -rl -- for-loop: "${gitout[@]}"
--- 8< -- snip -- 8< ---


  reply	other threads:[~2016-09-21 21:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21  8:57 Sebastian Gniazdowski
2016-09-21  9:14 ` Sebastian Gniazdowski
2016-09-21  9:19   ` Sebastian Gniazdowski
2016-09-21  9:35   ` Sebastian Gniazdowski
2016-09-21 10:35     ` Sebastian Gniazdowski
2016-09-21 10:37       ` Sebastian Gniazdowski
2016-09-21 21:13         ` Bart Schaefer [this message]
2016-09-22 16:48           ` Sebastian Gniazdowski
2016-09-22 16:50           ` Sebastian Gniazdowski
2016-09-21 11:09 ` Sebastian Gniazdowski
2016-09-21 17:59 ` Bart Schaefer

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=160921141309.ZM3643@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).