Error: 35:64: unknown escape sequence (and 3 more errors)

Labels: area/dependencies kind/bug

Timeline

Matěj Cepl (mcepl) opened

In various situations this happens:

stitny~/b/n/v/vis (master)$ git bug user ls
Building identity cache... Done.
Building bug cache... Done.
stitny~/b/n/v/vis (master)$ git bug user create 
Error: 35:64: unknown escape sequence (and 3 more errors)
stitny~/b/n/v/vis (master)$ 

or

stitny~/b/n/v/vis (devel)$ git bug comment add
Error: Unable to detect default git editor: 35:57: unknown escape sequence (and 3 more errors)

stitny~/b/n/v/vis (devel)$ git config core.editor
editor
stitny~/b/n/v/vis (devel)$ echo $EDITOR
editor
stitny~/b/n/v/vis (devel)$ 

I am not sure what’s the deal with the unknown escape sequence.

Michael Muré (MichaelMure) commented

Hmmm, that's a tough one. Would it be possible that one of you git config file (either repo local, or global) has some formatting or weird character in it?

It's hard to know without a debugger, but my guess would be that go-git fail to read one of your config file.

Matěj Cepl (mcepl) commented

Hmmm, that's a tough one. Would it be possible that one of you git config file (either repo local, or global) has some formatting or weird character in it?

As far as I know, the default encoding is UTF-8, so my name shouldn’t be a problem, should it?

stitny~$ iconv -f utf-8 -t iso-8859-2 ~/.config/git/config |diff -u ~/.config/git/config -
--- /home/matej/.config/git/config	2022-10-20 12:28:37.767262130 +0200
+++ -	2022-10-24 00:28:43.554221003 +0200
@@ -1,5 +1,5 @@
 [user]
-	name = Matěj Cepl
+	name = Mat Cepl
 	email = mcepl@cepl.eu
     signingkey = 0xBD4211B2
 [core]
@@ -93,7 +93,7 @@
 	auth-password = =6D991K0
 [sendemail]
 	smtpserver = localhost
-	from = Matěj Cepl <mcepl@cepl.eu>
+	from = Mat Cepl <mcepl@cepl.eu>
 	chainreplyto = false
 [url "git://git.gnome.org/"]
 	insteadof = gnm:
stitny~$ iconv -f utf-8 -t iso-8859-2 ~/build/neovim/vis/vis/.git/config |diff -u ~/build/
neovim/vis/vis/.git/config -
stitny~$ 

Michael Muré (MichaelMure) commented

Does that solve the problem?

Matěj Cepl (mcepl) commented

Does that solve the problem?

??? What should solve the problem. My locale is cs_CZ.UTF-8 so why shouldn’t I have my configuration files in UTF-8?

Michael Muré (MichaelMure) commented

git-bug should support whatever git itself support. I'm asking because we haven't figured out yet what the problem is.

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) added label Core

Michael Muré (MichaelMure) added label area/dependencies

Michael Muré (MichaelMure) commented

... or rather, it's a weird copy of 2012's scanner.Scanner that evolved from there. Point is, the bug is there.

Michael Muré (MichaelMure) commented

Now, to fix that, it would really help if you could come up with a small example that makes the parser fault.

Matt Broadway (mbway) commented (edited)

I am getting this error too and for me the problem is having an alias spanning multiple lines by escaping a newline. For example having this in my ~/.gitconfig:

[alias]
    myalias = "!f(){ \
        echo hello; \
        };f"

results in:

$ git bug user create
Error: 2:23: unknown escape sequence (and 1 more errors)

as a workaround I'm going to replace these aliases with scripts named git-aliasname in my $PATH instead (which is probably nicer anyway)

Michael Muré (MichaelMure) added label go-git

Michael Muré (MichaelMure) commented

@mbway https://github.com/go-git/gcfg/pull/2 should fix your issue @mcepl I tried but I can't manage to trip the parser with what you gave me

Matěj Cepl (mcepl) commented

Mostly it got fixed somewhere.

Matěj Cepl (mcepl) closed the bug

Matěj Cepl (mcepl) commented

I am getting this error too and for me the problem is having an alias spanning multiple lines by escaping a newline. For example having this in my ~/.gitconfig:

[alias]
    myalias = "!f(){ \
        echo hello; \
        };f"

results in:

$ git bug user create
Error: 2:23: unknown escape sequence (and 1 more errors)

as a workaround I'm going to replace these aliases with scripts named git-aliasname in my $PATH instead (which is probably nicer anyway)

Actually, it seems that's it. I had this alias in my ~/.config/git/config, and when I comment it out git-bug starts to work:

	branch-info = "!sh -c 'git branch --list --no-color | \
	        sed -e \"s/*/ /\" | \
	        while read branch; do \
	        git log -1 --format=format:\"%Cred$branch:%Cblue %s %Cgreen%h%Creset (%ar)\" $branch; \
	        done'"

(replacing it with a script of the same name, fixes the issue).

sudoforge removed label Core

sudoforge removed label go-git