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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

GNU ed ate my homework

113 点作者 atan2大约 3 年前

17 条评论

skissane大约 3 年前
If this &quot;save a backup file&quot; functionality was built into the OS, instead of having to be redone by every application, this probably would never have happened – it is much harder to do the wrong thing when you are just calling an OS API than when you have to implement it all yourself. And if the OS API is implemented wrong, you can just change the OS API, instead of having to change every application.<p>I like how Vim uses swap files to warn you if you are editing a file you already have opened (or have autosaved data from a previous crashed execution) – but it only works for Vim, if you open the file in another editor you don&#x27;t get the warning. If that functionality was in the OS instead, it could easily work cross-application.
评论 #30895479 未加载
评论 #30900463 未加载
评论 #30896694 未加载
评论 #30897928 未加载
projektfu大约 3 年前
Leaving aside the correct advice to avoid such hard coded backup files, I wish people would recommend at least considering &quot;sudo -e&quot; instead of &quot;sudo $EDITOR&quot; when editing something important with root permissions.
评论 #30894813 未加载
评论 #30896359 未加载
gumby大约 3 年前
The vi editor is, or was just ed. All ed commands are vi commands.<p>Likewise Emacs: originally it was just a bunch of TECO macros plus the “^R mode” (visual) addition to TECO. I frequently used to casually type raw TECO into a mini buffer to perform certain edits (meta-altmode — my hand just made the gesture automatically when I thought about it).<p>I suspect Bill Joy knew about this when he added visual mode to ed about a decade later.<p>PS if you haven’t checked out the MIT TECO language you should — it will blow your mind.
评论 #30897540 未加载
ncphil大约 3 年前
In 1999, after installing Linux on a mainframe for the first time, I needed to edit a few files. Being in the Linux console, ISPF wasn&#x27;t an option. But the copy of Linux we were working with (Marist College&#x27;s release) didn&#x27;t yet have vi available. So I had to go with ed. That, as they used to say, was &quot;a real trip&quot;.
评论 #30894749 未加载
eternityforest大约 3 年前
Just another reason I don&#x27;t mess with unix utils outside of the most trivial scripts one can imagine.<p>I really don&#x27;t care if the software I use is &quot;high quality&quot; or not, anywhere near as much as how many edge cases they&#x27;ve covered.<p>If your app is small and has very few dependencies, as a heuristic I generally expect it to somehow be trouble one way or another.<p>The only time I&#x27;ve had major trouble with VS Code is when I installed a buggy extension that helps add licenses to things, without noticing that it modifies every file in the entire workspace, even if they have a license already, and sometimes gets the syntax wrong.<p>It wasn&#x27;t a bit popular extension, so I probably should have known better.
评论 #30896267 未加载
rav大约 3 年前
Is it really pronounced &quot;ee-dee&quot;? Here I&#x27;ve been pronouncing it all the time like it was some zany protagonist in a 90&#x27;s cartoon show!
评论 #30895050 未加载
评论 #30895191 未加载
peterburkimsher大约 3 年前
This is completely off topic, so please downvote it.<p>It&#x27;s a children&#x27;s story, personifying ed, along with several other UNIX commands.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;peterburk&#x2F;peterburk.github.io&#x2F;blob&#x2F;master&#x2F;blog&#x2F;Ed%20and%20the%20Awk.txt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;peterburk&#x2F;peterburk.github.io&#x2F;blob&#x2F;master...</a><p>It&#x27;s not finished, but it did help a couple of young girls from the homestay family where I used to live to fall asleep.
评论 #30895086 未加载
评论 #30895720 未加载
评论 #30895215 未加载
leephillips大约 3 年前
The code fragment that the author complains about has an even more serious fault: it doesn’t check for the existence of an `ed.hup` file. If you happen to have one, because you’re unaware of `ed`’s behavior and you like to give weird names to your files, `ed` will wipe it out when trying to help you.<p>Vim does similar irresponsible things with its backup files¹ in its default configuration. It not only destroys existing files without checking, but prevents many auto-build systems from working correctly. All these behaviors are reckless, especially as there are obvious alternatives that don’t make assumptions about the users&#x27; files.<p>[1] <a href="https:&#x2F;&#x2F;lee-phillips.org&#x2F;badvim&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lee-phillips.org&#x2F;badvim&#x2F;</a>
technofiend大约 3 年前
ed was a lifesaver if your Unix system didn&#x27;t fully boot because unlike ex&#x2F;vi, it was statically compiled and had no dependencies on other filesystems. Plus it was cool to learn just as a bit of history and in a very small way follow in the footsteps of some amazing people.
评论 #30894879 未加载
评论 #30895689 未加载
评论 #30897947 未加载
ncmncm大约 3 年前
The right solution would be to make a log file at startup, and append a copy of the original text and then every last bit of input, exactly as it is typed, interspersed with some metadata. Then, if anything happens, you just exit on the spot, and absolutely nothing is lost.<p>The type of stuff edited doesn&#x27;t matter: could be audio, video, 3D design, vector drawing.<p>All editors should operate this way. It is disgraceful none do.
评论 #30903657 未加载
not2b大约 3 年前
ed is the way that it is in part because many users in the late 70s had a really slow modem and a printing terminal, and memory was minimal, so just ? was seen as a good error message.
评论 #30894402 未加载
评论 #30895904 未加载
评论 #30896865 未加载
jamespwilliams大约 3 年前
I recently found an example shell session in the documentation for mysqlimport that uses ed: <a href="https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;8.0&#x2F;en&#x2F;mysqlimport.html" rel="nofollow">https:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;8.0&#x2F;en&#x2F;mysqlimport.html</a>
userbinator大约 3 年前
Who doesn&#x27;t reflexively save when pausing to think&#x2F;etc.? To someone who does save early and often, this seems to be a non-issue --- if the original file wasn&#x27;t writable for whatever reason, you&#x27;d also know pretty quickly.
评论 #30894565 未加载
评论 #30896467 未加载
michaelmrose大约 3 年前
Ed as a Clojure IDE<p><a href="https:&#x2F;&#x2F;lambdaisland.com&#x2F;episodes&#x2F;ultimate-dev-setup" rel="nofollow">https:&#x2F;&#x2F;lambdaisland.com&#x2F;episodes&#x2F;ultimate-dev-setup</a>
Mawr大约 3 年前
The proposed fix is wrong.<p>&gt; This is a lesson on why not to use static backup filenames.<p>Yes, that would address this bug, and this bug only.<p>What if there&#x27;s another bug? Or the file system is full? Or `ed` gets kill -9&#x27;d? Or the PC loses power?<p>Assuming it&#x27;s possible to predict every single failure mode is foolish. It&#x27;s better to make a system safe by default. In the case of `ed`, simply periodically store the text buffer in a file and restore from it on startup.
omoikane大约 3 年前
I am glad vim has the option to place the swap files where you want them, and make them unique (by setting &#x27;directory&#x27; to end with &quot;&#x2F;&#x2F;&quot;).<p>For vim and ed and every other console program, I would run them inside screen(1) to avoid losing work due to network troubles, and network disconnects is usually where I get my SIGHUP.
评论 #30894858 未加载
YeGoblynQueenne大约 3 年前
That&#x27;s brilliant but I have a question: why are you doing your homework in ed?