Open Mzed3D opened 2 years ago
escape ampersand "&' this way without quotes '&'
On Thu, 7 Apr 2022, 13:05 Mzed3D, @.***> wrote:
Hello! I really can't manage to use the character "&" for a string in a list dialog. I tryed backslashing it, double quoting it, nothing works. Everytime it is interpreted as an actual command. Is there a way to solve this? Is it a bug? Thanks!
— Reply to this email directly, view it on GitHub https://github.com/v1cont/yad/issues/167, or unsubscribe https://github.com/notifications/unsubscribe-auth/APRODEQ4ZAHYWXIZSZCBCSDVD3FOTANCNFSM5SZEQ5PQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
It worked! Thanks!
or use --no-markup option
Remember to escape "<>" characters too.
#!/usr/bin/env bash
pangoEscape() {
local string="${1//&/&}"
string="${string//</<}"
string="${string//>/>}"
printf '%s' "$string"
}
declare -i index=0
for f in ./*
do
[[ -d "$f" ]] && continue # files only
filelist+=("$(readlink -f "$f")")
f="${f##*/}"
yadlist+=(FALSE "$(pangoEscape "${f}")" "${index}")
let index=index+1
done
choice=$(yad --list --text="Choose some files" --search-column=2 \
--center --borders=20 --width=400 --height=500 \
--checklist --column="Select:CHK" --column="Name:TEXT" \
--column=path:HD "${yadlist[@]}" --separator=' ' \
--print-column=3 --button=OK:0 --button=Cancel:1 )
for key in ${choice}
do
echo "${filelist[${key}]}"
done
Hello! I really can't manage to use the character "&" for a string in a list dialog. I tryed backslashing it, double quoting it, nothing works. Everytime it is interpreted as an actual command. Is there a way to solve this? Is it a bug? Thanks!