File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55binDefaults=" /usr/bin/defaults"
66binReload=" /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings"
7- version=" 1.0"
7+ version=" 1.0.1 "
88
99# # endregion ########################################### End Static Variables
1010
@@ -118,10 +118,12 @@ done
118118prefix=" sudo -u $targetUser "
119119action=" ${args[0]} "
120120
121+ # Determine if this will write
122+ if echo " $action " | grep -q ' write\|array\|array-add\|dict\|dict-add' ; then
123+ isWrite=true
124+ fi
125+
121126if [ " $action " == " write" ] && $isSingle ; then
122- # Get Particulars
123- domain=" ${args[1]} "
124- key=" ${args[2]} "
125127 if $isType ; then
126128 type=" ${args[3]} "
127129 value=" ${args[4]} "
@@ -159,23 +161,22 @@ done
159161
160162# Output if Applicable
161163if $isQuiet ; then
162- if $commandStr /dev/null 2>&1 ; then
163- if echo " $action " | grep -q ' write\|array\|array-add\|dict\|dict-add' ; then
164- $prefix $binReload -u
165- fi
166-
167- exit 0
164+ if $isWrite ; then
165+ $commandStr /dev/null 2>&1
166+ else
167+ $commandStr 2> /dev/null
168168 fi
169+ exitCode=$?
169170else
170- if $commandStr ; then
171- if echo " $action " | grep -q ' write\|array\|array-add\|dict\|dict-add' ; then
172- $prefix $binReload -u
173- fi
171+ $commandStr
172+ exitCode=$?
173+ fi
174174
175- exit 0
176- else
177- exit $?
178- fi
175+ if [ " $exitCode " -eq " 0" ] && $isWrite && [ -f " $binReload " ]; then
176+ # Reload preferences
177+ $prefix $binReload -u
179178fi
180179
180+ exit " $exitCode "
181+
181182# # endregion ########################################### End Main Code
You can’t perform that action at this time.
0 commit comments