2

On "Linux Mint 16 Petra" i type this command :

zenity --list --column "test" a b c

I select the item 'a', then the returnning value is randomly

a or a|a

How do you explain this ? is it a zenity bug ? How to get only 'a' ?

Regards.

JeffProd
  • 3,088
  • 1
  • 19
  • 38
  • Just found that : select a + keyboard enter returns a|a. Select a + valid button returns a. So how to get 'a' on both cases ? – JeffProd Feb 26 '14 at 16:37

3 Answers3

2

It is a pretty annoying bug. Not the first one this year too.

open=$(find "${@}" -iname "$string" | zenity --list --title "Search results" --text "Please select file or directory to open:" --width 800 --height 600 --column "Files")

work-around:

opens=$(echo $open | cut -d "|" -f2)

Community
  • 1
  • 1
0

When you select "a" with mouse double click (or with the enter key on keyboard), the value is "a|a". When you select it and press "Ok", the value is "a". I don't know exactly why.

A simple workaround could be :

TMP=$(zenity --list --column "test" a b c) # Save the returned value in TMP
VAL=${TMP:0:1} # Keep the first character of TMP and put it in VAL
echo $VAL # VAL = "a", "b" or "c"
Junior Dussouillez
  • 2,327
  • 3
  • 30
  • 39
  • So if values are more than one char, we have to split : `TMP=$(zenity --list --column "test" item1 another andthelast); # Save the returned value in TMP` `IFS='|' read -a array <<< "$TMP"; # split on | if exists` `VAL="${array[0]}";` `echo $VAL;` – JeffProd Feb 26 '14 at 18:53
  • Yes, it's a simple solution to keep the right result. But I really don't know why Zenity returns different results... – Junior Dussouillez Feb 26 '14 at 20:39
0

Print every value in a | separated list : zenity --list --print-column=ALL (...) and get the whole selected row.

yPhil
  • 8,049
  • 4
  • 57
  • 83