-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathediff.sh
More file actions
executable file
·70 lines (51 loc) · 1.69 KB
/
Copy pathediff.sh
File metadata and controls
executable file
·70 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# This script uses call-emacs-function.sh in order to run Ediff on a pair of files.
#
# It needs a routine like the following in your Emacs configuration:
#
# (defun my-ediff-files-from-outside (filename-a filename-b)
# "" ; No docstring yet.
# (ediff-files filename-a filename-b))
#
# You could call ediff-files directly, but I needed to customize the code in my Emacs configuration.
#
# Copyright (c) 2026 R. Diez - Licensed under the GNU AGPLv3
set -o errexit
set -o nounset
set -o pipefail
declare -r SCRIPT_NAME="${BASH_SOURCE[0]##*/}" # This script's filename only, without any path components.
# Script version 1.00
declare -r -i BOOLEAN_TRUE=0
declare -r -i BOOLEAN_FALSE=1
declare -r -i EXIT_CODE_ERROR=1
abort ()
{
echo >&2 && echo "Error in script \"$SCRIPT_NAME\": $*" >&2
exit $EXIT_CODE_ERROR
}
is_tool_installed ()
{
if command -v "$1" >/dev/null 2>&1 ;
then
return $BOOLEAN_TRUE
else
return $BOOLEAN_FALSE
fi
}
# ------ Entry Point (only by convention) ------
if (( $# != 2 )); then
abort "Invalid command-line arguments. Please specify both filenames to compare."
fi
declare -r CALL_EMACS_FUNCTION_FILENAME="call-emacs-function.sh"
if ! is_tool_installed "$CALL_EMACS_FUNCTION_FILENAME"; then
abort "Helper script \"$CALL_EMACS_FUNCTION_FILENAME\" not found."
fi
declare -r FILENAME_1="$1"
declare -r FILENAME_2="$2"
if ! [ -f "$FILENAME_1" ]; then
abort "File \"$FILENAME_1\" does not exist or is not a regular file."
fi
if ! [ -f "$FILENAME_2" ]; then
abort "File \"$FILENAME_2\" does not exist or is not a regular file."
fi
exec "$CALL_EMACS_FUNCTION_FILENAME" --suppress-output -- "my-ediff-files-from-outside" "$FILENAME_1" "$FILENAME_2"