fish-shell/fish-shell — pull request #1008 by lunixbochs (2013-09-19 01:10:03+00:00)
Title: Improve dangerous/undefined PID expansion behavior

In Bash, % means something like 'last job backgrounded'. Previously in Fish, it means either "all backgrounded jobs" or "all processes owned by your user".

I would run `kill -9 %` in Fish if I wanted to hard kill the last job backgrounded (useful if it wasn't responding).

`kill -9 %` will kill all of your processes if you ever accidentally run it without backgrounding something.

----

*Changes*

Use Bash-like expansion for empty searches (when you just use a '%' by
itself).

'%' will now *only* match the last valid backgrounded process.
If there are no such processes, an expansion error will be generated.

'%' by itself would previously match either *all* backgrounded
processes, or failing that, all processes owned by your user. If you
ever tried to run `kill -9 %`, it would either kill all backgrounded
processes or *all* of your processes. I'm not sure why anyone would ever
want that to be a single keystroke away. You could almost typo it.

As a result, `fg %`, `bg %`, `kill %`, etc will all operate on the last
process touched by job control.

----

Don't run 'by-name' matches when the search term is numeric.

This prevents you from running a command like `kill %1` and accidentally
killing a process named something like "1Command". Overloaded behavior
can be dangerous, and we probably shouldn't play fast and loose with
expansion characters that generate process IDs.