当前位置: 首页 > news >正文

Joeys shell

您熟悉bash的语法吗?"You're afraid of bugs? Get a bug!" --Joey Tribbiani, "FRIENDS".

想找个mini shell来看看源码,浏览了些网页,有“这玩意也配叫shell?”之感。

  • bash-1.14.7.tar.gz 1996-08-29 1.4M
  • bash-2.0.tar.gz 1996-12-31 1.3M gcc 12 编译不过
  • bash-3.0.tar.gz 2004-08-03 2.3M gcc 12 编译通过

Debian 12用的是5.2.15 2022-12-13,最新的是5.3 2025-07-30 11M

搜bash-3.0.tar.gz,国内有镜像,下载速度很快。

When running configure, the script hangs for about 60 seconds on checking for mktime, eventually fails and moves on.

https://bugs.launchpad.net/adeona/+bug/407735

里面有个parse.y,看懂后自然就明白bash的语法啦!

源码里好像带了y.tab.c,没有yacc能也编译出bash。想修改parse.y再编译,需要apt install yacc.

贴部分代码:

%union {WORD_DESC *word;		/* the word that we read. */int number;			/* the number that we read. */WORD_LIST *word_list;COMMAND *command;REDIRECT *redirect;ELEMENT element;PATTERN_LIST *pattern;
}%start inputunitinputunit:	simple_list simple_list_terminator|	error '\n'|	yacc_EOF;redirection: '>' WORD | '<' WORD | NUMBER '>' WORD ..simple_command_element: WORDshell_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|	arith_command|	cond_command|	arith_for_command;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 '}'|	FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE|	FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE|	FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}';arith_for_command:	FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE...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;

我说过for i in 1 2 3; do echo $i; done和ls; ls; ls类似,这个说法很可能是错误的,因为AI说:

  • YACC(Yet Another Compiler Compiler)由Stephen C. Johnson于1975年开发
  • Bourne Shell(sh)由Stephen Bourne开发,于1979年末随UNIX第7版首次发布

所以sh一开始就用了YACC? 不对,没有sh前,cc yacc.c咋输入?第一个sh是汇编写的吧?

Bourne的音标是/bɔːrn/,电影《谍影重重》男主角的英文名为‌Jason Bourne‌(杰森·伯恩)。

parse.y, 不是parser.y, 也不是parsing.y. 虽然我昨天刚踩坑把n用了两次,可下面的程序还是有点过了吧:

function setupTextAreaLineSelection(textAreaId) {const textArea = document.getElementById(textAreaId);textArea.addEventListener('dblclick', function() {const start = this.selectionStart;const end = this.selectionEnd;let lineStart = start;let lineEnd = end;

dblclick,不是doubleClick啊。

http://www.gsyq.cn/news/22470.html

相关文章:

  • 软件工程学习日志2025.10.16
  • Apifox 9 月更新| AI 生成接口测试用例、在线文档调试能力全面升级、内置更多 HTTP 状态码、支持将目录转换为模块 - 实践
  • window电脑开启hyperV虚拟化功能后导致本地服务端口被占用问题处理方案
  • 初识pytorch:网络骨架中的填充之各种层
  • Day5字符型
  • 深入解析:从 Vercel 构建失败谈 Git 大小写敏感性问题:一个容易被忽视的跨平台陷阱
  • 完整教程:Logit论文阅读
  • 前端快速开发工具推荐与实战 让开发速度提升 3 倍的完整工具链
  • Matlab选择常见颜色
  • 2025 年防静电地板源头厂家最新推荐榜单:权威品牌实力展现,助力各行业精准挑选优质产品
  • HyperWorks许可状态监控
  • 2025 年激光焊锡源头厂家最新推荐排行榜:覆盖多行业需求,助力企业精准挑选优质设备供应商
  • 客户案例 | 未来生物甄知科技,在SAP架构中搭建IT运维智能引擎
  • keycloak~标准的国际化设计
  • C0268 Count 1s
  • fac卡片网格灵活控制宽高
  • Ai元人文:用户端元人文
  • idea 安装的插件 和pom里引入的依赖区别
  • 使用 LLVM-Mingw 编译的 Qt 应用程序部署指南:拷贝必要库到 exe 目录
  • 盒子模型
  • 2025年10月国内权威信息公布:西安第四代住宅新房/学区房/地铁口买房性价比楼盘/地铁口新房价格/交大附中附近住宅/低总价新房推荐/带露台高性价比四代宅推荐口碑排行榜TOP10揭晓
  • HolmesGPT 正式上线 丨 KubeSphere 助力云原生智能排障新体验
  • MAUI开发安卓应用,采用PC的chrome浏览器调试平板网页
  • 【学习笔记】回滚莫队初步总结
  • python之模块
  • 2025 年电动阀门厂推荐榜:电动/气动/高压/真空阀门厂,上海巨良阀门凭技术与口碑领跑行业
  • 【学习笔记】线性基
  • x86_64架构__rdtsc指令
  • 【2025最新】6款免费DLL修复工具推荐:彻底解决“XXX.dll缺失”问题!
  • 2025 年注浆管生产厂家最新推荐排行榜:聚焦 0.3mm 精度与国企合作案例,助力基建企业精准挑选优质供应商