nvbn / thefuck

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

Buggy o/p: When 'fuck' is coupled with 'rmdir' #152

Closed ghost closed 9 years ago

ghost commented 9 years ago

screenshot from 2015-05-01 16 06 38

As seen from the above picture, 'rmdir' causes fuck to behave funny.

After deleting a directory created using fuck if I try to recreate it, it does recreate it but gives the output on the console as 'No fuck given'.

This happens repeatedly everytime the same set of statements is executed.

(PS: I am a novice student so please bear with me if I make a few noob mistakes.)

pranav15197 commented 9 years ago

The problem seems to be with the history class, as on commenting out the following in the get_command function the issue disappears

#if script == 'fuck' or script == history.last_script:
#    script = history.last_fixed_script or history.last_script
scorphus commented 9 years ago

Strange. It works just fine for me, I couldn't reproduce:

screen shot 2015-05-01 at 2 00 47 pm

pranav15197 commented 9 years ago

This seems to be a more general issue, as same bug appears if you repeat any wrong command - for example selection_003

pranav15197 commented 9 years ago

changing

if script == 'fuck' or script == history.last_script:
       script = history.last_fixed_script or history.last_script

to

if script == 'fuck' or script == history.last_script:
       script = history.last_script or history.last_fixed_script

fixes the issue

scorphus commented 9 years ago

It seems to be a problem with Bash. It works nice with Fish:

screen shot 2015-05-01 at 2 09 33 pm

ghost commented 9 years ago

@pranav15197 The fix worked on my system too. Thanks.

scorphus commented 9 years ago

What shell are you using? What version of TheFuck? It works for me in Bash too:

screen shot 2015-05-01 at 2 16 04 pm

pranav15197 commented 9 years ago

I cloned the repo today and installed it for development, the version = 1.32 on the setup.py file

ghost commented 9 years ago

Same as @pranav15197 . thefuck - Installed today, version 1.32 GNU Bash - version 4.2.42, default with linux 12.04

nvbn commented 9 years ago

Yep, repeats for me with:

➜  cd dummy 
autoenv_cd:cd:2: no such file or directory: dummy
➜  fuck
mkdir -p dummy && cd dummy [enter/ctrl+c]
➜  cd ..
➜  rm -rf dummy 
➜  cd dummy
autoenv_cd:cd:2: no such file or directory: dummy
➜  fuck
No fuck given
scorphus commented 9 years ago

Oh! It works for me:

»»»» cd dummy
cd: The directory 'dummy' does not exist
»»»» fuck
mkdir -p dummy && cd dummy
»»»» cd ..
»»»» rm -rf dummy
»»»» cd dummy
cd: The directory 'dummy' does not exist
»»»» fuck
mkdir -p dummy && cd dummy
»»»» pip freeze | grep thefuck
thefuck==1.32
»»»» fish --version
fish, version 2.1.2
scorphus commented 9 years ago

It also works with bash:

bash-4.3$ ls
bash-4.3$ cd dummy
bash: cd: dummy: No such file or directory
bash-4.3$ fuck
mkdir -p dummy && cd dummy
bash-4.3$ cd ..
bash-4.3$ rm -rf dummy
bash-4.3$ cd dummy
bash: cd: dummy: No such file or directory
bash-4.3$ fuck
mkdir -p dummy && cd dummy
bash-4.3$ pip freeze | grep thefuck
thefuck==1.32
bash-4.3$ bash --version
GNU bash, version 4.3.33(1)-release (x86_64-apple-darwin14.1.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
nvbn commented 9 years ago

@scorphus it repeats only in version from git.

And I almost know how to fix it =)

scorphus commented 9 years ago

Oh, my bad. Sorry, I thought I was helping. I now confirm this issue.

nvbn commented 9 years ago

Probably fixed in 1.35+

scorphus commented 9 years ago

I confirm it is fixed in Fish and Bash. Thanks @nvbn!

ghost commented 9 years ago

Thanks @nvbn :)