I just did some experiments and gvim behaves differently that I thought it would.

```
echo hello >$def
gvim $def
```

This "works" since the variable `$def` is not set, it allows the use of `$` in the filename.

However, if we define `def`:

```
set def=xxx
gvim $def
```

we can no longer edit the `$def` file; gvim tries to edit `xxx` and there is no way to escape the `$` that I can find.

According to these experiments, for vim compatibility I should remove the check whether any substitutions failed and use the string "as is" in that case, because in any particular situation the '~' or '$' might actually be part of the filename.

If we want:

* tilde-expansion and environment variable substitution _and_
* the ability to refer to paths that start with `~` or contain `$`

and yet there is no quoting mechanism, then we will have to accept some odd situations like not being able to edit a file called `$PATH`.

If you agree, I will change the behavior to match vim, since it has already wrestled with these tradeoffs.