bash - How do I mark only one selection as TRUE in a dynamic zenity radiolist? -
this code have @ moment - finds files have file extension .sv
, lists them in zenity
radiolist, however, none of items selected. of course, if change awk '{print "false\n"$0}'
awk '{print "true\n"$0}'
they'll selected, don't want.
test_name=$( find ../tests/ -name '*.sv' | awk '{print "false\n"$0}' | cut -d "/" -f3 | cut -d "." -f1 | zenity --list \ --radiolist \ --title "select test" \ --text "tests..." \ --column "box" \ --column "files" ) #select test via zenity
how make first item selected, , rest not? know can done using arrays, suggested this question/answer, require more code. there more elegant way of achieving this?
you can amend awk
command print "true" if first line processed. can remove cut
commands using basename
:
test_name=$( find ../tests/ -name '*.sv' -exec basename {} .sv \; | awk 'nr==1{print "true\n"$0} nr>1{print "false\n"$0}' | zenity --list \ --radiolist \ --title "select test" \ --text "tests..." \ --column "box" \ --column "files" ) #select test via zenity
you use sed
in place of `awk:
sed -e '1itrue' -e '1!ifalse'
Comments
Post a Comment