$ZCMdline

$ZCM[DLINE] contains a string value specifying the "excess" portion of the command line that invoked the GT.M process. By "excess" is meant the portion of the command line that is left after GT.M has done all of its command line processing. For example, a command line mumps -direct extra1 extra2 causes GT.M to process the command line upto mumps -direct and place the "excess" of the command line, that is "extra1 extra2" in $ZCMDLINE. $ZCMDLINE gives the M routine access to the shell command line input.

Note that the actual user input command line might have been transformed by the shell (for example, removing one level of quotes, filename, and wildcard substituion, and so on.), and it is this transformed command line that GT.M processes.

Example:

$ cat > test.m
write " $ZCMDLINE=",$ZCMDLINE,!
quit
$ mumps -run test OTHER  information
$ZCMDLINE=OTHER information
$

This creates the program test.m, which writes the value of $ZCMDLINE. Note how the two spaces specified in OTHER information in the command line gets transformed to just one space in OTHER information in $ZCMDLINE due to the shell's pre-processing.

Example:

$ cat foo.m
foo     ; a routine to invoke an arbitrary entry with or without 
 parameters
   ;
  set $etrap="" ; exit if the input isn't valid
  if $length($zcmdline) do @$zcmdline quit
  quit

$ mumps -run foo 'BAR^FOOBAR("hello")'

In this example, GT.M processes the shell command line up to foo and puts the rest in $ZCMDLINE. This mechanism allows mumps -run to invoke an arbitrary entryref with or without parameters. Note that this example encloses the command line argument with single quotes to prevent inappropriate expansion in Bourne-type shells. Always remember to use the escaping and quoting conventions of the shell and GT.M to prevent inappropriate expansion.

[Important] Important

Use the ^%XCMD utility to XECUTEs code from the shell command line and return any error status (truncated to a single byte on UNIX) that the code generates. For more information, refer to “ %XCMD”.