nvbn / thefuck

Magnificent app which corrects your previous console command.
MIT License
84.8k stars 3.43k forks source link

Doesn't handle pipes #108

Open nwinkler opened 9 years ago

nwinkler commented 9 years ago

It looks like fuck doesn't handle pipes well. If I try to do this in Bash:

$ pss -ef | grep foo
-bash: pss: command not found
$ fuck
ps -ef | grep foo
ps: illegal argument: |
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-g grp[,grp...]] [-u [uid,uid...]]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]

It looks like the command is executed in the wrong way, it seems like it's trying to execute it as a single command, instead of treating it as a line of input with potentially multiple commands.

nwinkler commented 9 years ago

I think this can be fixed by changing the alias to use eval:

alias fuck='eval $(thefuck $(fc -ln -1))'

This makes it work for me:

$ fuck
ps -ef | grep foo
  502 12900  2764   0 11:13am ttys003    0:00.00 grep --color=auto foo

I'll create a PR for this...

nvbn commented 9 years ago

Reopened because in the future rules should be applied to every part of a command with pipes.

nwinkler commented 9 years ago

Yes, good point. I've seen that the no_command rule only fixes the first part of the command. Something like ps -ef | lss currently doesn't get fixed, since it doesn't check for possible alternatives for lss.

jchayan commented 7 years ago

Still doesn't work. Example: ps aux | grep 'ruby'

Output -> No fucks given

mhowell86 commented 3 years ago

Is anyone looking at this still?

$ find . | grepp \.go

Command 'grepp' not found, did you mean:

  command 'grep' from deb grep (3.4-1)

Try: sudo apt install <deb name>

$ fuck
No fucks given