Skip to content

Commit

Permalink
Recognize brew.sh invocations
Browse files Browse the repository at this point in the history
And tune shell script handling a bit.
  • Loading branch information
walles committed Jul 13, 2024
1 parent a955753 commit 3da3787
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 6 additions & 4 deletions px/px_commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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("-"):
Expand Down
13 changes: 11 additions & 2 deletions tests/px_commandline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)


Expand Down

0 comments on commit 3da3787

Please sign in to comment.