3.11. Quoting Special Characters

Beginning with Apple IIgs System Software 6.0, GS/OS is able to read files from Macintosh computers. The Macintosh uses a filesystem known as HFS, which allows filenames to contain any character except the colon (":"). Because a filename such as "emacs?*" is valid under HFS, care must be taken or unexpected results will occur. The word "emacs?*" was used as a regular expression above to specify a list of filenames beginning with the word "emacs" and one or more trailing characters. gsh does provide a way to pass an argument which contains special shell characters to a command. This is known as quoting an argument. There are three different ways to quote an expression:

  1. The single quote will quote everything between the single quote marks. Thus, to display the contents of a file on an HFS volume named "emacs?*", use the command: more 'emacs?*'

  2. The double quote will quote everything between the double quote marks except variables; echo "emacs?* $home" will product "emacs?* /dev/gno". See Chapter 5 for more on variables.

  3. The backslash is used to quote one character. To pass "emacs?*" as a regular using the backslash, one could enter the following: ls emacs\?\*

One additional purpose of the quoting mechanism built into gsh is to add spaces to command arguments. Each command and its arguments is separated by a space. Multiple spaces between arguments are treated as one space. Thus, consider the following:


% echo a       b c
a b c
% echo 'a       b c'
a       b c