[Pharo-users] pharo bash script with startup

Hernán Morales Durand hernan.morales at gmail.com
Wed Jun 27 14:52:19 EDT 2018


2018-06-27 10:50 GMT-03:00 K K Subbu <kksubbu.ml at gmail.com>:
> On Wednesday 27 June 2018 06:39 PM, K K Subbu wrote:
>>
>>
>> The double quotes are required here to skip splitting arguments with
>> embedded spaces into different words.
>>
>> I suspect the error is earlier in the image=$@ assignment. This requires
>> double quotes. Double quotes are also required while calling zenity to avoid
>> word splitting.
>
>
> My earlier fix is also in error, Sorry!
>
> Essentially, we are mixing up single value variable (image) with argument
> array ($@). I found a cleaner fix :
>
> ````
> if [ $# -eq 0 ]; then
>         image_count=`ls "$RESOURCES"/*.image 2>/dev/null |wc -l`
>         if [ "$image_count"  -eq 1 ]; then
>                 set -- "$RESOURCES"/*.image
>         elif which zenity &>/dev/null; then
>                 set -- "$(zenity --title 'Select an image' --file-selection
> --filename "$RESOURCES/" --file-filter '*.image' --file-
> filter '*')"
>         else
>                 set -- "$RESOURCES/Pharo6.1-64.image"
>         fi
> fi
>

Use $() instead of backticks for command substitution:
http://mywiki.wooledge.org/BashFAQ/082

Cheers,

Hernán

> # execute
> exec "$LINUX/pharo" \
>         --plugins "$LINUX" \
>         --encoding utf8 \
>         -vm-display-X11 \
>         "$@"
> ````
>
> HTH .. Subbu
>



More information about the Pharo-users mailing list