From 80f9adedd028a27a2e472e8533320e6b4a617b51 Mon Sep 17 00:00:00 2001 From: Shreyas Atre Date: Mon, 8 Nov 2021 12:58:04 +0530 Subject: [PATCH] [Utils] Install Script: https://github.com/WasmEdge/WasmEdge/issues/621#issue-1046674611 * Fixes `sourcing` not being appended to $HOME/.shellrc Signed-off-by: Shreyas Atre --- utils/install.sh | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/utils/install.sh b/utils/install.sh index 2dd3fb2f2034..f65eb530db81 100755 --- a/utils/install.sh +++ b/utils/install.sh @@ -574,45 +574,46 @@ main() { echo "$ENV" >"$IPATH/env" echo "# Please do not edit comments below this for uninstallation purpose" >>"$IPATH/env" - if [ ! $default == 1 ]; then - echo "${YELLOW}No path provided" - echo "Installing in $IPATH${NC}" - local _source=". \"$IPATH/env\"" - local _grep=$(cat "$__HOME__/.profile" 2>/dev/null | grep "$IPATH/env") - if [ -f "$__HOME__/.profile" ]; then - if [ "$_grep" = "" ]; then - echo "$_source" >>"$__HOME__/.profile" - fi - else - echo "Generating $__HOME__/.profile" + local _source=". \"$IPATH/env\"" + local _grep=$(cat "$__HOME__/.profile" 2>/dev/null | grep "$IPATH/env") + if [ -f "$__HOME__/.profile" ]; then + if [ "$_grep" = "" ]; then echo "$_source" >>"$__HOME__/.profile" fi + else + echo "Generating $__HOME__/.profile" + echo "$_source" >>"$__HOME__/.profile" + fi - local _shell_ _shell_rc - _shell_="${SHELL#${SHELL%/*}/}" - _shell_rc=".""$_shell_""rc" + local _shell_ _shell_rc + _shell_="${SHELL#${SHELL%/*}/}" + _shell_rc=".""$_shell_""rc" - if [[ "$_shell_" =~ "zsh" ]]; then - local _grep=$(cat "$__HOME__/.zprofile" 2>/dev/null | grep "$IPATH/env") - if [ "$_grep" = "" ]; then - echo "$_source" >>"$__HOME__/.zprofile" - fi - elif [[ "$_shell_" =~ "bash" ]]; then - local _grep=$(cat "$__HOME__/.bash_profile" 2>/dev/null | grep "$IPATH/env") - if [ "$_grep" = "" ]; then - echo "$_source" >>"$__HOME__/.bash_profile" - fi + if [[ "$_shell_" =~ "zsh" ]]; then + local _grep=$(cat "$__HOME__/.zprofile" 2>/dev/null | grep "$IPATH/env") + if [ "$_grep" = "" ]; then + echo "$_source" >>"$__HOME__/.zprofile" + fi + elif [[ "$_shell_" =~ "bash" ]]; then + local _grep=$(cat "$__HOME__/.bash_profile" 2>/dev/null | grep "$IPATH/env") + if [ "$_grep" = "" ]; then + echo "$_source" >>"$__HOME__/.bash_profile" fi + fi - if [ -f "$__HOME__/$_shell_rc" ]; then - local _grep=$(cat "$__HOME__/$_shell_rc" | grep "$IPATH/env") - if [ "$_grep" = "" ]; then - echo "$_source" >>"$__HOME__/$_shell_rc" - fi - else - echo "Generating $__HOME__/$_shell_rc" + if [ -f "$__HOME__/$_shell_rc" ]; then + local _grep=$(cat "$__HOME__/$_shell_rc" | grep "$IPATH/env") + if [ "$_grep" = "" ]; then echo "$_source" >>"$__HOME__/$_shell_rc" fi + else + echo "Generating $__HOME__/$_shell_rc" + echo "$_source" >>"$__HOME__/$_shell_rc" + fi + + if [ ! $default == 1 ]; then + echo "${YELLOW}No path provided" + echo "Installing in $IPATH${NC}" fi if [ ! $VERBOSE == 0 ]; then