So I was making a script to check if Firefox is changing my preference on me. When I came across an oddity, see the following script.
check_ff_prefs.sh (this is the bare bones version)
#!/bin/bash
check_match() {
grep -qx -- "${1}" $2
exit_code=$?
if [ "$exit_code" == "0" ]; then
echo "does match $3"
else
echo "does not match $3"
fi
}
FILE_1=/home/mcm/projects/dotfiles/firefox/prefs.js
FILE_2=/home/mcm/.mozilla/firefox/6zpaipqa.mcm/prefs.js
last_line_file_1=$(tail -n 1 $FILE_1)
last_line_file_2=$(tail -n 1 $FILE_2)
check_match "$last_line_file_1" "$FILE_1" "file1 -> file1"
check_match "$last_line_file_2" "$FILE_2" "file2 -> file2"
check_match "$last_line_file_1" "$FILE_2" "file1 -> file2"
check_match "$last_line_file_2" "$FILE_1" "file2 -> file1"
if [ "$last_line_file_1" == "$last_line_file_2" ]; then
echo "they match"
else
echo "they don't match"
fi
echo $last_line_file_1 > last_line_file_1.txt
echo $last_line_file_2 > last_line_file_2.txt
diff last_line_file_1.txt last_line_file_2.txt
The above script's output is below
does match file1 -> file1
does match file2 -> file2
does not match file1 -> file2
does not match file2 -> file1
they do not match
1c1
< user_pref("webgl.vendor-string-override", " ");
---
> user_pref("webgl.vendor-string-override", " ");
As you can see the strings really don't match according to bash
, grep
and diff
.
Note: I have tried escaping the "
with this nonsense line=${line//\"/\\\"}
So my question is two fold.
- How are these lines actually different
- Is there something I can do with grep (or another program) to ignore this difference?
The two files that have output piped to them are here: https://github.com/robbmj/dotfiles/blob/alacritty_mods/firefox/last_line_file_1.txt https://github.com/robbmj/dotfiles/blob/alacritty_mods/firefox/last_line_file_2.txt
Thanks.