File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 91
91
# ReportManual Log manual actions to report file
92
92
# ReportSuggestion Add a suggestion to report file
93
93
# ReportWarning Add a warning and priority to report file
94
+ # RunBrewCmd Run Homebrew commands as a normal user instead of root
94
95
# SafeFile Security tests to perform on a file before using it
95
96
# SafePerms Check if a file has safe permissions
96
97
# SafeInput Test provided string to see if it contains unwanted characters
3036
3037
}
3037
3038
3038
3039
3040
+ # ###############################################################################
3041
+ # Name : RunBrewCmd()
3042
+ # Description : Run Homebrew commands as a normal user instead of root
3043
+ #
3044
+ # Parameters : $@ = Homebrew command arguments
3045
+ # Returns : None (executes the command as the appropriate user)
3046
+ # ###############################################################################
3047
+
3048
+ RunBrewCmd () {
3049
+ case " $( id -u) " in
3050
+ 0) sudo -u " $SUDO_USER " brew " $@ " ;;
3051
+ * ) brew " $@ "
3052
+ esac
3053
+ }
3054
+
3055
+
3039
3056
# ###############################################################################
3040
3057
# Name : SafeInput()
3041
3058
# Description : Test provided string to see if it contains unwanted characters
Original file line number Diff line number Diff line change 127
127
LogText " Test: Querying brew to get package list"
128
128
Display --indent 4 --text " - Querying brew for installed packages"
129
129
LogText " Output:" ; LogText " -----"
130
- GPACKAGES=$( brew list --versions)
130
+ GPACKAGES=$( RunBrewCmd list --versions)
131
131
while IFS= read -r PKG; do
132
132
PACKAGE_NAME=$( echo ${PKG} | ${CUTBINARY} -d ' ' -f1)
133
133
PACKAGE_VERSION=$( echo ${PKG} | ${CUTBINARY} -d ' ' -f2)
183
183
PACKAGE_VERSION=$( defaults read " $CS /Contents/Info" CFBundleShortVersionString 2> /dev/null || echo " N/A" )
184
184
LogText " Found CoreServices: ${PACKAGE_NAME} (version: ${PACKAGE_VERSION} )"
185
185
INSTALLED_PACKAGES=" ${INSTALLED_PACKAGES} |${PACKAGE_NAME} ,${PACKAGE_VERSION} "
186
- done
186
+ done
187
187
fi
188
188
#
189
189
# ################################################################################
You can’t perform that action at this time.
0 commit comments