VBScript argument names must have length > 1

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

VBScript argument names must have length > 1

John Brown
Hello All,

The following VBScript simply displays the values of a named argument
passed to the script., so `cscript test.vbs /n:john' should print

n = john

'Single quote is comment like //
'BEGIN SCRIPT
Set args = WScript.Arguments.Named
If args.Exists("n") Then
    ' & operator concatenates strings
    WScript.StdOut.WriteLine "n = " & args("n")
Else
    WScript.StdOut.WriteLine "argument n was not passedt"
End If
'END SCRIPT

This script does not work in a MSYS window if the argument name is only
one letter.

=====
$ cscript test.vbs /n:john
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

argument n was not passed
=====

It works as expected under CMD, even when cmd.exe is launched from
a MSYS window.

=====
$ c:/windows/syswow64/cmd.exe /c "cscript test.vbs /n:john"
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

n = john
=====

If the name has more than one letter e.g. `cscript /first:john' it works
in MSYS.

Regards
John Brown.
     
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: VBScript argument names must have length > 1

Keith Marshall
On 22/10/14 10:57, John Brown wrote:

> The following [snipped] VBScript simply displays the values of a
> named argument passed to the script., so `cscript test.vbs /n:john'
> should print
>
> n = john
>
> [...snip...]
>
> This script does not work in a MSYS window if the argument name is only
> one letter.
>
> =====
> $ cscript test.vbs /n:john

PEBKAC.  The *documented* way to express this, in MSYS shell, is:

  $ cscript test.vbs //n:john
                     ^^

> Microsoft (R) Windows Script Host Version 5.8
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> argument n was not passed
> =====
>
> It works as expected under CMD, even when cmd.exe is launched from
> a MSYS window.

Naturally enough, I guess, because cmd.exe doesn't recognize / as a
directory name separator.

> =====
> $ c:/windows/syswow64/cmd.exe /c "cscript test.vbs /n:john"
> Microsoft (R) Windows Script Host Version 5.8
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> n = john
> =====
>
> If the name has more than one letter e.g. `cscript /first:john' it works
> in MSYS.

That's surprising; you should still require the double //.

--
Regards,
Keith.

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: VBScript argument names must have length > 1

John Brown


