This is to help address bad corrections like the following (note the
position of the -p flag):
thefuck 'git log $(git ls-files thefuck | grep python_command) -p'
git log $(git ls-files thefuck | grep -p python_command) [enter/↑/↓/ctrl+c]
These were found by creating a `.flake8` file containing:
[flake8]
ignore = E501,W503
exclude = venv
then running:
flake8 $(git diff master... --name-only)
See https://github.com/nvbn/thefuck/pull/563 for running `flake8` in CI
This ensures that even if the command suggested and run by `thefuck`
fails, it will still be added to the history, allowing the user to tweak
it further (or run `fuck` again) if desired.
Note that the fish shell appears to already behave this way.
For example:
$ git log README.md -p
fatal: bad flag '-p' used after filename
$ fuck
git log -p README.md [enter/↑/↓/ctrl+c]
Aborted
$ git log -p README.md --name-only
fatal: bad flag '--name-only' used after filename
$ fuck
git log -p --name-only README.md [enter/↑/↓/ctrl+c]
Aborted
$ git log README.md -p CONTRIBUTING.md
fatal: bad flag '-p' used after filename
$ fuck
git log -p README.md CONTRIBUTING.md [enter/↑/↓/ctrl+c]
Suggest `foo --help` instead. However, if there are man pages, suggest
`foo --help` after `man 2/3 foo`
This addresses the comment in the previous commit message:
> However, in cases where multiple sections have man pages for `foo`,
> running `man foo` could bring up the "wrong" section of man pages.
> `man read` is an example of this, but that should probably be handled in
> a way that still suggests `foo --help` first when there are *no* man
> pages for `foo` in any section.
`man` without a section searches all sections, so having `foo --help`
suggested first makes more sense than adding a specific section. See
https://github.com/nvbn/thefuck/pull/562#issuecomment-251142710
However, in cases where multiple sections have man pages for `foo`,
running `man foo` could bring up the "wrong" section of man pages.
`man read` is an example of this, but that should probably be handled in
a way that still suggests `foo --help` first when there are *no* man
pages for `foo` in any section.
Closes https://github.com/nvbn/thefuck/issues/546
This is along the lines of what @waldyrious suggested in
https://github.com/nvbn/thefuck/issues/546, but it just adds a new
suggestion rather than replacing the other ones.