Skip to content

Commit 399432a

Browse files
committed
pre-launch error checking
1 parent 7d4a8d7 commit 399432a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
## Unreleased
44

55
1. Replaced status messages with nicer, easier-to-read messages in color.
6+
7+
2. Added error checking for presence of wimlib tools and ESD image before starting.

windows-esd-to-iso

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ _twrap() {
2424
_qtput sgr0
2525
}
2626
bold() { _twrap "$1" bold; }
27+
red() { _twrap "$1" setaf 1; }
2728
green() { _twrap "$1" setaf 2; }
2829
blue() { _twrap "$1" setaf 4; }
2930

@@ -33,7 +34,28 @@ print_subtask() { echo "$(blue "==>") $(bold "$@")"; }
3334
set -e
3435
setup_color
3536

36-
esd="${1}"
37+
if [ -z "$1" ] || [ "$1" = "-h" ]; then
38+
echo "$(red "Usage:") $(basename "$0") ESD"
39+
exit 0
40+
fi
41+
42+
check_tool() {
43+
if ! which "$1" >/dev/null; then
44+
echo "$(red "Error:") wimlib tools not found"
45+
exit 1
46+
fi
47+
}
48+
check_tool wiminfo
49+
check_tool wimapply
50+
check_tool wimexport
51+
52+
esd="$1"
53+
54+
if [ ! -f "${esd}" ]; then
55+
echo "$(red "Error:") ${esd} not found"
56+
exit 2
57+
fi
58+
3759
tmpdir=$(mktemp -d)
3860

3961
__cleanup() {

0 commit comments

Comments
 (0)