|
|
@@ -0,0 +1,65 @@
|
|
|
+#!/usr/bin/env bash
|
|
|
+# compare_wsl.sh
|
|
|
+# Usage: ./compare_wsl.sh /path/to/file1 /path/to/file2
|
|
|
+
|
|
|
+set -euo pipefail
|
|
|
+
|
|
|
+if [[ $# -ne 2 ]]; then
|
|
|
+ echo "Usage: $0 <linux_path_to_file1> <linux_path_to_file2>"
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+# Input (Linux) paths
|
|
|
+F1_LINUX="$1"
|
|
|
+F2_LINUX="$2"
|
|
|
+
|
|
|
+# Basic checks
|
|
|
+if [[ ! -e "$F1_LINUX" ]]; then
|
|
|
+ echo "Error: '$F1_LINUX' does not exist." >&2
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+if [[ ! -e "$F2_LINUX" ]]; then
|
|
|
+ echo "Error: '$F2_LINUX' does not exist." >&2
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+if ! command -v wslpath >/dev/null 2>&1; then
|
|
|
+ echo "Error: wslpath not found." >&2
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+# Resolve to absolute Linux paths (helps if you pass relative paths)
|
|
|
+# 'readlink -f' is available on most WSL distros; if not, remove these two lines.
|
|
|
+F1_LINUX="$(readlink -f "$F1_LINUX")"
|
|
|
+F2_LINUX="$(readlink -f "$F2_LINUX")"
|
|
|
+
|
|
|
+# === Prepare required variables ===
|
|
|
+# Filenames only
|
|
|
+F1_NAME="$(basename "$F1_LINUX")"
|
|
|
+F2_NAME="$(basename "$F2_LINUX")"
|
|
|
+
|
|
|
+# Windows-mapped absolute paths
|
|
|
+F1_PATH="$(wslpath -w "$F1_LINUX")"
|
|
|
+F2_PATH="$(wslpath -w "$F2_LINUX")"
|
|
|
+
|
|
|
+# (Optional) show what we computed
|
|
|
+#echo "F1_PATH=$F1_PATH"
|
|
|
+#echo "F1_NAME=$F1_NAME"
|
|
|
+#echo "F2_PATH=$F2_PATH"
|
|
|
+#echo "F2_NAME=$F2_NAME"
|
|
|
+
|
|
|
+# === Example: launch ExamDiff via Windows PowerShell ===
|
|
|
+# Adjust ExamDiff path if your version/path differs.
|
|
|
+POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
|
|
|
+EXAMDIFF="C:\\Program Files\\ExamDiff Pro 16.0\\ExamDiff.exe"
|
|
|
+
|
|
|
+# Use Start-Process with an explicit -ArgumentList.
|
|
|
+# We wrap the entire PowerShell command in double quotes so Bash expands our vars,
|
|
|
+# and we escape the inner double quotes so PowerShell receives proper strings.
|
|
|
+"$POWERSHELL" -NoProfile -Command \
|
|
|
+"Start-Process -FilePath '$EXAMDIFF' -ArgumentList \
|
|
|
+\"$F1_PATH\",\"$F2_PATH\",\"/dn1:$F1_NAME\",\"/dn2:$F2_NAME\",\"/nh\""
|
|
|
+
|
|
|
+# If you prefer to block until ExamDiff exits, add: -Wait
|
|
|
+# ...like:
|
|
|
+# \"$F1_PATH\",\"$F2_PATH\",\"/dn1:$F1_NAME\",\"/dn2:$F2_NAME\",\"/nh\" -Wait
|
|
|
+
|