Skip to content

Commit 3da3787

Browse files
committedJul 13, 2024·
Recognize brew.sh invocations
And tune shell script handling a bit.
1 parent a955753 commit 3da3787

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
 

‎px/px_commandline.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ def get_command(commandline: str) -> str:
284284
),
285285
)
286286

287-
if command in ["bash", "sh"]:
288-
return faillog(commandline, get_generic_script_command(commandline))
287+
if command in ["bash", "sh", "zsh"]:
288+
return faillog(
289+
commandline,
290+
get_generic_script_command(commandline, ignore_switches=["-p"]),
291+
)
289292

290293
if PERL_BIN.match(command):
291294
return faillog(commandline, get_generic_script_command(commandline))
@@ -562,9 +565,8 @@ def get_generic_script_command(
562565
if len(array) == 2:
563566
# vm + script
564567
return script
565-
if script not in ["brew.rb", "yarn.js"]:
568+
if script not in ["brew.rb", "brew.sh", "yarn.js"]:
566569
return script
567-
script = os.path.splitext(script)[0]
568570

569571
subcommand = array[2]
570572
if subcommand.startswith("-"):

‎tests/px_commandline_test.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def test_get_command_ruby_switches():
503503
px_commandline.get_command(
504504
"/usr/bin/ruby -W0 /usr/local/bin/brew.rb install rust"
505505
)
506-
== "brew install"
506+
== "brew.rb install"
507507
)
508508

509509
# https://github.com/walles/px/issues/87
@@ -621,7 +621,16 @@ def test_get_homebrew_commandline():
621621
]
622622
)
623623
)
624-
== "brew upgrade"
624+
== "brew.rb upgrade"
625+
)
626+
627+
628+
def test_get_bash_brew_sh_commandline():
629+
assert (
630+
px_commandline.get_command(
631+
"/bin/bash -p /usr/local/Homebrew/Library/Homebrew/brew.sh upgrade"
632+
)
633+
== "brew.sh upgrade"
625634
)
626635

627636

0 commit comments

Comments
 (0)
Please sign in to comment.