Skip to content

Commit

Permalink
Fix style for finding external grep
Browse files Browse the repository at this point in the history
  • Loading branch information
climbfuji committed Dec 16, 2024
1 parent 4665c25 commit 68ca1c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions var/spack/repos/builtin/packages/grep/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ class Grep(AutotoolsPackage):

@classmethod
def determine_version(cls, exe):
version_string = Executable(exe)("--version", output=str, error=str).split('\n')[0]
version_string = Executable(exe)("--version", output=str, error=str).split("\n")[0]
# Linux
if "GNU grep" in version_string:
return version_string.lstrip("grep (GNU grep)").strip()
# macOS
elif "BSD grep, GNU compatible" in version_string:
return version_string.lstrip("grep (BSD grep, GNU compatible)").rstrip("-FreeBSD").strip()
return (
version_string.lstrip("grep (BSD grep, GNU compatible)").rstrip("-FreeBSD").strip()
)
# Don't know how to handle this version of grep, don't add it
else:
# Don't know how to handle this version of grep, don't add it
return None

def configure_args(self):
Expand Down

0 comments on commit 68ca1c4

Please sign in to comment.