There is an alphabetical index. This page is a sample piece of documentation generated from unix.syntax.mth . For more information see the documentation on Dr. Botting's MATHS project.

Contents


    Lexicon

    [ comp.text.ASCII.html ]
  1. |- white_space::= SP | HT | ...
  2. |- doublequote::="\"",
  3. |- quote::="'",
  4. |- backquote::="`",
  5. |- backslash::="\\".
  6. |- semicolon::=";".

    Syntax

    The Bourne shell a pure interpreter for a highly interactive, complex and powerful programming language with syntax based loosely on ALGOL 68. The basic input (from a user or from a file) into the interpreter (sh) is a sequence of pipelined commands.

  7. pipeline::= command (input_redirection|) #("|" command) ("|" command output_redirction|).

  8. input_redirection::= "<" file | "<<"string.
  9. output_redirection::=( ">" | ">>" ) file.

    These notes fon't give rules running commands in the background:

  10. background_command::=command "&",

    and the two pseudo-boolean operators "&&" and "||":

  11. and_then::=command #("&&" command ), the first command is executed and if it terminates successfully so is the second command, and so on.

  12. or_else::=command #("||" command), Here the commands are tried one after another until one of them is successful.

    It is not clear at this time what the relative priorities of "&&", "||", "|" are.

    Commands

  13. command::=local_assignments command_name arguments,
  14. local_assignments::=#(assignment separator),
  15. arguments::=#(separator argument). Normally,
  16. separator::=whitespace~EOLN #(whitespace~EOLN).

  17. argument::=#(word | string | escaped_symbol ),
  18. word::=#(value_shell_variable| value_of_argument | #(char~separator)),

    Scripts

    A script is a sequence of commands and control structures separated by command separators

  19. script::=(pipeline | built_in_structure) #(command_separator (pipeline | built_in_structure)),
  20. command_separator::=EOLN #whitespace | semicolon #whitspace.
  21. terminated_script::= script command_separator.

    Built_in Shell Commands and Structures

  22. built_in_structure::=assignment | selection | loop | other_command | block | subshell,
  23. selection::=if_then_fi | case_esac,
  24. loop::= for_do_done | while_do_done | ... .

  25. other_command::=exit_statement | echo_statement | export_statement... .
  26. block::="{" script "}". Used to make a sequence of commands into one command.
  27. subshell::="(" script ")". A new shell is stated up to run the script.
  28. assignment::= shell_variable"="argument.
  29. export_statement::="export" shell_variable #(separator shell_variable). A variable that has been assigned a value in this process can be exported to processes that this process calls. The variable and its value are copied into the enviironment of all programs thatthis process runs. They are never returned. Thus local assignments remain in the process that assigned them and its sub-processes.

  30. echo_statement::="echo" arguments,
  31. exit_statement::="exit" argument. The argument of an exit statement is reurned as an exit staus. The convention is that and exit 0 indicates success, but all other values indicate an error.

    Control Structures

  32. condition::=terminated_script. Any sequence of commands can act as a condition. Successful completion acts a true value. Notice that "&&" and "||" act as short-circuited boolean operators - conjunction(and_then) and disjunction(or-else).

  33. if_then_fi::= "if" condition "then" terminated_script #(elif_part) O("else" terminated_script ) "fi".

  34. elif_part::= "elif" condition "then" terminated_script.
  35. while_do_done::="while" condition "do" terminated_script "done".

  36. case_esac::="case" argument "in" command_separator case #(";;" case) command_separator "esac".
  37. case::= case_expression")" script.

  38. for_do_done::= "for" shell_variable O("in" arguments) command_separator "do" terminated_script "done".

    Variables and Arguments

    A shell variable is identified by an identifier:
  39. shell_variable::=identifier,
  40. value_of_variable::= "$" variable| "${" identifier operator word "}",
  41. operator::= O(colon) ( "-" | "=" | "?" | "+" ). The most common form of these is
  42. ${ i :- w } = If i is unset or null use w else use ${i}.

    Arguments are numbered inside a shell script:

  43. script_argument::= digit,
  44. value_of_argument::="$"digit "${" digit operator word "}".

    There are several special variables/values:

  45. value::=value_of_argument | value_of_variable | "$" ( "$" | "?" | "#" | "!" | ...).
  46. $# = number of arguments/parameters.
  47. $$ = process id of this process.
  48. $? = exit status of last command.

    Strings

  49. string::= double_quoted_string |single_quoted_string|reverse_quoted_string,

  50. escaped_symbol::=backslash char,

  51. double_quoted_string::= double_quote #( value_of_variable | value_of_argument | #(char~double_quote) | escaped_symbol) double_quote,
  52. reverse_quoted_string::=backquote pipeline backquote,
  53. single_quoted_string::=quote #(char~quote | escaped_symbol) quote.


Labels and Definitions in Alphabetical Order


This was the work of Dick Botting at
dick@csci.csusb.edu ( also known as: rbotting@wiley.csusb.edu).

Disclaimer: CSUSB may or may not agree with this message.

Copyright(1996): Copy the document in which the link appeared and use as you wish as long as you include the following as source, disclaimer, and copyright.