Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] String equal when compared, processed differently via //
- X-seq: zsh-workers 39404
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] String equal when compared, processed differently via //
- Date: Wed, 21 Sep 2016 10:59:13 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=Os/GG0QeLEGcIcOEOPytgbeJd5CDa7BFImfSpvsBRr4=; b=tA9zMwyYVMZ6iq5+4Odw3WR8tLsHEeC8ReEQUhcEjfyRh6SxCoqrKvKGsWLDjvS9Qj Rr2fKhXZAxJUB8damLYo2NI/yF+yqsG5RKRJenNqphLyxm437BcYSJ/rx7YUVx77LZD+ 5wxPaKLxCPrWfwCeR+oAbgh63Zw+lv9B9GLZgc37KK54AZIjx3QUzGy1CVzUmr+ZTNB/ z7dDBlYT4zYN+pgUnCKar30b+0Vmb0p7c4KhfMoCohMvTOm7OeO7VFDA70Z1UdCEVejD 8uUyVKOqKFIVzdqlTTuv3jv2U9DH4EhQe+uv5kFpwHfKO5BkWocA7NLss8rH+IHyPHGC tBew==
- In-reply-to: <CAKc7PVAdnzTRk8mUZVrFJHKWr_Q9-8whffw7DAUpnkYqwX24yg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAdnzTRk8mUZVrFJHKWr_Q9-8whffw7DAUpnkYqwX24yg@mail.gmail.com>
On Sep 21, 10:57am, Sebastian Gniazdowski wrote:
} Subject: [BUG] String equal when compared, processed differently via //
}
} # hash \1 message \2 repo info \3 date \4 author
} # match[1] match[2] match[3] match[4] match[5]
} gitout=( "${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]}" )
}
} On input, there is:
}
} 15f1acd^AUpdated README.md^B (HEAD -> master, origin/master)^C4 days
} ago^DSebastian Gniazdowski
}
} On output, there should be:
}
} ^C15f1acd^Y 'Updated README.md' > (HEAD -> master, origin/master)<
} ^E'4 days ago'^Y Sebastian Gniazdowski
}
} THE THING IS: output string gets truncated after ^B in the input
} string.
If I replace your single gitout=( ... ) assignment with this loop --
integer i
for ((i=$#gitout; i ; i--)) {
gitout[i]="${gitout[i]//(#b)([^$'\1']#)$'\1'([^$'\2']#)$'\2'([^$'\3']#)$'\3'([^$'\4']#)$'\4'(*)(#B)/${match[1]} ${(q-)match[2]}} >${match[3]}< ${(q-)match[4]} ${match[5]}"
}
-- then I get the output you expect (at least, on a zsh git tree).
I suspect it is because you are referencing $match[3] through $match[5]
outside the closing brace of the ${...//.../...} expression. If I move
the 2nd closing brace from after ${(q-)match[2]} to place it after
${match[5]} instead, then to the best of my understanding I also get
the output you expect.
I looked at all the subsequent "minimal" examples from your follow-up
email and all of them have the 2nd closing brace after $match[2], so
they would all have suffered from this same problem.
That (I:2:) changes anything is mostly coincidental.
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author