Ticket #14452: select.sh.diff

File select.sh.diff, 2.0 KB (added by ebgssth@…, 16 years ago)
  • select.sh

     
    1 #!/bin/bash
     1#!/bin/bash -e
    22#
    33# $Id: portdestroot.tcl 27199 2007-07-24 09:09:43Z mww@macports.org $
    44#
     
    5353
    5454# print the usage of this tool
    5555usage() {
    56         echo "usage: ${TOOL} [-n] [-f] [-r] [-h] [-v] version"
    57         echo ""
    58         echo "-n        Show commands to do selection but do not execute them."
    59         echo "-f        Ensure the links are correct for the specified version"
    60         echo "          even if it maches the current default version."
    61         echo "-h        Display this help info."
    62         echo "-r        Skip test for necessary rights."
    63         echo "-v        Display version of ${0}."
    64         echo "-l        List available options for version."
    65         echo "-i path   Install mode to perform an initial selection in path."
    66         echo ""
     56        cat <<EOD
     57usage: ${TOOL} [-n] [-f] [-r] [-h] [-v] version
     58
     59-n        Show commands to do selection but do not execute them.
     60-f        Ensure the links are correct for the specified version
     61          even if it maches the current default version.
     62-h        Display this help info.
     63-r        Skip test for necessary rights.
     64-v        Display version of ${TOOL}.
     65-l        List available options for version.
     66-i path   Install mode to perform an initial selection in path.
     67
     68EOD
    6769}
    6870
    6971# print the version of this tool
     
    8082# test if a particular version is available
    8183version_is_valid() {
    8284        for version in $(ls -1 ${CONFPATH} | grep -v base); do
    83                 if [ ${1} == ${version} ]; then
     85                if [ "${1}" == "${version}" ]; then
    8486                        return 0
    8587                fi
    8688        done
     
    8991
    9092# perform an action (command) or just display it
    9193action() {
    92         if [ "rm" == ${1} ]; then
    93                 if [ 1 == ${noexec} ]; then
     94        if [ "rm" == "${1}" ]; then
     95                if [ 1 == "${noexec}" ]; then
    9496                        echo "rm -f ${2}"
    9597                else
    9698                        rm -f ${2}
    9799                fi
    98         elif [ "ln" == ${1} ]; then
    99                 if [ 1 == ${noexec} ]; then
     100        elif [ "ln" == "${1}" ]; then
     101                if [ 1 == "${noexec}" ]; then
    100102                        echo "ln -sf ${2} ${3}"
    101103                else
    102104                        ln -sf ${2} ${3}