Skip to content

Commit 85bc77a

Browse files
committed
enh: check bash-completion before install
Signed-off-by: wxiwnd <wxiwnd@outlook.com>
1 parent 6ab7816 commit 85bc77a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

scripts/install_completion.sh

100644100755
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
set -e
33

44
cargo build --release
5-
echo "Install binary..."
5+
6+
# Check bash-completion
7+
if [ ! -d /etc/bash_completion.d ]; then
8+
echo "Directory /etc/bash_completion.d does not exist. Please install bash-completion first."
9+
exit 1
10+
fi
11+
12+
# Install or upgrade the binary
13+
if [ -f /usr/bin/bash-pinyin-completion-rs ]; then
14+
echo "The binary /usr/bin/bash-pinyin-completion-rs already exists. Upgrading..."
15+
else
16+
echo "Installing binary..."
17+
fi
618
sudo cp target/release/bash-pinyin-completion-rs /usr/bin/
7-
echo "Install bash-completion script..."
19+
20+
# Install or upgrade the script
21+
if [ -f /etc/bash_completion.d/bash_pinyin_completion ]; then
22+
echo "The bash-completion script /etc/bash_completion.d/bash_pinyin_completion already exists. Upgrading..."
23+
else
24+
echo "Installing bash-completion script..."
25+
fi
826
sudo cp scripts/bash_pinyin_completion /etc/bash_completion.d/

0 commit comments

Comments
 (0)