From 032b95aa9bf9df0813fa20010076beb27ad136bd Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 8 Apr 2019 23:32:04 +0800 Subject: [PATCH] Remove show command, which is obsolete now --- .travis.sh | 2 - ghcup | 129 +++++++++++++---------------------------------------- 2 files changed, 31 insertions(+), 100 deletions(-) diff --git a/.travis.sh b/.travis.sh index 959f434..37ea58f 100755 --- a/.travis.sh +++ b/.travis.sh @@ -59,8 +59,6 @@ edo mv shellcheck-latest/shellcheck "$HOME"/.local/bin/shellcheck # check our script for errors edo shellcheck ghcup -edo ghcup -v show - edo ghcup -v debug-info edo ghcup -v list diff --git a/ghcup b/ghcup index 9617078..fbf11be 100755 --- a/ghcup +++ b/ghcup @@ -185,7 +185,6 @@ FLAGS: SUBCOMMANDS: install Install GHC$(${VERBOSE} && printf "\n compile Compile and install GHC from source (UNSTABLE!!!)") - show Show current/installed GHC set Set currently active GHC version list Show available GHCs and other tools upgrade Upgrade this script in-place @@ -277,24 +276,6 @@ ARGS: exit 1 } -# @FUNCTION: show_usage -# @DESCRIPTION: -# Print the help message for 'ghcup show' to STDERR -# and exit the script with status code 1. -show_usage() { - (>&2 echo "ghcup-show -Show the installed/current GHC versions - -USAGE: - ${SCRIPT} show [FLAGS] - -FLAGS: - -h, --help Prints help information - -i, --installed Show installed GHC version only -") - exit 1 -} - # @FUNCTION: rm_usage # @DESCRIPTION: # Print the help message for 'ghcup rm' to STDERR @@ -1249,6 +1230,37 @@ array_contains() { return 1 } +# @FUNCTION: show_ghc_installed +# @DESCRIPTION: +# Prints the currently selected GHC only as version string. +# @STDOUT: current GHC version +show_ghc_installed() { + current_ghc="${BIN_LOCATION}/ghc" + real_ghc=$(posix_realpath "${current_ghc}") + + if [ -L "${current_ghc}" ] ; then # is symlink + if [ -e "${real_ghc}" ] ; then # exists (posix_realpath was called) + real_ghc="$(basename "${real_ghc}" | sed 's#ghc-##')" + printf "%s" "${real_ghc}" + else # is a broken symlink + red_message "broken symlink" + fi + fi + + unset real_ghc current_ghc +} + +# @FUNCTION: show_cabal_installed +# @DESCRIPTION: +# Prints the currently selected cabal only as version string. +# @STDOUT: current cabal version +show_cabal_installed() { + if [ -x "${BIN_LOCATION}/cabal" ] ; then + "${BIN_LOCATION}/cabal" --numeric-version + fi +} + + ############################ @@ -1415,68 +1427,6 @@ upgrade() { - ######################### - #--[ Subcommand show ]--# - ######################### - - -# @FUNCTION: show_ghc -# @DESCRIPTION: -# Prints the currently installed and selected GHC, in human-friendly -# format. -show_ghc() { - current_ghc=$(show_ghc_installed) - - echo "Installed GHCs:" - for i in "${GHC_LOCATION}"/* ; do - if [ -e "${i}" ] ; then - echo " $(basename "${i}")" - else # directory is empty - echo " None" - exit 0 - fi - done - - if [ -n "${current_ghc}" ] ; then - echo - echo "Current GHC" - echo " ${current_ghc}" - fi - - unset current_ghc i -} - -# @FUNCTION: show_ghc_installed -# @DESCRIPTION: -# Prints the currently selected GHC only as version string. -# @STDOUT: current GHC version -show_ghc_installed() { - current_ghc="${BIN_LOCATION}/ghc" - real_ghc=$(posix_realpath "${current_ghc}") - - if [ -L "${current_ghc}" ] ; then # is symlink - if [ -e "${real_ghc}" ] ; then # exists (posix_realpath was called) - real_ghc="$(basename "${real_ghc}" | sed 's#ghc-##')" - printf "%s" "${real_ghc}" - else # is a broken symlink - red_message "broken symlink" - fi - fi - - unset real_ghc current_ghc -} - -# @FUNCTION: show_cabal_installed -# @DESCRIPTION: -# Prints the currently selected cabal only as version string. -# @STDOUT: current cabal version -show_cabal_installed() { - if [ -x "${BIN_LOCATION}/cabal" ] ; then - "${BIN_LOCATION}/cabal" --numeric-version - fi -} - - ####################### #--[ Subcommand rm ]--# @@ -2004,23 +1954,6 @@ while [ $# -gt 0 ] ; do upgrade "$(dirname "$(posix_realpath "${SOURCE}")")" fi break;; - show) - SHOW_INSTALLED=false - shift 1 - while [ $# -gt 0 ] ; do - case $1 in - -h|--help) show_usage;; - -i|--installed) SHOW_INSTALLED=true - break;; - *) show_usage;; - esac - done - if ${SHOW_INSTALLED} ; then - show_ghc_installed - else - show_ghc - fi - break;; rm) shift 1 while [ $# -gt 0 ] ; do