spring-shell icon indicating copy to clipboard operation
spring-shell copied to clipboard

Get and process raw commands entered by the user

Open NPCDW opened this issue 2 years ago • 3 comments
trafficstars

I hope that an interface can be added before parameter parsing, the function is to obtain and process the original command input by the user.

Here is an example, User input is select * from user where username = 'test'.

After the program parses the parameters, the single quotes are removed.

User must enter select * from user where username = "'test'".

it is very inconvenient.

NPCDW avatar Apr 07 '23 13:04 NPCDW

You've probably misunderstood how terminal works with spring-shell or generally speaking with any other commands a terminal runs.

Lets take an example of a bash in linux:

$ echo foo
foo

$ echo "foo"
foo

$ echo 'foo'
foo

$ echo \'foo\'
'foo'

$ echo \"foo\"
"foo"

$ echo "'foo'"
'foo'

It's a terminal which removes your single or double quotes. You can use escape to keep your quotes or use double quotes with single guotes which will be preserved.

jvalkeal avatar Apr 07 '23 16:04 jvalkeal

When parsing line into words in the source code of spring shell, single quotes are removed image

I hope you can provide this parsing process to developers

NPCDW avatar Apr 08 '23 07:04 NPCDW

Ah so you might have been using interactive mode where things are more or less processed via jline library. I think they made it work remarkable same as normal bash processing.

We could try to look if this can somehow easily tuned by a user but I already know what works for one user, doesn't work for other user. Quotes, double quotes and escaping things has always been a bit annoyance in shell apps. Default functionality will always be so that you can use same command string in both interactive and non-interactive modes.

But yes having some kind of raw mode in interactive mode might be a way to go. Thanks clarifying this use case!

jvalkeal avatar Apr 09 '23 15:04 jvalkeal