学习bash第二版-附录四 语法

news/2024/7/3 19:49:13

**保留字
  下面关键字为保留字,在它们没有被引起来时对shell具有特殊的含义:
  if  then  else  elif  fi  case
  esac  for  while  until  do  done
  function  in  select  !  {  }
  time
  
**bash的BNF
  以下为bash 2.0的Backus-Naur Form(BNF)语法:
  <letter> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|
               A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
   
  <digit> ::= 0|1|2|3|4|5|6|7|8|9
   
  <number> ::= <digit>
             | <number> <digit>
   
  <word> ::= <letter>
           | <word> <letter>
           | <word> '_'
   
  <word_list> ::= <word>
               |  <word_list> <word>
   
  <assignment_word> ::= <word> '=' <word>
   
   
  <redirection> ::=  '>' <word>
                  |  '<' <word>
                  |  <number> '>' <word>
                  |  <number> '<' <word>
                  |  '>>' <word>
                  |  <number> '>>' <word>
                  |  '<<' <word>
                  |  <number> '<<' <word>
                  |  '<&' <number>
                  |  <number> '<&' <number>
                  |  '>&' <number>
                  |  <number> '>&' <number>
                  |  '<&' <word>
                  |  <number> '<&' <word>
                  |  '>&' <word>
                  |  <number> '>&' <word>
                  |  '<<-' <word>
                  |  <number> '<<-' <word>
                  |  '>&' '-'
                  |  <number> '>&' '-'
                  |  '<&' '-'
                  |  <number> '<&' '-'
                  |  '&>' <word>
                  |  <number> '<>' <word>
                  |  '<>' <word>
                  |  '>|' <word>
                  |  <number> '>|' <word>
   
  <simple_command_element> ::= <word>
                            |  <assignment_word>
                            |  <redirection>
   
  <redirection_list> ::= <redirection>
                      |  <redirection_list> <redirection>
   
  <simple_command> ::=  <simple_command_element>
                     |  <simple_command> <simple_command_element>
   
  <command> ::=  <simple_command>
              |  <shell_command>
              |  <shell_command> <redirection_list>
   
  <shell_command> ::=  <for_command>
                    |  <case_command>
                    |  while <compound_list> do <compound_list> done
                    |  until <compound_list> do <compound_list> done
                    |  <select_command>
                    |  <if_command>
                    |  <subshell>
                    |  <group_command>
                    |  <function_def>
   
  <for_command> ::=  for <word> <newline_list> do <compound_list> done
              |  for <word> <newline_list> '{' <compound_list> '}'
              |  for <word> ';' <newline_list> do <compound_list> done
              |  for <word> ';' <newline_list> '{' <compound_list> '}'
              |  for <word> <newline_list> in <word_list> <list_terminator>
                     <newline_list> do <compound_list> done
              |  for <word> <newline_list> in <word_list> <list_terminator>
                     <newline_list> '{' <compound_list> '}'
   
  <select_command> ::=  select <word> <newline_list> do <list> done
                     |  select <word> <newline_list> '{' <list> '}'
                     |  select <word> ';' <newline_list> do <list> done
                     |  select <word> ';' <newline_list> '{' list '}'
                     |  select <word> <newline_list> in <word_list>
                             <list_terminator> <newline_list> do <list> done
                     |  select <word> <newline_list> in <word_list>
                             <list_terminator> <newline_list> '{' <list> '}'
   
  <case_command> ::=  case <word> <newline_list> in <newline_list> esac
                   |  case <word> <newline_list> in <case_clause_sequence>
                           <newline_list> esac
                   |  case <word> <newline_list> in <case_clause> esac
   
  <function_def> ::=  <word> '(' ')' <newline_list> <group_command>
                   |  function <word> '(' ')' <newline_list> <group_command>
                   |  function <word> <newline_list> <group_command>
   
  <subshell> ::=  '(' <compound_list> ')'
   
  <if_command> ::= if <compound_list> then <compound_list> fi
            | if <compound_list> then <compound_list> else <compound_list> fi
            | if <compound_list> then <compound_list> <elif_clause> fi
   
  <group_command> ::=  '{' <list> '}'
   
  <elif_clause> ::= elif <compound_list> then <compound_list>
             | elif <compound_list> then <compound_list> else <compound_list>
             | elif <compound_list> then <compound_list> <elif_clause>
   
  <case_clause> ::=  <pattern_list>
                  |  <case_clause_sequence> <pattern_list>
   
  <pattern_list> ::=  <newline_list> <pattern> ')' <compound_list>
                   |  <newline_list> <pattern> ')' <newline_list>
                   |  <newline_list> '(' <pattern> ')' <compound_list>
                   |  <newline_list> '(' <pattern> ')' <newline_list>
   
  <case_clause_sequence> ::=  <pattern_list> ';;'
                           |  <case_clause_sequence> <pattern_list> ';;'
   
  <pattern> ::=  <word>
              |  <pattern> '|' <word>
   
   
  <list> ::=   <newline_list> <list0>
   
  <compound_list> ::=  <list>
                    |  <newline_list> <list1>
   
  <list0> ::=   <list1> '\n' <newline_list>
             |  <list1> '&' <newline_list>
             |  <list1> ';' <newline_list>
   
  <list1> ::=   <list1> '&&' <newline_list> <list1>
             |  <list1> '||' <newline_list> <list1>
             |  <list1> '&' <newline_list> <list1>
             |  <list1> ';' <newline_list> <list1>
             |  <list1> '\n' <newline_list> <list1>
             |  <pipeline_command>
   
  <list_terminator> ::= '\n'
                     |  ';'
   
  <newline_list> ::=
                    |  <newline_list> '\n'
   
  <simple_list> ::=  <simple_list1>
                  |  <simple_list1> '&'
                  |  <simple_list1> ';'
   
  <simple_list1> ::=  <simple_list1> '&&' <newline_list> <simple_list1>
                   |  <simple_list1> '||' <newline_list> <simple_list1>
                   |  <simple_list1> '&' <simple_list1>
                   |  <simple_list1> ';' <simple_list1>
                   |  <pipeline_command>
   
  <pipeline_command> ::= <pipeline>
                      |  '!' <pipeline>
                      |  <timespec> <pipeline>
                      |  <timespec> '!' <pipeline>
                      |  '!' <timespec> <pipeline>
   
  <pipeline> ::=
            <pipeline> '|' <newline_list> <pipeline>
         |  <command>
   
  <time_opt> ::= '-p'
   
  <timespec> ::=  time
               |  time <time_opt>
   
  .XE "BNF (Backus-Naur Form)"
  .XE "bash" "syntax, BNF form of"
 


