Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Echo

Built-in

SYNTAX

Echo [parameter1 [parameter2]…] [-n]

DESCRIPTION

The Echo command writes the value of its parameters, separated by spaces and terminated by a carriage return. It is especially useful for checking the results of filename generation and variable and command substitution.

Note that if the {echo} shell variable is set to 2, the Echo command provides extended information about what script and what line is executing. This can be particularly useful in trying to track down problems in scripts.

INPUT

None

OUTPUT

Standard output.

STATUS

Echo always returns a status code of 0.

PARAMETERS

parameter1 [parameter2]…

Specifies one or more MPW Shell variables or text strings to be written to standard output. If you do not specify any parameters, Echo writes only a linefeed.

OPTIONS

-n

Does not write a return following the parameters. The insertion point remains at the end of the output line. Note that -n itself is not echoed.

EXAMPLES

The following command line writes the current value of the {Status} variable, which is the status of the last command executed.

Echo {Status}

Pattern matching can be used with Echo, for instance, to generate a list of all files in the current directory ending with ".a". In the command line

Echo "Assembly language files:" ≈.a

an explanatory text string precedes "≈.a", producing the following output:

Assembly language files: DAEntry.a TESample.a

As a precaution, it is good practice to expand filenames in this way before executing a command such as Delete with the same parameters. This allows you to tell ahead of time which files will be affected.

The command line below deletes the contents of the EmptyFile file if it exists. If the file does not exist, the MPW Shell creates it.

Echo -n > EmptyFile

Although both the Echo and Quote commands return the value of their parameters, Quote also places quotation marks around any value containing special characters. (See Quote for the list of special characters.)

The following script takes the first parameter, {1}, passed to it and, using the Echo command, announces that it is compiling the second parameter, {2}, (a source file). This If…Else control structure includes the case where symbolics is on and the case where it is off.

If "{1}" == "-symon"
  Echo "# Compiling `quote "{2}"` with symbolics on"
  MrC "{2}" -sym on
Else
  Echo "# Compiling `quote "{2}"` with symbolics off"
  MrC "{2}" -sym off
End

Notice how the output from Quote is used as input to Echo. This ensures proper quotation of filenames containing special characters such as spaces. For example, the command line

MPW:MyScript -symon "A Test File"

returns the following line before compiling the source file with -sym on:

# Compiling 'A Test File' with symbolics on

SEE ALSO

Parameters

Quote

 
 


Last Updated July 2000