编程与软件工程github.com编辑精选
纯 Bash 圣经
Pure Bash Bible
2019 — 2022,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
《Pure Bash Bible》是一份用纯 Bash 内建功能完成常见任务的技巧合集,目标是不调用 sed、awk 等外部命令。它借助参数展开、数组操作等 Bash 特性,给出字符串处理、文件读写等场景的写法,更像一本可查阅的配方手册。
为什么经久不衰:它把 Bash 冷门但强大的内建特性整理成速查配方,既能直接抄用,也能帮助理解 shell 自身能力的边界,因此多年后仍值得翻阅。
HN 评论精选
作者现身,并用纯 Bash 写的 TUI 文件管理器展示其能力边界。
我是《Pure Bash Bible》的作者,很乐意回答任何问题。这里有个例子能展示 Bash 能做到什么:https://github.com/dylanaraps/fff/(一个用 Bash 写的 TUI 文件管理器)!
dyanaraps查看英文原文
Hello, I'm the author of the Pure Bash Bible. Happy to answer any questions you may have. Here's an example of what bash is capable of: https://github.com/dylanaraps/fff/ (a TUI file manager written in bash)!
批评这类技巧可读性差、难以维护。
我个人讨厌正则和不易读的代码,维护起来很头疼,所以尽量避开 shell 脚本。第一个例子就不可读:如果函数名与实际行为不符,我完全不知道这段代码在干什么(比如那个 trim_string)。
jmnicolas查看英文原文
I have a personal dislike for regexes and non human readable code, it gives maintenance headache. It's why I avoid shell scripts as much as possible. The first example is not human readable, if the name of the function is a lie, I have no idea what this piece of code do : trim_string() { : "${1#"${1%%[![:space:]]*}"}" : "${_%"${_##*[![:space:]]}"}" printf '%s\n' "$_" }
澄清“pure”指不调用外部进程,而非追求可移植性。
我一开始没意识到这里的“pure”指的是只用 Bash 自带功能、不调用外部进程;我本以为在这个语境下,纯粹主义应该指避免 bashism、写可移植的(ksh、POSIX shell)脚本。
tannhaeuser查看英文原文
Didn't realize at first that "pure" refers to features available in bash without calling out to external processes, when I would've thought purism in this context should refer to avoiding bashisms and writing portable (ksh, POSIX shell) scripts.
认为纯 Bash 违背 shell 组合外部程序的初衷,是反讽式赞赏的无用 hack。
作为一个真心喜欢无聊、无意义 hack 的人(比如用 CSS 或 Minecraft 做到图灵完备),我觉得这个绝对是最蠢的,佩服。Bash/Shell 脚本的全部意义(至少应该是)是把其他程序串起来完成任务。对我来说,“Pure Bash”就像一块永远不沾水的肥皂。
jrm4查看英文原文
As someone who is genuinely a fan of stupid pointless hacks, like Turing Completeness with CSS or Minecraft or whatnot, in my opinion this is definitely the stupidest. Kudos. The entire point of Bash/Shell scripting is (or darn it, ought to be) to use it to string together OTHER programs to get stuff done. "Pure Bash" to me is like a bar of soap that never gets wet.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选