New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set_color
with no arguments prints nothing
#5443
Comments
Makes sense to me! |
I was surprised to see: > set_color normal | string escape \e\[30m\e\(B\e\[m I only expected to see a sgr0 here. Cleanup a nearby `else { if (...) {` and comment with a bogus example.
As mentioned on Gitter, the only potential problem would be stuff like |
echo (set_color $somevar)somestring would otherwise print nothing. This isn't perfect - `set_color` calls that aren't in command substitutions, and successive set_color calls in one command substitutions will now have an extra line. E.g. set_color green; echo -n "banana" with TERM=dumb, or set_color $undefined; echo -n "banana" with $undefined undefined will now print \nbanana But it's probably much less of an issue - the one case we've hit is in the `read.expect` tests, which set TERM=dumb, but that's a hack. Fixes fish-shell#5443.
Okay, I've now implemented this, and it broke the read.expect tests - they run with TERM=dumb (like all expect tests, to have fewer colors to match), because the default read prompt looks like: #define DEFAULT_READ_PROMPT L"set_color green; echo -n read; set_color normal; echo -n \"> \"" And that idiom of doing set_color standalone shows up in a bunch of our sample prompts - https://github.com/fish-shell/fish-shell/search?p=2&q=set_color&unscoped_q=set_color. So they'd break if we just changed this like I asked for. So there's a few possibilities here:
One thing that seems to work is streams.out.append(L"z\b"); i.e. print "a character" and then a backspace. This seems safe, since the user already is okay with us printing something, as long as it's not visible characters. So any character that always has a width of 1 should do. Also this is just completely invisible - it'll keep the color as it was, and AFAIK it shouldn't move to a newline and then not back. Of course that still breaks assumptions about the "form" of the sequence - see e.g. 60f8eda. |
Oh, and since nobody commented on it:
@floam: The problem with NUL is that it would truncate arguments - Other control characters might work, but it seems prudent to restrict ourself to what's in ASCII, and that doesn't seem to have any fitting chars. |
There's actually a reverted commit that can help here. There used to be a |
What did that do, though? I mean we can make it so that If you did |
Hm, actually, not sure about that, the 'ignore' color seems to have had no output. |
I think the DEL character would work. |
8f33b55 removed it, and if I'm reading it correctly it printed nothing, so we're back at the same problem.
del and another char though? If you did |
I don't believe it will do anything. It should not affect output. It's only meaningful as input. |
|
Some research I did indicated that going back to before the vt100, there are two bare characters that are going to be treated as noops by the terminal: DEL and NUL. Since NUL is problematic, I'm leaning towards DEL. There are also a number of actual escapes that should be no-ops, but I worry about them causing garbage in funny situations. |
I'm coming here from this issue, which is caused by a closely related problem: |
I think the mistake there is |
That would do it, but it doesn't seem like programs typically print |
Most programs don't but I think a shell builtin doesn't want to have surprise output to stdout. So most shells do not have builtins that can take
Their builtins also take |
This comment has been minimized.
This comment has been minimized.
I recently ran into this issue with IlanCosman/tide#21. The user had some program that set the I've no idea as to the technical details of of which character to use, but fixing this would certainly improve quality of life for authors. |
Adding onto this, I ran into the issue with |
This was forgotten, so e.g. calling `set_color --bg foo` results in nothing being printed, which might result in strings being removed - #5443.
This is essentially a re-run of #1335, which I assumed fixed just this but apparently didn't.
Apparently, a bare
set_color
will exit with no output.Obviously, that's an issue if there's a cartesian product, like
which in turn is a problem if a color happens to be undefined.
Instead, in this case it'd be nice if set_color always printed exactly one line. If not given any arguments, that means just a newline.
The text was updated successfully, but these errors were encountered: