nutools/ldiff

34 lines
982 B
Plaintext
Raw Normal View History

2023-07-10 16:33:31 +04:00
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
source "$(dirname "$0")/lib/ulib/auto" || exit 1
function display_help() {
uecho "$scriptname: frontend de diff pour comparer deux fichiers encodés en latin1
USAGE
$scriptname [options] Lfile Rfile
OPTIONS
-u, -U, --unified N
-w, --ignore-all-space
-B, --ignore-blank-lines
options de diff qui sont reprises telles quelles"
}
diffopts=()
args=(
--help '$exit_with display_help'
-u '$diffopts+=(-u)'
-U:,--unified: '$diffopts+=(-U "$value_")'
-w,--ignore-all-space '$diffopts+=(-w)'
-B,--ignore-blank-lines '$diffopts+=(-B)'
)
parse_args "$@"; set -- "${args[@]}"
Lfile="$1"
Rfile="$2"
[ -n "$Lfile" -a -n "$Rfile" ] || die "vous devez spécifier les deux fichiers"
[ -d "$Lfile" -o -d "$Rfile" ] && die "il faut absolument comparer deux fichiers"
diff "${diffopts[@]}" <(iconv -f latin1 -t utf-8 "$Lfile") <(iconv -f latin1 -t utf-8 "$Rfile")