How come the Gradle task `JavaExec` doesn’t honor ...
# gradle
c
How come the Gradle task
JavaExec
doesn’t honor carriage returns
("\r")
in Java print statements?
g
Not sure what kind of computer your on, but there is a difference between \r, \l, \l\r a.k.a \n. This goes back to the days of typewriters. i.e. I think your doing it wrong... I think your trying to do \r, which I think is a carriage return when you need a new line aka carriage return + line feed. i.e. try \n
c
Copy code
@Gunslingor I am on a Mac. Running a pre-defined Gradle task. No, I meant what I said when I wanted the carriage return. When you append a "\r" to a print() statement, it effectively starts at the beginning of the line again, which is the desired result.
g
okay, yeah... still I think the problem is related... there have been many times I've been at the CLI and wanted to do that for good status updates, but was denied by some framework or tool I was using. Its translational issue... there could be some way around it using ascii or something.
Jenkins can't candle it, webpack cant either... they interpret these chars differently
\r doesn't mean anything to em I suspect
c
Oh i’ve got good news for you!
From the JavaExec API:
Copy code
* Note: the parser does <strong>not</strong> support using backslash to escape quotes. If this is needed,
* use the other quote delimiter around it.
* For example, to pass the argument {@code 'singly quoted'}, use {@code "'singly quoted'"}.
* </p>
*
and this works!!! :D
g
hmm... interesting
c
yeah, so normally your print statement would look like this:
Copy code
print("${cursor}/${total_rows}\r")
but with their parser you have to surround it with the single-quotes…
Copy code
print("${cursor}/${total_rows}'\r'")
that’s Kotlin, not Java btw…
g
cool, wonder what your compiling too... mac you said... yeah running that on windows may not work, lol
c
yeah it might not, Windows has it’s own idiosyncracies with console output lol