smenu -l chops exterior quotes
step- opened this issue · 9 comments
Hi,
either I'm doing something wrong or smenu is. I would like to display and select quoted strings as in the following three choices:
printf %s\\n '"a"' "'a'" 'a'
"a"
'a'
a
but smenu displays the same three unquoted letters:
printf %s\\n '"a"' "'a'" 'a' | smenu -l
a
a
a
Platform: Linux 64-bit
smenu version: 0.9.16
Thank you
Hi,
it's always hard to deal with different kinds of quotes :-)
Please try this:
printf "%s\n%s\n%s" $'\\"a\\"' "\'a\'" a | smenu -l
Thank you. Hmm, while the example you gave does show what I want, it means that smenu needs to be told how to display that kind of input. In other words, "it's always hard to deal with different kinds of quotes :-)" refers to smenu, not to the input itself. It's also hard to predict in advance what gets piped into smenu to "fix" it so smenu can show it verbatim. Would it be possible to add a "verbatim" option to smenu, so that smenu can show its input exactly as it comes in, without mangling quotes?
PS. I suppose that the mangling comes from library routines and not directly from your own source code.
Could you please get the latest git commit of smenu (7304e15) and tell me if it meets your needs?
Note that I will not add a "full verbatim" option to smenu because it must handle some non-printable characters so as not to corrupt the display.
Could you please get the latest git commit of smenu (7304e15) and tell me if it meets your needs?
Thank you. Yes, it meets my needs -- specifically by using the options shown in the first line of this picture. The other lines show some more simple tests that I ran to my satisfaction.
Note that I will not add a "full verbatim" option to smenu because it must handle some non-printable characters so as not to corrupt the display.
OK.
There might be another unrelated problem. Apparently, printf ... | smenu
doesn't print the selection to the terminal window unless smenu's stdout is redirected. You can see it in the picture, where I added | cat
to get some output. Note that where output is missing I did make a selection and pressed ENTER, so there should have been some output. Urxvt is my terminal emulator.
Thanks.
Glad you like this improvement.
The lack of display of the selected word on the terminal is a feature. The goal is to avoid corrupting the display with the output while still sending the selection to stdout, smenu is intended to be used as a filter.
The canonical usage is: OUT=$(print ... | smenu ...); do someting with "$OUT"
Try: OUT=$(printf %s\\n "'a b c'" '"x y z"' "1 2 3" | smenu -l -W $'\n' -T: -d)
Note the -d option.
Yes, option -d is very useful. Can you please tell me what options are needed to output each tagged line on a line of its own? I was looking for something like an output word separator, to set it to $'\n', but couldn't find an option for it. Perhaps this can be done with one of the built-in sed filters?
Simply use $'\n' as an argument for -T as in:
OUT=$(printf ... | smenu ... -T $'\n'); echo "$OUT"
This case is considered in the part of the manual dealing with the -T option.
Perfect. Thank you very much again. You can close this issue as you please.
You're welcome.