diff --git a/px/px_commandline.py b/px/px_commandline.py index 3d1b3a0..7d32c8c 100644 --- a/px/px_commandline.py +++ b/px/px_commandline.py @@ -284,8 +284,11 @@ def get_command(commandline: str) -> str: ), ) - if command in ["bash", "sh"]: - return faillog(commandline, get_generic_script_command(commandline)) + if command in ["bash", "sh", "zsh"]: + return faillog( + commandline, + get_generic_script_command(commandline, ignore_switches=["-p"]), + ) if PERL_BIN.match(command): return faillog(commandline, get_generic_script_command(commandline)) @@ -562,9 +565,8 @@ def get_generic_script_command( if len(array) == 2: # vm + script return script - if script not in ["brew.rb", "yarn.js"]: + if script not in ["brew.rb", "brew.sh", "yarn.js"]: return script - script = os.path.splitext(script)[0] subcommand = array[2] if subcommand.startswith("-"): diff --git a/tests/px_commandline_test.py b/tests/px_commandline_test.py index 5d48065..4a0de2c 100644 --- a/tests/px_commandline_test.py +++ b/tests/px_commandline_test.py @@ -503,7 +503,7 @@ def test_get_command_ruby_switches(): px_commandline.get_command( "/usr/bin/ruby -W0 /usr/local/bin/brew.rb install rust" ) - == "brew install" + == "brew.rb install" ) # https://github.com/walles/px/issues/87 @@ -621,7 +621,16 @@ def test_get_homebrew_commandline(): ] ) ) - == "brew upgrade" + == "brew.rb upgrade" + ) + + +def test_get_bash_brew_sh_commandline(): + assert ( + px_commandline.get_command( + "/bin/bash -p /usr/local/Homebrew/Library/Homebrew/brew.sh upgrade" + ) + == "brew.sh upgrade" )