fish-shell/fish-shell — pull request #354 by Soares (2012-11-12 16:37:39+00:00)
Title: A case against brace expansion

I think brace expansion should be removed.

I know, I know, it's a cool feature and it's often very convenient. Bear with me for a moment:

First of all, it's inconsistent. Why does it use commas as separators instead of spaces? I thought maybe so you can have spaces in your brace expansion, but that yields a parse error:

> echo {a b c d}
fish: could not expand string "{a"

It seems that there's no good reason for this other than compatibility with other shells. Brace expansion is not POSIX. Fish should be consistent with itself first and POSIX second and answer to no one else. Given all the [recent hoopla](https://github.com/fish-shell/fish-shell/issues/159) about separator consistency I think it's important that we use one separator everywhere. So at the very least, brace expansion should use spaces as a separator.

But if we allow use space separation in brace expansion then we realize that it's exactly the same thing as `(echo ...)`. Check it out:

> mv file.(echo txt markdown)

works just as well as

> mv file.{txt,markdown}

This is a super cool side effect of how [lists work together](https://github.com/fish-shell/fish-shell/issues/352). It's five extra characters to use echo. Five. Seems pretty [non-orthogonal](http://ridiculousfish.com/shell/user_doc/html/design.html) to me.

It can be convenient, sometimes, to just have those braces when you want to rename/move a bunch of files. I get it. The terse syntax is nice, and people might expect it coming from other shells.

But before you argue that that five character reduction is good, remember that the brace characters themselves are pretty harmful.

For example, whenever you want to specify a commit in a git command:

> git reset --soft HEAD@{2}

This blows up unless you use `HEAD@\{2\}`

That costs me two extra characters and a headache. I use commands with braces on *at least* a 3:1 ratio with brace expansion, so brace expansion *actually hurts me as a user*, even if you ignore the headaches that it causes!

It uses inconsistent separator characters, doesn't allow spaces, and saves you five characters. At the same time it dicks you over when you try to use certain git commands and any other commands that want braces.

It's really just `(echo ...)`! It's non-orthogonal! Give it the axe.