From d1dbbb57d96df06cf0608f2d4325abf265498aa6 Mon Sep 17 00:00:00 2001 From: Alex Barcelo Date: Fri, 16 Feb 2018 12:21:33 +0100 Subject: [PATCH] Include root (start with /) case --- thefuck/rules/cd_correction.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/thefuck/rules/cd_correction.py b/thefuck/rules/cd_correction.py index ca3464b..5dded56 100644 --- a/thefuck/rules/cd_correction.py +++ b/thefuck/rules/cd_correction.py @@ -37,7 +37,11 @@ def get_new_command(command): dest = command.script_parts[1].split(os.sep) if dest[-1] == '': dest = dest[:-1] - if six.PY2: + + if dest[0] == '': + cwd = os.sep + dest = dest[1:] + elif six.PY2: cwd = os.getcwdu() else: cwd = os.getcwd()