You can view, comment on, or merge this pull request online at:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408
-- Commit Summary --
* Add file chooser dialog to squeak.sh.in * Add file chooser dialog to bin.squeak.sh.in
-- File Changes --
M platforms/unix/config/bin.squeak.sh.in (13) M platforms/unix/config/squeak.sh.in (13)
-- Patch Links --
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408.patch https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/408.diff
fniephaus requested changes on this pull request.
@@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
/lib|/usr/lib) SVMLLP=/lib:/usr/lib;; *) SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib" esac -LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@" + +# If no image file is provided as a command-line argument, allow the user to +# select the image file via a file-chooser dialog +if which zenity &>/dev/null && [ $# -eq 0 ]; then
Could you please swap left and right? No need to check if `zenity` is installed if there are more args anyway.
@@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
/lib|/usr/lib) SVMLLP=/lib:/usr/lib;; *) SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib" esac -LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@" + +# If no image file is provided as a command-line argument, allow the user to +# select the image file via a file-chooser dialog +if which zenity &>/dev/null && [ $# -eq 0 ]; then + IMAGE=$(zenity --title 'Select an image' --file-selection --filename "${RESOURCES}/" --file-filter '*.image' --file-filter '*')
`IMAGE` is also used for all args (below), so please rename to something like `VM_ARGS`. Also, `${RESOURCES}` is not defined, maybe remove `--filename "${RESOURCES}/"`?
@@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
/lib|/usr/lib) SVMLLP=/lib:/usr/lib;; *) SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib" esac -LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@" + +# If no image file is provided as a command-line argument, allow the user to +# select the image file via a file-chooser dialog +if which zenity &>/dev/null && [ $# -eq 0 ]; then + IMAGE=$(zenity --title 'Select an image' --file-selection --filename "${RESOURCES}/" --file-filter '*.image' --file-filter '*') +else + IMAGE=$@ +fi + +echo "Using image: ${IMAGE}"
Please remove this print message.
@@ -53,4 +53,15 @@ case $PLATFORMLIBDIR in
/lib|/usr/lib) SVMLLP=/lib:/usr/lib;; *) SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib" esac -LD_LIBRARY_PATH="$PLUGINS:$SVMLLP:${LD_LIBRARY_PATH}" exec $GDB "$BIN/squeak" "$@"
See comments for other file...
@MrModder pushed 1 commit.
e73e92d7909d71a8e0d44714ac003ccda59d63be Apply suggested changes to squeak.sh.in
@MrModder pushed 1 commit.
9b8899e84e40539dc9aeb72b7055889fb82bf218 Apply suggested changes to bin.squeak.sh.in
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 notifications@github.com 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; tim@rowledge.org; http://www.rowledge.org/tim Plan to be spontaneous tomorrow.
Closed #408.
@LeonMatthes pushed 0 commits.
vm-dev@lists.squeakfoundation.org