File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 9191# ReportManual Log manual actions to report file
9292# ReportSuggestion Add a suggestion to report file
9393# ReportWarning Add a warning and priority to report file
94+ # RunBrewCmd Run Homebrew commands as a normal user instead of root
9495# SafeFile Security tests to perform on a file before using it
9596# SafePerms Check if a file has safe permissions
9697# SafeInput Test provided string to see if it contains unwanted characters
30363037 }
30373038
30383039
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+
30393056 # ###############################################################################
30403057 # Name : SafeInput()
30413058 # Description : Test provided string to see if it contains unwanted characters
Original file line number Diff line number Diff line change 127127 LogText " Test: Querying brew to get package list"
128128 Display --indent 4 --text " - Querying brew for installed packages"
129129 LogText " Output:" ; LogText " -----"
130- GPACKAGES=$( brew list --versions)
130+ GPACKAGES=$( RunBrewCmd list --versions)
131131 while IFS= read -r PKG; do
132132 PACKAGE_NAME=$( echo ${PKG} | ${CUTBINARY} -d ' ' -f1)
133133 PACKAGE_VERSION=$( echo ${PKG} | ${CUTBINARY} -d ' ' -f2)
183183 PACKAGE_VERSION=$( defaults read " $CS /Contents/Info" CFBundleShortVersionString 2> /dev/null || echo " N/A" )
184184 LogText " Found CoreServices: ${PACKAGE_NAME} (version: ${PACKAGE_VERSION} )"
185185 INSTALLED_PACKAGES=" ${INSTALLED_PACKAGES} |${PACKAGE_NAME} ,${PACKAGE_VERSION} "
186- done
186+ done
187187 fi
188188#
189189# ################################################################################
You can’t perform that action at this time.
0 commit comments