Live data from Hacker News

Vim's 400 line function to wait for keyboard input

geoff.greer.fm

131–140 of 239 posts

Re: Vim's 400 line function to wait for keyboard input

#131

Earlier quoted context omitted.

Exactly - I (incorrectly) assumed most folks had previously read the article. Mea culpa.

May I know which article? (I mean, the article about joel's paying the price.

Background on Wasabi: http://www.joelonsoftware.com/items/2006/09/01b.html http://blog.fogcreek.com/the-origin-of-wasabi/

Killing of wasabi: http://blog.fogcreek.com/killing-off-wasabi-part-1/

Codding Horror on Wasabi: http://blog.codinghorror.com/has-joel-spolsky-jumped-the-sha...

Re: Vim's 400 line function to wait for keyboard input

#132
post #39
post #5

Earlier quoted context omitted.

You can refactor it into multiple functions (#ifdefs around a line containing just "||"? seriously??), some of which are no-ops on some platforms / configurations, and let the compiler deal with inlining the functions that exist and optimizing out those that don't. (Not that you would have noticed the overhead anyway, probably.)

Probably with heavy code duplication though, as eg X clipboard management and X session management appear to be cross-cutting concerns. I mean, if you bury the ugly in just one function, I don't see how everyone is calling this horrid engineering. edit: I read this [1] and maybe the ugly isn't localized =P edit2: since you're reading this, thank you for ag . I use it every day. [1] http://geoff.greer.fm/2015/01/15/wh…

(Just realized this might be confusing: I'm a different Geoff. Geoff Greer is ggreer, but he's also in these comments.)

Re: Vim's 400 line function to wait for keyboard input

#133

Earlier quoted context omitted.

vim crashes or hangs for me about once every month. I've never bothered to find out why since I don't think it's worth the effort. The effort would be lower if the code was cleaner and didn't have so much bloat related to platforms that don't exist. It would definitely be easier to submit a patch if I didn't need to cater to all the platforms I've never seen.

Most likely you've typed Ctrl-S, which causes the terminal to pause. Here is the what the vim docs have to say about that: Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again.

This was my biggest hurdle to learning vim, I kept hitting Ctrl-S...

Re: Vim's 400 line function to wait for keyboard input

#134
post #132
post #39

Earlier quoted context omitted.

Probably with heavy code duplication though, as eg X clipboard management and X session management appear to be cross-cutting concerns. I mean, if you bury the ugly in just one function, I don't see how everyone is calling this horrid engineering. edit: I read this [1] and maybe the ugly isn't localized =P edit2: since you're reading this, thank you for ag . I use it every day. [1] http://geoff.greer.fm/2015/01/15/wh…

(Just realized this might be confusing: I'm a different Geoff. Geoff Greer is ggreer, but he's also in these comments.)

wow, reading is hard. My apologies for getting you confused!

Re: Vim's 400 line function to wait for keyboard input

#136

Earlier quoted context omitted.

aka bitrot

Bitrot means degradation of physical media containing digital data, not really anyting to do with bugs appearing in code that is introduced into a new environment.

It has been used almost interchangably with code rot in this sense for a long time: http://www.catb.org/jargon/html/B/bit-rot.html

Re: Vim's 400 line function to wait for keyboard input

#137
post #98

Earlier quoted context omitted.

Wow that's rude. No need to insult someone's upbringing on a thread based on their musings about a snippet of code. Also you're wrong. Critique is useful in and of itself, not just as a direct means to getting something fixed. If person A doesn't have the time/skill to fix something, they can critique it, hope that person B sees the critique and goes on to fix it. Also, by critiquing it, it starts a discussion about…

The 'ol "raising awareness" argument is way too slippery to be nailed down and often leads people to finding exactly the interpretation w/r/t utility that they want. Regardless, I think it's pretty reasonable to suggest that telling a community of developers "old code is a bit shit" isn't useful. Especially when the code in question is on a codebase that already has a serious modernization effort underway. And there…

The author of the blog post[1] associated with that code sample has, in fact, attempted to submit patches to the original vim codebase. Many people have. They were rejected. That's why neovim exists now.

So this is providing criticism in the service of providing a solution.

[1]: http://geoff.greer.fm/2015/01/15/why-neovim-is-better-than-v...

Re: Vim's 400 line function to wait for keyboard input

#138
post #58
post #8

This is a classic case of why legacy code is a nightmare to maintain. It's the OpenSSL situation all over again, and one can definitely see the appeal of going through there and ripping out all of the functionality that nobody uses anymore just to make maintenance less of a nightmare. Luckily vim doesn't run suid root on any sane system, so all of this legacy cruft is not as huge of a threat surface on the machine.

It is still an issue, since vi/vim gets used for sudo purposes all the time. Any time someone uses visudo to modify their sudoers file, for example, that's giving root privileges to vim.

When you visudo, you are subjecting vim to (1) your chosen input and (2) the contents of sudoers. If you are malicious, you could choose your input to be ":!", which gives you a root shell. If the contents of sudoers are malicious, they can give root access to whoever they want. So visudo is not a particularly dangerous scenario.

Of course, it's possible that some aspect of vim will, say, create a temp file insecurely as root, or read random shit out of /proc, or what have you, and be exploitable. But the historical security problems in vim (and there have been several!) have mostly had to do with editing maliciously-composed files with it.

Re: Vim's 400 line function to wait for keyboard input

#139

Earlier quoted context omitted.

aka bitrot

Bitrot means degradation of physical media containing digital data, not really anyting to do with bugs appearing in code that is introduced into a new environment.

> The Jargon File, a compendium of hacker's lore, defines "bit rot" as a jocular explanation for the degradation of a software program over time even if "nothing has changed"; the idea being this is almost as if the bits that make up the program were subject to radioactive decay.

https://en.m.wikipedia.org/wiki/Software_rot

Post reply on HN