Skip to content

Commit

Permalink
[Utils] Install Script: WasmEdge#621 (comment)
Browse files Browse the repository at this point in the history
* Fixes `sourcing` not being appended to $HOME/.shellrc

Signed-off-by: Shreyas Atre <[email protected]>
  • Loading branch information
SAtacker authored and hydai committed Nov 11, 2021
1 parent 3b60feb commit 80f9ade
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions utils/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80f9ade

Please sign in to comment.