On Wed, 22 Oct 2014 14:35:03 +0100, Keith Marshall wrote:
>
> On 22/10/14 10:57, John Brown wrote:
[snip

>> This script does not work in a MSYS window if the argument name is only
>> one letter.
>>
>> =====
>> $ cscript test.vbs /n:john
>
> PEBKAC. The *documented* way to express this, in MSYS shell, is:
>
> $ cscript test.vbs //n:john
> ^^

Where is this documented?

>>
>> If the name has more than one letter e.g. `cscript /first:john' it works
>> in MSYS.
>
> That's surprising; you should still require the double //.
>

When the argument name is more than one letter, it works with or without
the extra /, but issue is fixed. Thanks.

Regards,
John Brown.
     
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: VBScript argument names must have length > 1

Keith Marshall
On 22/10/14 15:15, John Brown wrote:

> On Wed, 22 Oct 2014 14:35:03 +0100, Keith Marshall wrote:
>> On 22/10/14 10:57, John Brown wrote:
> [snip
>>> This script does not work in a MSYS window if the argument name is only
>>> one letter.
>>>
>>> =====
>>> $ cscript test.vbs /n:john
>>
>> PEBKAC. The *documented* way to express this, in MSYS shell, is:
>>
>> $ cscript test.vbs //n:john
>>                    ^^
>
> Where is this documented?

In the README.rtf file which comes with MSYS; (mingw-get installs it as
/share/doc/MSYS/README.rtf, from the msys-core-doc package).  Of course
you did read that, did you not?  (And FWIW, I think it was a really bad
choice, to distribute that as RTF rather than as POT).

>>> If the name has more than one letter e.g. `cscript /first:john' it works
>>> in MSYS.
>>
>> That's surprising; you should still require the double //.
>
> When the argument name is more than one letter, it works with or without
> the extra /, but issue is fixed. Thanks.

I expected /first:john to be interpreted as a path list, but apparently
it isn't:

  $ showargv /first:john
  command: c:\mingw\bin\showargv.exe /first:john
  argv[00]: c:\mingw\bin\showargv.exe
  argv[01]: /first:john

However, it may not be prudent to rely on such behavioural quirks:

  $ showargv /first:/john
  command: c:\mingw\bin\showargv.exe C:\MinGW\msys\1.0\first;C:\MinGW
    \msys\1.0\john
  argv[00]: c:\mingw\bin\showargv.exe
  argv[01]: C:\MinGW\msys\1.0\first;C:\MinGW\msys\1.0\john

but these:

  $ showargv //first:/john
  command: c:\mingw\bin\showargv.exe //first:/john
  argv[00]: c:\mingw\bin\showargv.exe
  argv[01]: //first:/john

  $ showargv //first://john
  command: c:\mingw\bin\showargv.exe //first://john
  argv[00]: c:\mingw\bin\showargv.exe
  argv[01]: //first://john

are anomalous, and *would* appear to indicate a bug in MSYS.  Any
comment, Cesar?

--
Regards,
Keith.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: VBScript argument names must have length > 1

Cesar Strauss
On 22/10/2014 17:05, Keith Marshall wrote:
> On 22/10/14 15:15, John Brown wrote:

>> Where is this documented?

There is a helpful soul that took the source code and created the
following page with all the rules:

http://mingw.org/wiki/Posix_path_conversion

> I expected /first:john to be interpreted as a path list, but apparently
> it isn't:
>
>    $ showargv /first:john
>    argv[01]: /first:john

Paths in path lists should be absolute. This looks to me like a command
line switch. Indeed, the Microsoft linker has a /DEF:filename switch.
See http://msdn.microsoft.com/en-us/library/34c30xs1.aspx

>    $ showargv /first:/john
>    argv[01]: C:\MinGW\msys\1.0\first;C:\MinGW\msys\1.0\john

It is a proper path list, no surprises.

>    $ showargv //first:/john
>    argv[01]: //first:/john

It begins with // followed by a /. It is treated like a UNC path,
//server/path.

>    $ showargv //first://john
>    argv[01]: //first://john

Same reason as above.

I was thinking that all these rules could be codified in an
user-modifiable external file with some regular expression syntax. This
would solve many complains about MSYS path translation, I think.

Regards,

Cesar


------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: VBScript argument names must have length > 1

Keith Marshall
On 22/10/14 22:33, Cesar Strauss wrote:
> On 22/10/2014 17:05, Keith Marshall wrote:
>> On 22/10/14 15:15, John Brown wrote:
>
>>> Where is this documented?
>
> There is a helpful soul that took the source code and created the
> following page with all the rules:
>
> http://mingw.org/wiki/Posix_path_conversion

Thanks for that link; boy, what a heuristic (== broken by design) mess!

>> I expected /first:john to be interpreted as a path list, but
>> apparently it isn't:
>>
>>    $ showargv /first:john
>>    argv[01]: /first:john
>
> Paths in path lists should be absolute. This looks to me like a
> command line switch.

Except that it is inconsistent with the documented expectation that, in
MSYS, Microsoft style command line switches should be expressed as //,
so making this:

> Indeed, the Microsoft linker has a /DEF:filename switch.
> See http://msdn.microsoft.com/en-us/library/34c30xs1.aspx

... fundamentally irrelevant.

>>    $ showargv /first:/john
>>    argv[01]: C:\MinGW\msys\1.0\first;C:\MinGW\msys\1.0\john
>
> It is a proper path list, no surprises.

Sure.  Of the examples which I provided, this is the only one to deliver
expected behaviour.

>>    $ showargv //first:/john
>>    argv[01]: //first:/john
>
> It begins with // followed by a /. It is treated like a UNC path,
> //server/path.

Maybe, but once again it is inconsistent with expectation; Earnie has
always stated that, in MSYS, UNC paths should normally be expressed as
///server/path, i.e. with three initial solidi, although the wiki page
suggests that the coding fails to match his intended design.

>>    $ showargv //first://john
>>    argv[01]: //first://john
>
> Same reason as above.

And again, inconsistent; the initial pair of solidi should have been
reduced to just one.  (Granted, the second pair should, perhaps then be
preserved, since they are embedded within the switch expression, for it
is as such that this argv[01] should have been interpreted).

> I was thinking that all these rules could be codified in an
> user-modifiable external file with some regular expression syntax. This
> would solve many complains about MSYS path translation, I think.

That could provide a solution.  Certainly, something *badly* needs to be
done, for right now, its all an horrendous mess of confusion, with
heuristic inconsistencies, and impossibilities.

--
Regards,
Keith.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe