OpenExtensions for z/VM "Q"s and "A"s

Question: Why can't I get "special characters" to work correctly with the shell cms command? If I type:

  cms filelist * * a
I get a message like:
  DMSPCL389E Invalid filetype: A.A

Or if I type a command like

  cms listfile * * a ( date
I get a message like:
  GSU7332 syntax error: got (, expecting Newline

Answer: Some characters, such as asterisks, parentheses, and quotes, have special meaning in the shell. The asterisks and parenthesis are being stripped before CMS sees the arguments.

The solution is to "protect" these special characters so the shell treats them as ordinary characters. One way to do this is by enclosing the text containing special characters with single or double quotes. The following commands are all equivalent:

  cms "filelist * * a"
  cms filelist  "* * a"
  cms filelist '* *' a
This method is simple and will probably work with most commands, but it is not 100% foolproof. Consider what would happen if your arguments contained a single or double quote (double quotes are also special characters).

A method that is guaranteed to work but is a little more difficult to use is to "escape" each special character (each single quote, each asterisk, each parenthesis, etc.) with a backslash:

  cms listfile \* \* a \(date

These techniques of protecting special characters are important when you use utilities such as c89 to refer to BFS files and you need specify special characters in the file identifiers.


For more questions and answers, go to our archive of questions and answers.