免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3118 | 回复: 0
打印 上一主题 下一主题

[桌面系统] bash 处理 input 的个人理解 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2017-08-01 11:38 |只看该作者 |倒序浏览
首先是一些基本的定义:
blank: 指 space 和 TAB。
word: 也叫做 token,是 input 的一个基本单元。
metacharacter: 也叫做 identifier,是 words 的分隔符。由下列字符组成:| ,&,;,(,),space,tab 。
control operator: 执行控制功能的 token,详见 man bash 。
SHELL 的语法主要有下面几部分(如需详细了解,参见 man bash):
simple command
pipeline
list
compound command

在参考 man bash 后,一些个人的理解,用于理解 input 的处理过程,有不正确的可以指出:
simple command 组成 pipeline 。
pipeline 组成 list 。
list 组成 compound command 。
compound command 作为一个命令的抽象,像 simple command 那样可以去
组成 pipeline ,进而继续进行上面的组成过程。
Bash 读取到一行 input 时,解释的方向则是相反的,由抽象到具体(大概轮廓的伪代码如下)
BEGIN
interpreter (input)
    if input is compound command
        //设置 compound command 的环境
        //按 compound command 的分隔符和终止符将整个 input 分解
        //递归处理分解的部分
    else if input is list
        //处理过程类似于 compound command
        //递归处理分解的部分
    else if input is pipeline
        //处理 pipeline
    else if input is simple command
        //处理 simple command
    else
        //语法错误
END

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP