mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-21 08:07:09 +02:00
Update updater.sh
This commit is contained in:
parent
f3e2bfa76d
commit
3a5738240a
1 changed files with 10 additions and 4 deletions
14
updater.sh
14
updater.sh
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## ghacks-user.js updater for macOS and Linux
|
## ghacks-user.js updater for macOS and Linux
|
||||||
|
|
||||||
## version: 2.1
|
## version: 2.2
|
||||||
## Author: Pat Johnson (@overdodactyl)
|
## Author: Pat Johnson (@overdodactyl)
|
||||||
## Additional contributors: @earthlng, @ema-pe
|
## Additional contributors: @earthlng, @ema-pe
|
||||||
|
|
||||||
|
@ -317,14 +317,20 @@ update_userjs () {
|
||||||
remove_comments user.js $current_nocomments
|
remove_comments user.js $current_nocomments
|
||||||
|
|
||||||
diffname="userjs_diffs/diff_$(date +"%Y-%m-%d_%H%M").txt"
|
diffname="userjs_diffs/diff_$(date +"%Y-%m-%d_%H%M").txt"
|
||||||
diff=$(diff -w -B -U 0 $past_nocomments $current_nocomments)
|
diff=$(sdiff -s -w 500 $past_nocomments $current_nocomments)
|
||||||
if [ ! -z "$diff" ]; then
|
if [ ! -z "$diff" ]; then
|
||||||
echo "$diff" > "$diffname"
|
local leasttabs=999999
|
||||||
|
while read line; do
|
||||||
|
ntabs=$(echo "$line" | tr -c -d "\t" | wc -c)
|
||||||
|
# somehow lines starting with TAB are counted as 1 so we need to catch that
|
||||||
|
if [ $ntabs -gt 1 ] && [ $ntabs -lt $leasttabs ]; then leasttabs=$ntabs; fi
|
||||||
|
done <<< "$diff"
|
||||||
|
# strip leasttabs-1 number of TABS once per line
|
||||||
|
sed -E 's/\t{'$((leasttabs-1))'}//1' <<< "$diff" > "$diffname"
|
||||||
echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}"
|
echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}"
|
||||||
else
|
else
|
||||||
echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created.${NC}"
|
echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created.${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm $past_nocomments $current_nocomments $pastuserjs
|
rm $past_nocomments $current_nocomments $pastuserjs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue