2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/dev/tools/fixduplicatelanglines.sh
MDW c885c6917e Qual: Ignore most shellcheck annotations, fix some (#27452)
# Qual: Ignore most shellcheck annotations, fix some

Most shellcheck annotations are ignored - this is to make sure that ci
can work for existing scripts.

Some fixes were applied.

pre-commit script was beautyfied by temporarily suppressing the IFS= expression on 2 lines.
2024-01-12 21:03:08 +01:00

41 lines
947 B
Bash
Executable File

#!/bin/sh
# Recursively deduplicate file lines on a per file basis
# Useful to deduplicate language files
#
# Needs awk 4.0 for the inplace fixing command
#
# Raphaël Doursenaud - rdoursenaud@gpcsolutions.fr
# shellcheck disable=2006,2035,2044,2046,2061,2166,2268
# Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then
echo "Find exact duplicated lines into file (not cross file checking)"
echo "Usage: deduplicatefilelinesrecursively.sh [list|fix]"
fi
# To detect
if [ "x$1" = "xlist" ]
then
echo "Search duplicate line for lang en_US"
for file in `find htdocs/langs/en_US -type f -name *.lang`
do
if [ `sort "$file" | grep -v '^$' | uniq -d | wc -l` -gt 0 ]
then
echo "***** $file"
sort "$file" | grep -v '^$' | uniq -d
fi
done
fi
# To fix
if [ "x$1" = "xfix" ]
then
echo "Fix duplicate line for lang en_US"
for file in `find htdocs/langs/en_US -type f -name *.lang`
do
awk -i inplace ' !x[$0]++' "$file"
done;
fi