dotconf/private_dot_config/private_mgmt/fns/install_bin.bash
2026-03-25 10:50:18 -05:00

17 lines
449 B
Bash

# shellcheck shell=bash
install_bin() {
name="$1"
file="$2"
source="$3"
flag="$4"
if file "$file" | grep -Eqv 'ELF|executable'; then
diag "$(red "error: file from $source not an executable")"
exit 1
fi
if [ "$flag" != "--no-backup" ] && [ -f "/usr/local/bin/$name" ]; then
sudo cp "/usr/local/bin/$name" "/usr/local/bin/$name.old"
fi
sudo install -m 755 "$file" "/usr/local/bin/$name"
}