[Gambas-user] check 4 Gambas Runtime files?

T Lee Davidson t.lee.davidson at gmail.com
Wed Dec 13 19:02:08 CET 2017


[shell-script]
#!/bin/bash

which gbx3 &>/dev/null
if [ $? -ne 0 ]; then
    echo "Gambas runtime (gbx3) not found in path. Cannot continue."
    exit 1 # arbitrary exit code of your choice
fi

if [[ $(gbx3 -e 'Comp(System.FullVersion, "3.10", gb.Natural) >= 0') == "False" ]]; then
    echo "So sorry."
    exit 2 # also an arbitrary exit code
fi

# Great, do Gambas stuff now
[/shell-script]

The line under the "which" statement basically says, "If the exit code from the 'which' command is not equal to zero, then..."


Strangely on my system, this prints, "So sorry," even though my package manager says version 3.10.0 of gambas-runtime is
installed. I have to assume that's an issue with the packager.


-- 
Lee

On 12/13/2017 12:33 PM, mikeB wrote:
> OKAY then - I'll try that (what Tobi wrote). I just didn't really understand it but I will after hack'n at it for awhile;-)
> THANKS - we can put this subject to bed unless someone has
> something else,
> mikeB
> 
> 
> 
> On 12/13/2017 08:44 AM, Karl Reinl wrote:
>> Am Mittwoch, den 13.12.2017, 08:26 -0700 schrieb mikeB:
>>> thats what i was thinking (works only if Gambas is installed) but wasn't
>>> sure.
>>>
>>> I really would prefer NOT to force the end user to install Gambas but
>>> only the v10 runtime files that are required to run the Gambas developed
>>> software/ program. A terminal command to just check if the v10 runtime
>>> files are installed is really what I was looking for;-)
>>>
>>> thanks to all that have taken to time to respond -
>>> it's highly APPRECIATED! Have learned something from every post.
>>> mikeB
>>>
>>> On 12/13/2017 07:43 AM, PICCORO McKAY Lenz wrote:
>>>> the suggestin from tobias are the best for check a specific version string,
>>>> due return a exact result, not an interpretative result
>>>>
>>>> good, but only works if gambas are installed, if not return "commando not
>>>> found"
>>>>
>>>>
>>>>
>>>> Lenz McKAY Gerardo (PICCORO)
>>>> http://qgqlochekone.blogspot.com
>>>>
>>>> 2017-12-13 9:21 GMT-04:00 Jussi Lahtinen <jussi.lahtinen at gmail.com>:
>>>>
>>>>> gbx3 -V
>>>>> or
>>>>> gbx3 --version
>>>>>
>>>>> Works also...
>>>>>
>>>>>
>>>>> Jussi
>>>>>
>>>>> On Wed, Dec 13, 2017 at 9:54 AM, Tobias Boege <taboege at gmail.com> wrote:
>>>>>
>>>>>> On Tue, 12 Dec 2017, mikeB wrote:
>>>>>>> On my web site, that I offer software programmed using Gambas, I have a
>>>>>>> notice :
>>>>>>> ***********************************************************************
>>>>>>> VERY IMPORTANT: before installing this app you will need to install
>>>>>> Gambas
>>>>>>> Runtime  v10 files - most systems will not have these very new files
>>>>>>> installed yet.
>>>>>>>
>>>>>>> Do so via the terminal commands:
>>>>>>> sudo add-apt-repository ppa:gambas-team/gambas3
>>>>>>> sudo apt-get update
>>>>>>> ***********************************************************************
>>>>>>> Now that Gambas runtime 10 files are more common - being install by the
>>>>>>> Distro - is there a way for the user (terminal command) to check if
>>>>>> they are
>>>>>>> installed?
>>>>>>>
>>>>>>> This is a real newbie question I'm sure but hey.. I'm a newbie!
>>>>>>> Thanks for any all help on this matter and have a GREAT day,
>>>>>>> mikeB
>>>>>>>
>>>>>>
>>>>>> First check if the interpreter gbx3 is found in PATH, using the "which"
>>>>>> utility. If not, I wouldn't call Gambas properly installed (although
>>>>>> some people might disagree -- it's their computer -- but then they will
>>>>>> be able to figure their Gambas version out themselves).
>>>>>>
>>>>>> Once you have that, the System class has FullVersion which gives you the
>>>>>> Gambas version as a string and you can compare it like this:
>>>>>>
>>>>>>     $ gbx3 -e 'Comp(System.FullVersion, "3.10", gb.Natural) >= 0'
>>>>>>
>>>>>> Comp will return the sign (-1, 0 or 1) of subtracting the version 3.10
>>>>>> from your Gambas version. You want the comparison to yield 0 or 1.
>>>>>> With the above line, you will see either the string "True" or "False"
>>>>>> printed to the terminal; you can make the output fancier.
>>>>>>
>>>>>> NOTE: gb.Natural makes the comparison by natural sort, which is
>>>>>> appropriate
>>>>>> to compare version numbers. Observe:
>>>>>>
>>>>>>     $ gbx3 -e 'Comp("3.2", "3.10")'
>>>>>>     1
>>>>>>     $ gbx3 -e 'Comp("3.2", "3.10", gb.Natural)'
>>>>>>     -1
>>>>>>
>>>>>> Because "2" comes before "1" in the alphabet, the default lexicographic
>>>>>> comparison mode declares the string "3.2" to be greater than "3.10",
>>>>>> but gb.Natural gets it right.
>>>>>>
>>>>>> Also never coerce the string version into a float for easier comparison
>>>>>> because you'll run into nasty bugs caused by float roundoff.
>>>>>>
>>>>>> Regards,
>>>>>> Tobi
>>>>>>
>>>>>> -- 
>>>>>> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>>>>>>
>>>>>
>>
>> Salut mikeB,
>>
>> reread what Tobi wrote: "which" is the magic command for that.
>>
> 
> --------------------------------------------------
> 
> This is the Gambas Mailing List
> https://lists.gambas-basic.org/listinfo/user
> 
> Hosted by https://www.hostsharing.net


More information about the User mailing list