Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Default `string split` to removing empty entries with option to keep #4779
The official fish documentation makes no mention of how
Author's note: I'm unsure if there is any code out there that will be broken
I'm kinda wary of changing the default here. That would break a bunch of stuff.
set -gx $var (string split -- ':' $val)
given that empty elements in $PATH have a specific meaning, that would change behavior.
Other things would benefit from this - the
set -l parts (string trim $line | string split " " -m 1)
which just looks like an attempt to remove the empty elements at the beginning and end.
But that would be alright as an additional option.
So: "--no-empty" please!
Nice catch on the path splitting. I question whether that particular case had been considered at the time or if it's just a lucky coincidence! I actually didn't know there could be an empty entry in the PATH, what meaning does that have?
It's perhaps a question of utility, however. If we are taking this opportunity to break things, I suppose we should ask "how much will break" and "is the future benefit worth it" (i.e. to which degree is either option "the intended behavior" when used)?
Actually, to take the example of PATH we were just discussing. Is the effect of an empty entry in the PATH more often a confusing side effect one wasn't expecting, or purposeful behavior desired and consciously achieved?
We have had discussions about empty $PATH components, but IIRC not in that context.
Same thing as "." - i.e. the current $PWD. (Yeah, not very exciting)
I'd add a third and fourth question:
And the former is the big issue here. You need to check every single use of
Compared with e.g. my
It's not that I'm against changing things for the better, it's that I want to have a smooth upgrade path for users.