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 e1276d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions var/spack/repos/builtin/packages/grep/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ class Grep(AutotoolsPackage):
@classmethod
def determine_version(cls, exe):
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 e1276d4

Please sign in to comment.