zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] String equal when compared, processed differently via //
@ 2016-09-21  8:57 Sebastian Gniazdowski
  2016-09-21  9:14 ` Sebastian Gniazdowski
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-21  8:57 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
I get an output from git log. It has $'\1' (Ctrl-A), $'\2' (Ctrl-B),
etc. embedded.

Here is how I process the output:

# 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. Output is:

^C15f1acd^Y 'Updated README.md'


While it should be:

^C15f1acd^Y 'Updated README.md' > (HEAD -> master, origin/master)<
^E'4 days ago'^Y Sebastian Gniazdowski

I.E. (HEAD -> master, ...) is something that stops output. However, if
I assign identical input to an array "a" - BY HAND:

a=( "15f1acd"$'\1'"Updated README.md"$'\2'" (HEAD -> master,
origin/master)"$'\3'"4 days ago"$'\4'"Sebastian Gniazdowski" )

and then copy from Git output:

a[2]="${gitout[1]}"

and even compare:

[ "$a[1]" = "$a[2]" ] && echo equal >> /tmp/reply || echo "not equal"
>> /tmp/reply

I get:
- "equal" – compare shows strings are equal
- output:

^C15f1acd^Y 'Updated README.md'
^C15f1acd^Y 'Updated README.md' > (HEAD -> master, origin/master)<
^E'4 days ago'^Y Sebastian Gniazdowski

I.E. Identical input is once interrupted before the "( HEAD -> master,
... )", once processed correctly.


PS. The git command is:

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

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-09-23  7:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21  8:57 [BUG] String equal when compared, processed differently via // 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
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

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).