[Info-vax] Command Line Versus Command Line
Craig A. Berry
craigberry at nospam.mac.com
Thu May 23 18:32:33 EDT 2024
On 5/23/24 2:05 PM, Arne Vajhøj wrote:
> On 5/23/2024 12:16 AM, Lawrence D'Oliveiro wrote:
>> VMS really wants you to use a DCL-style syntax for your command lines. It
>> does weird things like uppercasing text in the command buffer, except for
>> parts in quotes, which are left as-is, but then the quotes are also left
>> in place, so command-line parsers have to worry about dealing with text
>> that might or might not be quoted.
>
> That is an oversimplified view on a complex issue.
>
> real: ABC def "GIH" "jkl"
> parse=traditional:
> CLI : ABC DEF GIH jkl
> FC : ABC DEF "GIH" "jkl"
> Mix : ABC DEF GIH jkl
> C : abc def GIH jkl
> DCL : ABC DEF GIH jkl
> parse=extended:
> CLI : ABC DEF GIH jkl
> FC : ABC def "GIH" "jkl"
> Mix : ABC DEF GIH jkl
> C : ABC def GIH jkl
> DCL : ABC DEF GIH jkl
>
> For details see below.
>
> Arne
>
> $ type cli.for
> program cli
> integer*4 p1len,p2len,p3len,p4len
> character*80 p1,p2,p3,p4
> call cli$get_value('p1',p1,p1len)
> call cli$get_value('p2',p2,p2len)
> call cli$get_value('p3',p3,p3len)
> call cli$get_value('p4',p4,p4len)
> write(*,*) 'CLI : '//p1(1:p1len)//' '//p2(1:p2len)//' '
> + //p3(1:p3len)//' '//p4(1:p4len)
> end
> $ type cli.cld
> define verb cli
> image "sys$disk:[]cli.exe"
> parameter p1
> parameter p2
> parameter p3
> parameter p4
> $ for cli
> $ link cli
> $ set comm cli.cld
> $ type mix.for
> program mix
> integer*4 cmdlen
> character*80 cmd
> integer*4 p1len,p2len,p3len,p4len
> character*80 p1,p2,p3,p4
> external mixcld
> call lib$get_foreign(cmd,,cmdlen)
> call cli$dcl_parse('cli '//cmd(1:cmdlen),mixcld,,,)
> call cli$get_value('p1',p1,p1len)
> call cli$get_value('p2',p2,p2len)
> call cli$get_value('p3',p3,p3len)
> call cli$get_value('p4',p4,p4len)
> write(*,*) 'Mix : '//p1(1:p1len)//' '//p2(1:p2len)//' '
> + //p3(1:p3len)//' '//p4(1:p4len)
> end
> $ type mixcld.cld
> module mixcld
> define verb cli
> parameter p1
> parameter p2
> parameter p3
> parameter p4
> $ for mix
> $ set command/object mixcld
> $ link mix + mixcld
> $ type fc.for
> program fc
> integer*4 cmdlen
> character*80 cmd
> call lib$get_foreign(cmd,,cmdlen)
> write(*,*) 'FC : '//cmd(1:cmdlen)
> end
> $ for fc
> $ link fc
> $ type c.c
> #include <stdio.h>
>
> int main(int argc, char *argv[])
> {
> printf("C :");
> for(int i = 1; i < argc; i++) printf(" %s", argv[i]);
> printf("\n");
> return 0;
> }
> $ cc c
> $ link c
> $ type dcl.com
> $ write sys$output "DCL : ''p1' ''p2' ''p3' ''p4'"
>
>
Good summary. Did you have DECC$ARGV_PARSE_STYLE defined for the C example?
More information about the Info-vax
mailing list