From b8a9eff444eb9f5f120c85c96905af6b25d15546 Mon Sep 17 00:00:00 2001 From: v4rgas <66626747+v4rgas@users.noreply.github.com> Date: Thu, 15 May 2025 17:19:57 -0400 Subject: [PATCH] 6179b4cf-2d77-4c64-aedc-51282931cf4a --- thefuck_4/tests/shells/test_fish.py | 7 ++----- thefuck_4/thefuck/shells/fish.py | 14 +++----------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/thefuck_4/tests/shells/test_fish.py b/thefuck_4/tests/shells/test_fish.py index 815382b..efd684f 100644 --- a/thefuck_4/tests/shells/test_fish.py +++ b/thefuck_4/tests/shells/test_fish.py @@ -16,8 +16,7 @@ def Popen(self, mocker): mock.return_value.stdout.read.side_effect = [( b'cd\nfish_config\nfuck\nfunced\nfuncsave\ngrep\nhistory\nll\nls\n' b'man\nmath\npopd\npushd\nruby'), - (b'alias fish_key_reader /usr/bin/fish_key_reader\nalias g git\n' - b'alias alias_with_equal_sign=echo\ninvalid_alias'), b'func1\nfunc2', b''] + b'alias fish_key_reader /usr/bin/fish_key_reader\nalias g git'] return mock @pytest.mark.parametrize('key, value', [ @@ -70,9 +69,7 @@ def test_get_aliases(self, shell): 'pushd': 'pushd', 'ruby': 'ruby', 'g': 'git', - 'fish_key_reader': '/usr/bin/fish_key_reader', - 'alias_with_equal_sign': 'echo'} - assert shell.get_aliases() == {'func1': 'func1', 'func2': 'func2'} + 'fish_key_reader': '/usr/bin/fish_key_reader'} def test_app_alias(self, shell): assert 'function fuck' in shell.app_alias('fuck') diff --git a/thefuck_4/thefuck/shells/fish.py b/thefuck_4/thefuck/shells/fish.py index 5693404..471df2a 100644 --- a/thefuck_4/thefuck/shells/fish.py +++ b/thefuck_4/thefuck/shells/fish.py @@ -20,17 +20,9 @@ def _get_functions(overridden): def _get_aliases(overridden): aliases = {} proc = Popen(['fish', '-ic', 'alias'], stdout=PIPE, stderr=DEVNULL) - alias_out = proc.stdout.read().decode('utf-8').strip() - if not alias_out: - return aliases - for alias in alias_out.split('\n'): - for separator in (' ', '='): - split_alias = alias.replace('alias ', '', 1).split(separator, 1) - if len(split_alias) == 2: - name, value = split_alias - break - else: - continue + alias_out = proc.stdout.read().decode('utf-8').strip().split('\n') + for alias in alias_out: + name, value = alias.replace('alias ', '', 1).split(' ', 1) if name not in overridden: aliases[name] = value return aliases