http://www.niftyadmin.cn/n/3152729.html

相关文章

hdu折线分割平面 递推

折线分割平面 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37707 Accepted Submission(s): 25240Problem Description 我们看到过很多直线分割平面的题目&#xff0c;今天的这个题目稍微有些变化&#xff0…

这是我们公司总结的一些关于中文乱码问题的一些解决方案和经验和大家分享!

这是我们公司总结的一些关于中文乱码问题的一些解决方案和经验和大家分享&#xff01; owen1944 原创 (参与分&#xff1a;208&#xff0c;专家分&#xff1a;760) 发表&#xff1a;2003-7-28 下午10:04 版本&#xff1a;1.0 阅读&#xff1a;3762 次 1.字节和unicode …

学习bash第二版-附录五 获得示例程序

可通过FTP和FTPMAIL方式得到本书的一些例子。如果连接了Internet&#xff0c;可使用FTP。如果未连接Internet但可以发送并接收电子邮件到Internet站点上&#xff0c;可使用FTPMAIL。 **FTP 如果你具有Internet连接&#xff08;永久或拨号&#xff09;&#xff0c;最简单的…

response.setContentType()与response.setHeader()

1、一秒刷新页面一次 response.setHeader("refresh","1"); 2、二秒跳到其他页面 response.setHeader("refresh","2;URLotherPagename"); 3、没有缓存&#xff1a; response.setHeader("Pragma", "No-cache"); r…

ejb3.0 数据源配制

1. 首先在JBOSS的\server\default\deploy目录下建立XML文档&#xff0c;此文档的名称一般根据所使用的数据库而定&#xff0c;如mysql的为mysql-ds.xml &#xff0c;db2的为db2-ds.xml。文档的内容一般如下&#xff1a;<?xml version"1.0" encoding"U…

git仓库的bare方式

git提供一种对外发布&#xff0c;供开发者克隆的一种空工作目录的bare方式。这种方式的优点在于节省存储空间。 1.要从头开始创建bare方式的git仓库&#xff0c;步骤如下&#xff1a; 注&#xff1a;假定要创建的git仓库位于/home/chen/sw目录&#xff0c;源文件位于/home/zh…

git最新版本2.19.1出现fatal: NullReferenceException encountered解决方案

git最新版本2.19.1在提交新的版本时会出现如下图所示异常&#xff1a; 此问题不影响代码的pull与push及clone&#xff0c;但是会出现上述错误。 是因为git的credential manager 在版本2.19.1会出现问题。为此可以在如下链接下载&#xff1a; https://github.com/Microsoft/Gi…

linux常用命令-1备份压缩

以下为linux常用的命令举例。 (注&#xff1a;#后面的为注释&#xff0c;输入命令时不要写) &#xff08;一&#xff09;备份压缩 1.1 tar&#xff08;打包压缩&#xff09; tar -cf file.tar file #将file文件或目录打包为文件&#xff1a;file.tar tar -tf file.tar #浏…