opensmalltalk-vm icon indicating copy to clipboard operation
opensmalltalk-vm copied to clipboard

Allow choosing an image via zenity when no arguments are provided

Open LeonMatthes opened this issue 5 years ago • 3 comments

Makes it much easier to open an image when you have many images to choose from

LeonMatthes avatar Jun 17 '19 15:06 LeonMatthes

Hi Leon,

alas I think this way will fail:

if [ $# -eq 0 && which zenity &>/dev/null ]; then VM_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '') else VM_ARGS=$@ fi

LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "${VM_ARGS}"

That's illustrated by the following test programme: -----------8<------------- #!/bin/bash ARGS=$@ echo; echo A for a in "$ARGS"; do echo $a done ARGS="$@" echo; echo B for a in "$ARGS"; do echo $a done ARGS="$@" echo; echo C for a in $ARGS; do echo $a done ARGS=$@ echo; echo D for a in $ARGS; do echo $a done -----------8<-------------

If one invokes this with ./testshellargs.sh 'arg one' 'arg two' then the output is

A arg one arg two

B arg one arg two

C arg one arg two

D arg one arg two

We have to find some way of writing this so that the output is YES!!! arg one arg two

eliotmiranda avatar Jun 29 '19 00:06 eliotmiranda

Hi Leon, the only way I know of doing this is to expand $@ within double quotes at the point of command dispatch. Here's the illustration of the magic incantation:

ZENITY_ARGS= echo 'YES!!!' for a in ${ZENITY_ARGS:="$@"}; do echo $a done

so the right form would be

ZENITY_ARGS= if [ $# -eq 0 && which zenity &>/dev/null ]; then ZENITY_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '') fi

LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" ${ZENITY_ARGS:="$@"}

eliotmiranda avatar Jun 29 '19 01:06 eliotmiranda

On 2019-06-28, at 6:05 PM, Eliot Miranda [email protected] wrote:

ZENITY_ARGS=$(zenity --title 'Select an image' --file-selection --file-filter '.image' --file-filter '') fi

Just a small flag-waving point - on a Pi, at least, that needs to be --file-selection '*.image' to actually show any image files.

tim

tim Rowledge; [email protected]; http://www.rowledge.org/tim Plan to be spontaneous tomorrow.

OpenSmalltalk-Bot avatar Jun 30 '19 17:06 OpenSmalltalk-Bot