UNIX for OpenVMS Users, Third Edition

10.2: Variables

10.2 Variables

You can assign variables in bash and Korn shell scripts with a statement that resembles a DCL symbol assignment. C shell scripts use the set command. Note the following differences in assigning values to variables and returning variable values between shell scripts and DCL command procedures.

The C shell does not make the same distinction as OpenVMS between defining variables for the duration of the command procedure and defining variables for the duration of the terminal session (that is, globally). The set command always assigns variables for the current process. Including the variable assignment in the .cshrc file gives the equivalent of global definitions, because this file is usually executed each time a shell (process) is started, that is, for each command or script file executed. The exception, as noted above, is a fast start of the C shell. You can use the C shell setenv command to set environmental variables.

The bash and Korn shells do distinguish between variables local to a script or shell and those accessible to child processes. You may use the export command or an equivalent shell option to make variables accessible.

Perl provides several different scoping mechanisms for its variables, but Perl variables are separate and distinct from variables in the user's interactive shell. A Perl program can read the parent's shell variables if desired, but cannot change them.

The C shell makes no distinction in defining a shell variable as an integer or a text string...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Heat Exchangers
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.