Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] String equal when compared, processed differently via //
- X-seq: zsh-workers 39403
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [BUG] String equal when compared, processed differently via //
- Date: Wed, 21 Sep 2016 10:57:48 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=GonAK0f6zLSoVVSDFIrdwqEK63YyVio98/GG0o9ruPw=; b=mhXI4mQp3FuKRkB1Rn/bLngBXb1IHiQ4LOPnTd8UkklP0jzrbbcBh/8m6v+tTQChXl rhQB4NFVOZ9IWim5aF7KNRQxwCw4tBqnVXB/AffXZqqpaU9OO2jeDqcXn8eFUXxf7eWh tfcK6e1x/abrQLWPtAPt2UdiSA23jju1ZtVz1nr+d02eAO5RFArDVuztTlbB8GoEc40v 4PODKOMCazmJ57cjyKour+KwNk7zlCBg6NAzA01HxBIijIzlfd+VZ4xbqKuOfggvSPSO N2T1FqaeeAwZdsu4uXoCuvIIWhAd2kuKEZcRmRgsq+Vy8NQRHOS0wFvRfbcPDmPq1EA7 CWnQ==
- 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
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author