[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gbs3 fails with ://
[Thread Prev] | [Thread Next]
- Subject: Re: gbs3 fails with ://
- From: Brian G <brian@xxxxxxxxxxxxxxxx>
- Date: Fri, 26 Apr 2024 08:24:44 -0700
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Well All seems interestingYes it is a bug in that it does not take into account the quotes! Needs to be updates, I am working on fixing that. It is historically a part of gbs3 from near the first iteration and has not been changed.
There is a difference between the gbs3 - and gbs with no dash.With the dash then gbs3 reads the standard in as if it was a file, so no difference than providing a script file name on the command line.
When there is no dash then the special : separator is recognized. so echo -e "print 24\nprint 45" | gbs3 and echo -e "print 24:print 45" | gbs3 are identical! But ..echo -e "print 24\nprint 45" | gbs3 - also works as does ..gbs3 - ..print 24 ..print 45 ..^d whereas by itself ..gbs3 gives an error ..gbs3 Error : no input file specifiedIn effect : is a shorthand for \n. It is also historical back to the days of the original basic language.
So we could right now write a script as: ..vi testcolon ..for i as integer = 0 to 3 ....print 34 : print 45 ....if i = 2 then: print 67 : else :print "this is strange" : endif ....for j as integer = 0 to 20 : wait 0.01 : next ..next ..cat testcolon | gbs3 34 45 this is strange 34 45 this is strange 34 45 67 34 45 this is strange What is not fun about that.... On 4/26/24 07:49, Tim Dickson wrote:
although used for c/c++/sh/bash semicolon (;) does have a predefined use in the basic "print" statement of suppressing tabulated output, for example..dim a as string a="fred" print "hello";a;"blogs" print "hello",a,"blogs" which does make it problematic to use as a statement separator. regards, Tim On 26/04/2024 15:08, Bruce Steers wrote:On Fri, 26 Apr 2024 at 14:25, Rolf-Werner Eilert <rwe-sse@xxxxxxxxxx> wrote:Can confirm that. Was somewhat handy for grouping couple of assignments in a single line. Instead of e. g. x = 4 y = 2 z = 1000 greet = "hello" you could write x= 4: y = 2: z = 1000 greet = "hello" Of course, there is no fun in using it with loops or conditional blocks, but within them is ok. In languages like C and its derivatives you can use the [obligatory] ";" to achieve the same. Regards RolfYes even bash a semicolon ; can be used like && for grouping lines but not : as it has too many other uses.And there's nothing in gambas coding for it.Primary use of gbs3 will be bash scripts/commands so ; would make more sense than : if the conventional 2 chars of \n are just too much for you to type ;) lolPersonally i do not see why : or ; would need to be converted to lf. conventionally we would just use echo -e and \n for newline. This "somewhat handy" feature breaks more than it fixes. it limits the usage of gbs3 just to enable something that's not even needed if you know how to use the echo command properly.But I think ; would be a better choice than : if you must have it as that goes better with shell/scripting conventions.Respects BruceS Am 25.04.24 um 18:47 schrieb Tim Dickson: > A bit of history... don't know if it is the reason for : in gambas as I > think it was also in vb6, but.... > a colon was a standard command/line separator in the days of BBC basic > which was my first intro to coding in the 80's > in that version of basic you could type shortcuts for the keywords, like > P. instead of PRINT which let you squeeze more > code in the 253byte per line limit. > regards, Tim > > On 25/04/2024 15:04, Bruce Steers wrote: >> >> >> On Thu, 25 Apr 2024 at 14:20, Tim Dickson <dickson.tim@xxxxxxxxxxxxxx> >> wrote: >> >> it would seem so. the detection of : is not smart enough to see if >> it is quoted in a string >> echo 'dim a as string:a="coffee:tea":print a'|gbs3 >> gives errors. >> you would need to do >> echo 'dim a as string:a="coffee"&chr$(58)&"tea":print a'|gbs3 >> to get it to work. >> >> >> does not seem right to me. >> conventionally you would just use echo -e and \n for newline >> >> echo -e 'dim a as string\na="coffee:tea"\nprint a'|gbs3 - >> >> It's like the idea to use : for lf was by someone who was not aware of >> the -e arg of echo to process escapes. >> I guess we just need to add to the wiki... >> A colon : is translated to \n unless you use the - argument. >> or replace each : with &chr$(58)& >> >> >> but then your example Tim.. >> echo 'dim a as string:a="coffee:tea":print a'|gbs3 >> >> fails if you use - or not. >> I think there are more problems than benefits to the conversion of : to lf >> And i don't think it's needed as echo -e and '\n' would be the >> conventional way. >> >> I think in my fork i will remove the conversion as i don't like it and >> I didn't even know you could use : for lf. >> and I'll be sure to use echo -e and the - argument in any gbs3 scripts >> for public use. >> >> Respects >> BruceS >> >> >> >> On 25/04/2024 11:30, Bruce Steers wrote: >>> Did you add th code that convert : to lf ? >>> >>> That's terrible >>> >>> Why not just echo -e "line 1\nline 2" ? >>> >>> >>> So a colon cannot be used in any pipe text to GBS unless you want >>> line feeds? >>> >>> On Thu, 25 Apr 2024, 03:07 Brian G, <brian@xxxxxxxxxxxxxxxx> wrote: >>> >>> >>> On 4/23/24 04:04, Bruce Steers wrote: >>>> >>>> >>>> On Tue, 23 Apr 2024 at 00:45, Brian G >>>> <brian@xxxxxxxxxxxxxxxx> wrote: >>>> >>>> >>>> On 4/22/24 16:28, Brian G wrote: >>>>> >>>>> >>>>> On 4/21/24 21:05, Bruce Steers wrote: >>>>>> >>>>>> >>>>>> On Mon, 22 Apr 2024 at 04:58, Bruce Steers >>>>>> <bsteers4@xxxxxxxxx> wrote: >>>>>> >>>>>> This has bugged me a few times. >>>>>> using file:// or http:// the : turns into a >>>>>> linefeed when gbs3 is piped >>>>>> Is it me doing something wrong or is it a bug? >>>>>> >>>>>> echo 'Print "http//www.there"'| gbs3 >>>>>> http//www.there >>>>>> >>>>>> echo 'Print "http://www.there"'| gbs3 >>>>>> # Gambas Project File 3.0 >>>>>> Title=Gambas Script >>>>>> Startup=MMain >>>>>> Vendor=Ordinary >>>>>> Version=0.0.1 >>>>>> License=General Public License 2.0 >>>>>> >>>>>> # Gambas module file : MMain:4:2: Non terminated >>>>>> string >>>>>> >>>>>> 1 :' Gambas module file >>>>>> 2 : >>>>>> 3 :Public Sub main() >>>>>> 4*:Print "http >>>>>> //www.there" >>>>>> ^ Non terminated string >>>>>> 5 :End >>>>>> 6 : >>>>>> 7 : >>>>>> >>>>>> Respects >>>>>> BruceS >>>>>> >>>>>> Aah i discovered this... >>>>>> echo 'Print "file://www.there"'| gbs3 - >>>>>> >>>>>> works okay if i add the dash - >>>>>> >>>>>> I'll use the dash if i need it :) >>>>>> >>>>>> Respects >>>>>> >>>>> >>>>> try >>>>> >>>>> echo 'print "https"&chr(58)&"//www.endofworld"' | gbs3 >>>>> >>>>> Yes it is a bug I guess! >>>>> >>>>> -- >>>>> ~~~~ Brian >>>> >>>> Yes the - causes it to read the stdin as if it were as file until eof >>>> and process it that way. >>>> -- >>>> ~~~~ Brian >>>> >>>> I have a fix, not sure how valid it is... >>>> >>>> A slight change in the _call() method of ParseArgs.class >>>> Ie. >>>> The loop now goes from 0 To aArgs.Max not 1 To aArgs.Max to >>>> still function if there are no args >>>> if no args it checks Lof(File.In) to see if there's data and >>>> add the - arg if yes. >>>> >>>> Public Function _Call(c As Context, aArgs As String[]) As String >>>> Dim I As Integer >>>> Dim sApp As String >>>> Dim index As Variant >>>> If File.Name(aArgs[0]) = "gbw" & System.version Then >>>> c.$bWebPage = True >>>> For I = 0 To aArgs.Max >>>> If I = 0 Then >>>> If aArgs.Count = 1 And If Lof(File.In) Then ' if there >>>> are no args but there is data waiting in stdin >>>> aArgs.Add("-") >>>> Goto gStdIn >>>> Break >>>> Else >>>> Continue >>>> Endif >>>> Endif >>>> Respects >>>> BruceS >>>> >>>> >>>> >>> echo "for i as integer = 0 to 3 : print i : next"| gbs3 >>> 0 >>> 1 >>> 2 >>> 3 >>> $ echo "for i as integer = 0 to 3 : print i : next"| gbs3 - >>> # Gambas Project File 3.0 >>> Title=Gambas Script >>> Startup=MMain >>> Vendor=Ordinary >>> Version=0.0.1 >>> License=General Public License 2.0 >>> >>> # Gambas module file : MMain:4:28:' >>> >>> 1 :' Gambas module file >>> 2 : >>> 3 :Public Sub main() >>> 4*:for i as integer = 0 to 3 : print i : next >>> ^ Unexpected ':' >>> 5 :End >>> 6 : >>> 7 : >>> >>> -- >>> ~~~~ Brian >>> >> >
-- ~~~~ Brian
Attachment:
OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Brian G <brian@xxxxxxxxxxxxxxxx> |
Re: gbs3 fails with :// | Brian G <brian@xxxxxxxxxxxxxxxx> |
Re: gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Brian G <brian@xxxxxxxxxxxxxxxx> |
Re: gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Tim Dickson <dickson.tim@xxxxxxxxxxxxxx> |
Re: gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Tim Dickson <dickson.tim@xxxxxxxxxxxxxx> |
Re: gbs3 fails with :// | Rolf-Werner Eilert <rwe-sse@xxxxxxxxxx> |
Re: gbs3 fails with :// | Bruce Steers <bsteers4@xxxxxxxxx> |
Re: gbs3 fails with :// | Tim Dickson <dickson.tim@xxxxxxxxxxxxxx> |