Skip to content

Commit 27a0720

Browse files
committed
Avoid an extra case/esac: use a flag instead.
Also factor out common commands to outside of test.
1 parent 29e205f commit 27a0720

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/tools/rust-installer/install-template.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,15 @@ install_components() {
551551
# Decide the destination of the file
552552
local _file_install_path="$_dest_prefix/$_file"
553553

554+
local _is_bin=false
554555
case "$_file" in
555556
etc/*)
556557
local _f="$(echo "$_file" | sed 's/^etc\///')"
557558
_file_install_path="$CFG_SYSCONFDIR/$_f"
558559
;;
559560
bin/*)
560561
local _f="$(echo "$_file" | sed 's/^bin\///')"
562+
_is_bin=true
561563
_file_install_path="$CFG_BINDIR/$_f"
562564
;;
563565
lib/*)
@@ -608,20 +610,11 @@ install_components() {
608610

609611
maybe_backup_path "$_file_install_path"
610612

611-
if test -x "$_src_dir/$_component/$_file"; then
612-
run cp "$_src_dir/$_component/$_file" "$_file_install_path"
613+
run cp "$_src_dir/$_component/$_file" "$_file_install_path"
614+
if $_is_bin || test -x "$_src_dir/$_component/$_file"; then
613615
run chmod 755 "$_file_install_path"
614616
else
615-
case "$_file" in
616-
bin/*)
617-
run cp "$_src_dir/$_component/$_file" "$_file_install_path"
618-
run chmod 755 "$_file_install_path"
619-
;;
620-
*)
621-
run cp "$_src_dir/$_component/$_file" "$_file_install_path"
622-
run chmod 644 "$_file_install_path"
623-
;;
624-
esac
617+
run chmod 644 "$_file_install_path"
625618
fi
626619
critical_need_ok "file creation failed"
627620

0 commit comments

Comments
 (0)