self-update inplace
This commit is contained in:
parent
e2f85dc17e
commit
fafb9bbf9d
26
ghcup
26
ghcup
@ -105,7 +105,11 @@ KNOWN_GOOD_CABAL="2.2.0.0"
|
|||||||
# How many jobs to use for compiling GHC.
|
# How many jobs to use for compiling GHC.
|
||||||
JOBS="1"
|
JOBS="1"
|
||||||
|
|
||||||
|
# @VARIABLE: SOURCE
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# The $0 argument, which contains
|
||||||
|
# the script name.
|
||||||
|
SOURCE="$0"
|
||||||
|
|
||||||
####################
|
####################
|
||||||
#--[ Print Help ]--#
|
#--[ Print Help ]--#
|
||||||
@ -682,6 +686,24 @@ set_ghc() {
|
|||||||
#--[ Subcommand self-update ]--#
|
#--[ Subcommand self-update ]--#
|
||||||
################################
|
################################
|
||||||
|
|
||||||
|
# @FUNCTION: script_dir
|
||||||
|
# @DESCRIPTION:
|
||||||
|
# Portably gets the full directory of where
|
||||||
|
# this script resides in and prints it to stdout.
|
||||||
|
# @STDOUT: script directory
|
||||||
|
script_dir() {
|
||||||
|
mysource=${SOURCE}
|
||||||
|
|
||||||
|
while [ -h "${mysource}" ]; do
|
||||||
|
mydir="$( cd -P "$( dirname "${mysource}" )" > /dev/null && pwd )"
|
||||||
|
mysource="$(readlink "${mysource}")"
|
||||||
|
[ "${mysource%${mysource#?}}"x != '/x' ] && mysource="${mydir}/${mysource}"
|
||||||
|
done
|
||||||
|
mydir="$( cd -P "$( dirname "${mysource}" )" > /dev/null && pwd )"
|
||||||
|
echo "${mydir}"
|
||||||
|
|
||||||
|
unset mysource mydir
|
||||||
|
}
|
||||||
|
|
||||||
# @FUNCTION: self_update
|
# @FUNCTION: self_update
|
||||||
# @USAGE: <install-location>
|
# @USAGE: <install-location>
|
||||||
@ -994,7 +1016,7 @@ while [ $# -gt 0 ] ; do
|
|||||||
if [ "${TARGET_LOCATION}" ] ; then
|
if [ "${TARGET_LOCATION}" ] ; then
|
||||||
self_update "${TARGET_LOCATION}"
|
self_update "${TARGET_LOCATION}"
|
||||||
else
|
else
|
||||||
self_update "${HOME}/.local/bin"
|
self_update "$(script_dir)"
|
||||||
fi
|
fi
|
||||||
break;;
|
break;;
|
||||||
show)
|
show)
|
||||||
|
Loading…
Reference in New Issue
Block a user