-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults_write
More file actions
executable file
·59 lines (48 loc) · 836 Bytes
/
defaults_write
File metadata and controls
executable file
·59 lines (48 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
function help {
echo "Script for writing multiple defaults in macos x"
echo "Usage:"
echo " $(basename $0) filename"
exit 1
}
function run {
if [ "$1" = "-p" ]; then
PRINT="-p"
shift
fi
if [ -z "$1" ]; then
echo "No command to run!"
exit 1
fi
if [ "${PRINT}" = "-p" ]; then
echo "writing:"
echo "$@"
fi
eval defaults write $@
RES=$?
if [ ${RES} -ne 0 ]; then
ISSUES=$((ISSUES+1))
REPORT=${REPORT}'\n'"$@ exited with ${RES}"
else
PASSED=$((PASSED+1))
fi
}
if [ -z "$1" ]; then
help
fi
FILE_NAME="$1"
REPORT=""
ISSUES=0
PASSED=0
FILE=`grep "^[^#;]" ${FILE_NAME}`
IFS=$'\n'
ENTRIES=(${FILE})
IFS=' '
for ENTRY in "${ENTRIES[@]}"
do
run ${ENTRY}
done
echo "Finished!"
echo "Written: ${PASSED}"
echo "Issues: ${ISSUES}"
echo -e ${REPORT}