macupdater
Search…
Functions
What the functions do
The app has three functions: one to check the last update commands for errors, one to create a horizontal line in the log file and the last to open the log file at the end if there has been an error.

Catcher function

The first function reviews the last update commands for errors. It then prints update complete to the log or shows the error message. It takes module's name as a variable so that it can return a notification that tells you which update module failed. It also sets the Error flag to "1" so that if there has been an error the app will auto-open the log file for the user to inspect.
1
catcher () {
2
if [ "$?" = "0" ]; then
3
printf "$1 updates complete." >> $LOG # If no error, print update complete to file.
4
printf "" >> $LOG # Add an empty line to the file.
5
else # If error, show a dialog stating the section where the error occured.
6
echo "NOTIFICATION: '$1' updates failed."
7
ERROR=1 # Sets variable for error in script to 1.
8
fi
9
}
Copied!

Horizontal line function

This function simply creates a line in the log file to separate the different module sections.
1
line () {
2
echo "" >> $LOG # Starts the horizontal line on its own fresh line.
3
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - >> $LOG # Prints line
4
}
Copied!

Verify function

This function is called after updates have been completed and checks the error flag to see if there has been an error at any point during the running of the app. If an error has been produced the app auto-opens the log for the user to inspect.
1
verify () {
2
if [ $ERROR = 1 ]; then
3
open $LOG
4
echo "NOTIFICATION: Updates completed with some errors."
5
else
6
echo "NOTIFICATION: Updates completed."
7
fi
8
}
Copied!
Last modified 1yr ago