From a7975ec2ddef8a394095d2e0f3268c3d08a9361c Mon Sep 17 00:00:00 2001 From: TpaeFawzen <30316430+GH-TpaeFawzen@users.noreply.github.com> Date: Sun, 6 Dec 2020 22:50:41 +0900 Subject: [PATCH] bootstrap.sh: tried to make it portable. --- bootstrap.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 5894c6c22f2..3fc64e2e6c2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,27 +1,30 @@ -#!/usr/bin/env bash +#!/bin/sh +set -eu # for safety + cd "$(dirname "${BASH_SOURCE}")"; git pull origin main; -function doIt() { +doIt() { rsync --exclude ".git/" \ --exclude ".DS_Store" \ --exclude ".osx" \ --exclude "bootstrap.sh" \ --exclude "README.md" \ --exclude "LICENSE-MIT.txt" \ - -avh --no-perms . ~; - source ~/.bash_profile; + -avh --no-perms . "$HOME"; + . "$HOME"/.bash_profile; } -if [ "$1" == "--force" -o "$1" == "-f" ]; then +case "$1" in ("--force"|"-f") doIt; -else - read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1; +;;(*) + echo "This may overwrite existing files in your home directory. Are you sure? (y/n) " 2>&1; + REPLY=$(stty raw; dd bs=1 count=1 2>/dev/null; stty -raw) echo ""; - if [[ $REPLY =~ ^[Yy]$ ]]; then + case $REPLY in ([Yy]) doIt; - fi; -fi; -unset doIt; + esac; +esac; +unset -f doIt;