TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

BASH as a Modern Programming Language [ppt]

55 点作者 triberian超过 11 年前

16 条评论

networked超过 11 年前
&gt;Why BASH instead of another programming language?<p>&gt;Is the default shell for all OSs except for Windows<p>BSD users would very much disagree, as would embedded Linux users and others. In fact, this assumption is a very common cause of portability problems for free and open source software.<p>I&#x27;m as guilty as anyone of assuming every shell is bash but when I had to make my software compile and run tests on both Linux and FreeBSD straight out of the repository I discovered that targeting the POSIX shell was not as limiting as you might think. I have since made it a habit to avoid &quot;bashisms&quot; in most scripts; a good way to start with that is to learn what is and isn&#x27;t a bashism using a handy list found at <a href="http://mywiki.wooledge.org/Bashism" rel="nofollow">http:&#x2F;&#x2F;mywiki.wooledge.org&#x2F;Bashism</a>.
评论 #6866562 未加载
评论 #6866528 未加载
评论 #6866378 未加载
评论 #6866985 未加载
dmytrish超过 11 年前
Oh please, don&#x27;t get me started on this.<p>Bash is much more powerful than it&#x27;s usually thought of (I wrote a decent chunk of bash code, there are middle-sized projects like DKMS written in bash, etc), but still it&#x27;s a language for a narrow niche (file-management and gluing other tools) with a lot of limitations:<p>- very weak data structures support: no trees, no decent maps (`declare -A` seems to be searched in linear time), no arrays-in-arrays;<p>- no typing at all, everything is a string;<p>- it does not have a complete standard, very much behavior is implementation-specific;<p>- heavy dependence on external tools (they&#x27;re like libraries in modern languages);<p>- stunning amount of pitfalls in syntax and corner cases, escaping hell (e.g.: `scp host:&quot;File\\ name\\ with\\ spaces&quot; .`).<p>Although I have to say that multiple jobs orchestration is amazing for a language from 70ths.
评论 #6866423 未加载
评论 #6867165 未加载
kps超过 11 年前
Nearly everything in the slides can be done in portable POSIX sh(1) with only minor syntactic changes to avoid bashisms.<p>If you really want a big shell with more language features, check out ol&#x27; AT&amp;T ksh¹, with things like nestable structured types and floating point arithmetic. [EDIT: and &#x27;call by reference&#x27; using variable names, to address the problem of returning or mutating complicated things.] Some of bash&#x27;s features originated in ksh, as did most of the POSIX sh features added since original sh.<p>(1) <a href="http://pubs.opengroup.org/onlinepubs/9699919799/idx/shell.html" rel="nofollow">http:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;idx&#x2F;shell.ht...</a> ¹ <a href="http://kornshell.org/" rel="nofollow">http:&#x2F;&#x2F;kornshell.org&#x2F;</a>
weland超过 11 年前
What the...<p>1. Bash is definitely <i>not</i> the default OS shell for &quot;all OSs&quot; except Windows. Most Android devices, most embedded devices running a variation of Linux, a lot of Unix systems and increasingly more desktop Linux systems don&#x27;t run bash as a default.<p>2. Pretty much every shell invokes a myriad of native binaries. That&#x27;s kind of what a shell does. cmd.exe does that just as easy as bash does.<p>Don&#x27;t get me wrong, bash is nice, but the opening part of this presentation is bullshit. Also, what the fuck happened to O&#x27;Reilly?
quarterto超过 11 年前
.ppt? Really? Is this not available in any other format?
评论 #6866280 未加载
评论 #6866347 未加载
评论 #6866685 未加载
wooby超过 11 年前
Bash has many features and for me has been useful to know because it&#x27;s almost everywhere, but it was never designed to be what it has become. I&#x27;m working on escaping it forever with gherkin, a Lisp I wrote in Bash 4.<p>gherkin is still in its early days, but if you&#x27;re interested in such a thing see <a href="https://github.com/alandipert/gherkin" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alandipert&#x2F;gherkin</a> or join us in #gherkin on freenode.
jdkanani超过 11 年前
Can somebody add `[ppt]` tag to title? I can&#x27;t as I don&#x27;t have enough points.
panzi超过 11 年前
My experience with bash: Once you do something a bit more complex where bashisms would be handy any shell is so slow and complicated to use that you&#x27;re better of with Python, even if all your system provides is Python 2.4. And Python is pre-installed under every (non-embedded) Linux distribution I&#x27;ve seen and also on Mac OS X.<p>Python is more powerful than shells but at the same time has a much simpler syntax (much less to remember). The only thing I miss in Python sometimes is how easy you can do complex piping in shells. It&#x27;s possible in Python but not at all as handy as in (ba)sh.
评论 #6867136 未加载
luikore超过 11 年前
Bash sucks at slicing arrays (always need a `[@]`):<p><pre><code> ${array[@]:$from:$to} </code></pre> Zsh is a bit nicer:<p><pre><code> ${array:$from:$to}</code></pre>
评论 #6866608 未加载
asmman1超过 11 年前
Moderna bash&#x2F;shell language? check out Window&#x27;s Power Shell [1]. The one shell scripting language what I would use and the only of its type that its syntax don&#x27;t scare me...<p>[1]: <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Windows_PowerShell</a>
评论 #6867004 未加载
malandrew超过 11 年前
Can you upload this to slideshare or something? Many people despise ppt files.
chattoraj超过 11 年前
It isn&#x27;t satire.
评论 #6866365 未加载
alisnic超过 11 年前
Sounds like a 1st april headline. If this article is accurate, it stretches the &quot;Modern&quot; qualification way too far far
gwu78超过 11 年前
Why do &quot;modern programming languages&quot; return 0 for true? APL returns 1.
评论 #6867311 未加载
hercynium超过 11 年前
For an interesting take on &quot;Modern Bash&quot; I came across this a few months ago, from the deliciously twisted genius that is Ingy döt Net: <a href="https://github.com/ingydotnet/bpan-bash" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ingydotnet&#x2F;bpan-bash</a>
Siecje超过 11 年前
I use fish instead of bash, it is pretty awesome.