blob: 37a04633d0bb7b16d13bc1a8f786421738649948 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/bash
if [[ ! -e '{{executable}}' ]]; then
echo >&2 'Not modifying {{target}} because {{executable}} is not installed.'
exit 0
fi
if [[ ! -L '{{target}}' ]]; then
echo >&2 'Not modifying {{target}} because it is not a symlink.'
exit 0
fi
# shellcheck disable=SC2193 # these are just template placeholders
if [[ '{{executable}}' == *'/{{pkgname}}/'* ]]; then
# Move original executable back into place
mv -fv '{{executable}}' '{{target}}'
rmdir -pv --ignore-fail-on-non-empty "$(dirname '{{executable}}')"
else
# Modify symlink so it points to the original executable
echo >&2 'Restoring original {{target}}'
ln -fnsv '{{executable}}' '{{target}}'
fi
|