Kotlin / kotlin-interactive-shell

Kotlin Language Interactive Shell
Apache License 2.0
587 stars 36 forks source link

Weird behavior with backslash in ki-shell #111

Closed LaurentBerger closed 2 years ago

LaurentBerger commented 2 years ago

Hi,

configuration windows 10 x64 ki-shell 0.4.5/1.6.10

I try this example in a script : it’s OK

c\:>kotlinc -script char_example.kts
a

?

C:\>

Now I try same code in ki-shell

[33] val aChar: Char = 'a'
[34] println(aChar)
a
[35] println('line 1:9 token recognition error at: '\'
\line 1:9 token recognition error at: '\'
'\n')  //prints an extra newline character

It seems that backslash character cannot be used in console

asm0dey commented 2 years ago

@ligee could you take a look pls?

ligee commented 2 years ago

@LaurentBerger, I'm not 100% sure that I understand, what you mean - the link to the "OK script" leads to some doc page, and the example contains improperly quoted string. But I assume that you're using special characters incorrectly. According to Kotlin docs - https://kotlinlang.org/docs/basic-types.html#characters - the backslash is a special character, so to use it by itself, you need to escape it with another one - '\\' or "\\".

LaurentBerger commented 2 years ago

First line type println("hello") and second line println("\ error

https://user-images.githubusercontent.com/3591626/176933814-ca13c816-b5a1-4525-8b27-e594f72d7ff4.mp4

asm0dey commented 2 years ago

@ligee here is the reproducer: https://asciinema.org/a/r6gQpn7ubTaTXPi8WpCywvA6N

ligee commented 2 years ago

Ok, got it. Looks like jline problem to investigate.

LaurentBerger commented 2 years ago

@ligee Why did you close issue? Is it solved?

ligee commented 2 years ago

@LaurentBerger, yes. Actually, github closed it automatically when I mentioned it in the commit with the fix. You can see it linked to the close message.

LaurentBerger commented 2 years ago

I think that If I want the new version I have to compile myself. Is it right?

asm0dey commented 2 years ago

Hi @LaurentBerger I'll publish it soon

LaurentBerger commented 2 years ago

@ligee @asm0dey

ki-shell 0.5.2-SNAPSHOT/1.7.0
type :h for help
[0] var x:String="bonjour"
[1] println("\nhello")

hello
[2] print("Thanks\n")
Thanks
[3]
asm0dey commented 2 years ago

@LaurentBerger published, please check

LaurentBerger commented 2 years ago

It works

ki-shell 0.5.2/1.7.0
type :h for help
[0] println("\nOK")

OK