32,405 karma · joined Jan 3, 2008 (18y ago) · 8,297 submissions
comment 6y ago · link · parent
I would imagine - depending on the terminal emulator - the zsh behavior would cause copy-paste-cruft in the form of trailing whitespace while appearing correct, and would guess this was why we changed our implementation.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
I think the missing clue is that the hack is followed by `^[[K` (clear line from the cursor to the right), before control is passed to `fish_prompt` to paint the prompt or whatever else.
Here's some sample output (stripped of the hack spaces and any ansii escapes):
mqudsi@ZBOOK /m/c/U/mqudsi> echo -n hello
hello¶
mqudsi@ZBOOK /m/c/U/mqudsi>
`fish_prompt` isn't called until the cursor is already at column 0 and the line is clear; the "missing line ending glyph" (here ¶ rather than ⏎ because fish correctly detected that the latter is likely not supported by the font used by my terminal emulator in yet another hack) is emitted at the end of the previous line.You can see all this and more by piping the output of a `fish --interactive` session to `xxd -C` or `hexyl` or whatever (that'll disable tty feature detection and force ansii escapes to be emitted that you can then inspect).`
(You can also verify by simply using `sleep 1` as your fish_prompt - you'd expect to see the glyph appear at least while the `sleep` was running if fish were waiting on/expecting the prompt to overwrite the glyph.)
comment 6y ago · link · parent
Not directly in fish, because we manually set the tty flags and restore them after each execution (it's why your fish prompt doesn't break when you ^C in the middle of a redirect or when you accidentally output binary to the terminal), but e.g. in bash or if fish were to emit those escape codes directly. But yeah, it definitely seems like a good hack and it would cut down on the bandwidth requirements (you can notice the lag when using fish/zsh over ssh on a lossy connection).
Note that depending on the xn attribute, \r may or may not end up taking you to col 0 of the same row, depending on if the previous output caused a soft wrap but didn't include the trailing new line - you could wind up at col 0 of the previous row instead, if I'm reading it correctly!
comment 6y ago · link · parent
The real problem is I'm not sure when the last boolean capability was added to the termcap standard. While new terminals continue to add and update their termcaps, the spec itself is missing a lot of features that would help enormously.
comment 6y ago · link · parent
It all depends on where the input cursor is when the command terminated. You need something that works with both cases (line break and no line break) because you can’t introspect the output.
tput el clears the output to the end of line so you still have to figure out if you’re on the same line as the output or if you’re on a new line. The goal of spaces is not to clear content but to invoke the wrapping behavior of the terminal which will either cause you to be on the same line only in the case that you started off at col 0 or else somewhere in the middle of the next line, but in both cases, you’re on the row you need to be on (after taking into account whether wrapping happens at max column or max column plus one).
Edit: It’s actually a lot like rounding by adding 0.5 and truncating. And the complexities are akin to trying to do it with non-standardized or different standards of doubles and dealing with epsilon and NaN :D
comment 6y ago · link · parent
This feature is still surprisingly complicated with many caveats. For example, some terminals will wrap to the next line if you are at $COLUMNS, some at $COLUMNS+1, and some not at all. Some advertise they do one thing and do another. If you miscalculate, you’ll end up skipping an extra line or none at all, maybe overwriting existing output or emitting the missing line break glyph when it should be hidden. We’ve ironed out most of the cases but every once in a while someone will be running an esoteric Pseudo tty (usually not under X) and run into issues.
There are also issues with selection of content. Some terminal emulators will bug out when you try to copy-and-paste content because they get lost with the output past the current location in cases where a line break was already emitted. It’s always the terminal emulator that’s broken but you’d be surprised at how broken some of the most popular emulators are. The entire codebase is littered with workarounds for tty emulators; if someone comes to you and says “fish doesn’t work in $terminal but bash does” (either because it’s minimalistic and is missing a feature that would cause the breakage or because it has a workaround), we almost always end up treating it as a fish bug unless we’re able to get it fixed in the upstream terminal package/OS/software/whatever, whom we file reports with all the time.
It’s insane the configurations and platforms people use shells under and I’m personally deeply appreciative of everyone that takes the time to file these bugs - in addition to making the software better it really does shed light on some extremely archaic bits of posix standards and Unix behavior and I’ve learned so much from the many deep-dives that start off with “this is kind of quirky behavior observed under certain circumstances” and ends up requiring architectural changes deep within because some underlying assumption doesn’t hold universally true as exemplified by a *nix that hasn’t seen a new user in fifteen years or something. It’s why I love hacking on fish; I must have one of the craziest collection of virtual machines to test edge cases, as do many of the other devs (especially @zanchey and @faho, although no one does a deep dive like @ridiculousfish).
comment 6y ago · link · parent
Suddenly you can get your book for free without even the legal or ethical hazards.
comment 6y ago · link · parent
comment 6y ago · link · parent
What that tells you is that their board does not place the sustainability and long-term availability of the archive over all other metrics and I think that’s a fundamental issue that can’t be corrected. If growth, popularity, increasing in scope, etc are more important to the archive’s board than the guaranteed existence of the content they’ve curated ten, twenty, or a hundred years from now then they are not worthy protectors of it. The archive’s worth isn’t the data they have today, it’s the fact that they promised to safekeep it for the years to come. If they can’t be trusted to do that and place that over everything else, then they are failing what the whole world has been sharing data and making donations in the name of.
comment 6y ago · link · parent
It’s not like the Archive doesn’t know what kind of people they are dealing with. They know publishers are out to stop second hand sales, ebook lending, right of resellers to set prices, and a million other things. It’s like expecting the RIAA or the MPAA to settle for an injunction when they have the chance to kill Napster/TPB/IsoTorrent/whatever. If it’s really in order to set a precedent then that’s damn short-sighted.
comment 6y ago · link · parent
I’m an executive board member for a much smaller IRL non-profit and could never imagine opening us up to such liabilities. I honestly cannot fathom how this came to pass.
comment 6y ago · link · parent
I messaged the HN mods many years ago (either pg or dang, can't remember) when things had changed and I had decided to just use my real name online but was told that it would not be possible to change it for posterity purposes.
comment 6y ago · link · parent
Yet I still have to define startsWith() and endsWith() any time I touch PHP code...
(More importantly, PHP is the one language I can never write from memory without referencing the manual for each and every function call because of how inconsistent it is. Eg Sometimes $haystack is the first parameter and sometimes it is $needle.)