mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-03 23:43:40 +02:00
Update updater.sh
This commit is contained in:
parent
cdeb690abf
commit
eeaccf6508
1 changed files with 12 additions and 7 deletions
19
updater.sh
19
updater.sh
|
@ -317,16 +317,21 @@ 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=$(sdiff -s -w 500 $past_nocomments $current_nocomments)
|
diff=$(sdiff -s -w 1000 $past_nocomments $current_nocomments)
|
||||||
if [ ! -z "$diff" ]; then
|
if [ ! -z "$diff" ]; then
|
||||||
local leasttabs=999999
|
local leasttabs=999999
|
||||||
while read line; do
|
local oldIFS=$IFS
|
||||||
ntabs=$(echo "$line" | tr -c -d "\t" | wc -c)
|
while IFS= read -r line; do
|
||||||
# somehow lines starting with TAB are counted as 1 so we need to catch that
|
ntabs=$(printf '%s\n' "$line" | tr -c -d "\t" | wc -c)
|
||||||
if [ $ntabs -gt 1 ] && [ $ntabs -lt $leasttabs ]; then leasttabs=$ntabs; fi
|
if [ $ntabs -lt $leasttabs ]; then leasttabs=$ntabs; fi
|
||||||
done <<< "$diff"
|
done <<< "$diff"
|
||||||
# strip leasttabs-1 number of TABS once per line
|
IFS=$oldIFS
|
||||||
sed -E 's/\t{'$((leasttabs-1))'}//1' <<< "$diff" > "$diffname"
|
if [ $leasttabs -lt 2 ]; then
|
||||||
|
echo "$diff" > "$diffname"
|
||||||
|
else
|
||||||
|
# strip leasttabs-1 number of TABS once per line
|
||||||
|
sed -E 's/\t{'$((leasttabs-1))'}//1' <<< "$diff" > "$diffname"
|
||||||
|
fi
|
||||||
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}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue