opensmalltalk-vm
opensmalltalk-vm copied to clipboard
Allow choosing an image via zenity when no arguments are provided
Makes it much easier to open an image when you have many images to choose from
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
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:="$@"}
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.