@@ -37,19 +37,14 @@ diff_files() {
37
37
return 1
38
38
fi
39
39
40
- if (cmp -s " $1 " " $2 " ) ; then
41
- # If they are identical, then return
40
+ if is_binary " { $1 } " || is_binary " ${2} " ; then
41
+ echo " File is binary. Skipping interactive diff "
42
42
return 0
43
- else
44
- if is_binary " {$1 }" || is_binary " ${2} " ; then
45
- echo " File is binary. Skipping interactive diff"
46
- return 0
47
- fi
48
- vimdiff -d " $1 " " $2 " || {
49
- echo " vimdiff on ${1} <-> ${2} ' exited with error"
50
- return 1
51
- }
52
43
fi
44
+ vimdiff -d " $1 " " $2 " || {
45
+ echo " vimdiff on ${1} <-> ${2} ' exited with error"
46
+ return 1
47
+ }
53
48
}
54
49
55
50
gpg_encrypt_file () {
@@ -63,27 +58,38 @@ gpg_encrypt_file() {
63
58
local output_filename
64
59
output_filename=$( basename " $output_file_path " )
65
60
local tmp_output_file_path=" ${tmp_path} /${output_filename} "
61
+ local input_file_existing_equal=false
66
62
67
63
# if the file to replace already exists, perform a diff to check for changes
68
64
if [[ -f " $output_file_path " ]]; then
69
65
tmp_output_file_path_current=" $tmp_output_file_path " .current
70
- gpg --local-user " $gpg_encryption_subkey " --armor --decrypt --yes --output " $tmp_output_file_path_current " " $output_file_path " || {
66
+ gpg --quiet --no-verbose -- local-user " $gpg_encryption_subkey " --armor --decrypt --yes --output " $tmp_output_file_path_current " " $output_file_path " > /dev/null || {
71
67
echo " failed to decrypt file ${output_file_path} to ${tmp_output_file_path_current} "
72
68
return 1
73
69
}
74
70
75
- diff_files " $tmp_output_file_path_current " " $input_file_path "
71
+ if (cmp -s " $tmp_output_file_path_current " " $input_file_path " ); then
72
+ input_file_existing_equal=true
73
+ else
74
+ diff_files " $tmp_output_file_path_current " " $input_file_path "
75
+ fi
76
76
fi
77
77
78
- gpg -v --local-user " $gpg_encryption_subkey " --recipient " $gpg_encryption_subkey " --armor --sign --yes --output " $tmp_output_file_path " --encrypt " $input_file_path " || {
79
- echo " failed to encrypt file ${input_file_path} to ${tmp_output_file_path} "
80
- return 1
81
- }
78
+ if [[ $input_file_existing_equal == true ]]; then
79
+ printf " %s <-> %s are equal. skipping encryption.\n" " $input_file_path " " $output_file_path "
80
+ else
81
+ gpg --quiet --no-verbose --local-user " $gpg_encryption_subkey " --recipient " $gpg_encryption_subkey " --armor --sign --yes --output " $tmp_output_file_path " --encrypt " $input_file_path " > /dev/null || {
82
+ echo " failed to encrypt file ${input_file_path} to ${tmp_output_file_path} "
83
+ return 1
84
+ }
82
85
83
- cp -f " $tmp_output_file_path " " $output_file_path " || {
84
- echo " failed to copy '${tmp_output_file_path} ' to '${output_file_path} '"
85
- return 1
86
- }
86
+ cp -f " $tmp_output_file_path " " $output_file_path " || {
87
+ echo " failed to copy '${tmp_output_file_path} ' to '${output_file_path} '"
88
+ return 1
89
+ }
90
+
91
+ printf " %s -> %s\n" " $input_file_path " " $output_file_path "
92
+ fi
87
93
}
88
94
89
95
if [[ " $current_hostname " != " $laptop_hostname " ]] && [[ " $current_hostname " != " $desktop_hostname " ]]; then
0 commit comments