Skip to content

Commit 9a5da0d

Browse files
Fix brew casks fact for non-mac platforms (#604)
* Fix brew casks fact for non-mac platforms This command contains a bashism which causes parsing errors for some shells (for example dash as included in raspbian). POSIX test doesn't include any pattern matching, so fall back on grep as the next best thing. tested against both a mac (running bigsur) and an rpi (running raspbian) * Update cask fact test command. Co-authored-by: Nick Barrett <[email protected]>
1 parent abe5f95 commit 9a5da0d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pyinfra/facts/brew.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class BrewCasks(BrewPackages):
8181
}
8282
'''
8383

84-
command = (r'if [[ "$(brew --version)" =~ Homebrew\ +(1\.|2\.[0-5]).* ]];'
84+
command = (r'if brew --version | grep -q -e "Homebrew\ +(1\.|2\.[0-5]).*" 1>/dev/null;'
8585
r'then brew cask list --versions; else brew list --cask --versions; fi')
8686
requires_command = 'brew'
8787

tests/facts/brew_casks/casks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"command": "if [[ \"$(brew --version)\" =~ Homebrew\\ +(1\\.|2\\.[0-5]).* ]];then brew cask list --versions; else brew list --cask --versions; fi",
2+
"command": "if brew --version | grep -q -e \"Homebrew\\ +(1\\.|2\\.[0-5]).*\" 1>/dev/null;then brew cask list --versions; else brew list --cask --versions; fi",
33
"output": [
44
"1password-cli 0.10.0",
55
"google-chrome 76.0.3809.132",

0 commit comments

Comments
 (0)