Following SETL2, which adopted the identifiers conventionally used in Ada to refer to the external name and arguments with which the program (the command) was invoked, *
command_nameis a predefined constant string that represents, in some environment-defined way, the name of the program from the point of view of the party that launched it, and *
command_lineis a predefined constant tuple of strings representing a list of arguments to the program.
Whenever one of the commonly used Unix shells is the caller, command_name and command_line correspond to what C programs receive as argv and the subsequent argc-1 elements of argv respectively.
If the setl command is invoked directly, then command_line will be a tuple of strings representing the arguments following ``--'' or ``-x'', and command_name will be the name of the SETL interpreter, setlrun in the default configuration of my current SETL implementation .
If, however, the SETL interpreter is invoked via the ``#!'' escape common to virtually all varieties of Unix (though this escape sequence is of unspecified effect according to the Unix 98 standard), by placing
#! /path/to/setl -kat the very beginning of a file that otherwise contains a SETL program, and by making this file executable using chmod (see Section 2.7 [User and Group Identities]), then the filename will be available inside the SETL program as command_name and any arguments placed after that name will be the strings that show up in command_line.
A convenient way of supplying some environmental information to programs is through environment variables. All widely used operating systems support these in one form or another. In SETL, *
value := getenv name;is used to retrieve, as a string, the value associated with the environment variable named name. If no such variable is known to the environment, getenv returns om.
Programmers should be aware that the names of environment variables may or may not be treated case-sensitively, depending on the system. In Unix systems, case is significant; in DOS-based systems, it is not. I strongly recommend strict adherence to uppercase as a convention for these names, since that is a portable practice that is already well entrenched in the Unix community.
A SETL program can also set environment variables for itself and for the benefit of programs it spawns, using *
setenv (name, value); -- associate value with namewhere name and value are both strings, and value defaults to the null string. Finally, environment variables can be deleted: *