1

My code works with:

binariesPathList="FALSE 'inkscape'
TRUE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage'
FALSE '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage'
FALSE '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape'
FALSE '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape'"

This is to demonstrate how YAD will receive it.

echo $binariesPathList

answer=$(yad
--list
--radiolist
--column="Pick"
--column="Application"
--column="Application Path"
$binariesPathList
)

If you run that last code (Ignore buttons): enter image description here

But fails with the exact same configuration, but three columns. If you run it, you will note that even with the same ' sign, it split by spaces.

binariesPathList="FALSE 'System Default Installation' 'inkscape'
TRUE '1.0 AppImage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage'
FALSE '1.1-dev Appimage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage'
FALSE '0.92.5 Build' '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape'
FALSE 'Master Build' '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape'"

This is to demonstrate how YAD will receive it.

echo $binariesPathList

answer=$(yad
--list
--radiolist
--column="Pick"
--column="Application"
--column="Application Path"
$binariesPathList
)

If you run that last code (Ignore buttons): enter image description here

The really strange thing here is that you can put the parameters directly where the variable should be, and it will work even better than first, and even with those spaces.

It's exactly as a copy-paste of the echo, but if you replace the variable with $(echo $binariesPathList) it will be the same result.

answer=$(yad \
    --list \
    --radiolist \
        --column="Pick" \
        --column="Application" \
        --column="Application Path" \
        FALSE 'System Default Installation' 'inkscape' FALSE '1.0 AppImage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-1.0-4035a4f-x86_64.AppImage' FALSE '1.1-dev Appimage' '/home/jeanfar/Downloads/binary-portable/inkscape/Inkscape-f54ab5f-x86_64.AppImage' FALSE '0.92.5 Build' '/home/jeanfar/git-clones/inkscape-0.92.5/build/install_dir/bin/inkscape' FALSE 'Master Build' '/home/jeanfar/git-clones/inkscape/build/install_dir/bin/inkscape' \
)

If you run that last code: enter image description here

DATALOT
  • 457
  • A workaround could be make the complete yad code a string and use eval "..., because then the $binariesPathList variable will be substituted before they passed to yad. Just like copy-paste the echo. But this is not a really practical solution for every time I have this issue. – DATALOT Jun 21 '20 at 08:05
  • 1
    did you read those comments and links on your last post about the problems inherent in storing commands in variables? Because that's what you're doing here, even if only for the actual command arguments and not for the command name. – ilkkachu Jun 21 '20 at 09:24
  • Ok, your "post" looks very useful, but I always fall in the same issue (the use of eval), because the arguments I'm trying to passe are in a string that the user put trough a text input in yad. That input is converted to a variable, and that variable is what I need to use. – DATALOT Jun 21 '20 at 18:38
  • yes, then I suppose you'll need eval or something else that knows how to parse shell syntax – ilkkachu Jun 21 '20 at 18:45
  • Another method is using the most complex system of regex to split that inputs in $@ then problem solved. But the code would be unreadable and also I know almost nothing (Zero) of regexs. – DATALOT Jun 21 '20 at 19:10
  • well, of course it also depends on if you want to support the full shell syntax, or just something simpler. And if you want to let the the user insert e.g. command substitutions or not. If it's the user themself entering code that eventually runs under their user account, there's no security issue – ilkkachu Jun 21 '20 at 19:17
  • You could use xargs binariesPathList="$(printf "%s" "$binariesPathList" | xargs -n 1 printf "%s\n")" and then

    yad --list --radiolist --column="Pick" --column="Application" --column="Application Path" <<<"${binariesPathList}"

    – Miloš Pavlović Jul 21 '20 at 03:42

0 Answers0