OSDN Git Service

The detection method of pkgng is modified.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 9 Dec 2012 18:10:20 +0000 (03:10 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 9 Dec 2012 18:10:20 +0000 (03:10 +0900)
Function ports_glob is fixed.
Variables invoked by echo command are escaped by "" in needed places.

modified:   portsreinstall
modified:   portsreinstall.8
modified:   portsreinstall.8~
modified:   portsreinstall~

portsreinstall
portsreinstall.8
portsreinstall.8~
portsreinstall~

index 042a14f..b67f648 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename "$0"`
-MYVERSION=2.0.0+toward_2.0.1_20121209185741
+MYVERSION=2.0.0+toward_2.0.1_20121210030952
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -403,9 +403,8 @@ then
        echo "port, and then restart this utility by 'redo' command."
        echo
        echo " The current package system is automatically detected; the new generation"
-       echo "package (pkgng) is used if it is installed and 'WITH_PKGNG=yes' is set and"
-       echo "'WITHOUT_PKGNG=yes' is not set /etc/make.conf, and otherwise the conventional"
-       echo "package is used."
+       echo "package (pkgng) is used if 'WITH_PKGNG=yes' is set and 'WITHOUT_PKGNG=yes' isf"
+       echo "not set /etc/make.conf, and otherwise the conventional package is used."
        echo
        echo " If you are familiar to the mechanism of Ports Collections system, in order to"
        echo "minimize package conflictions, it may be a good idea to delete packages which "
@@ -436,62 +435,50 @@ PORTSDIR=${PORTSDIR:-/usr/ports}
 PORTS_MOVED_DB=${PORTSDIR}/MOVED
 PORTS_INDEX_DB=${PORTSDIR}/INDEX-`uname -r | cut -d . -f 1`
 
-if which -s pkg
-then
-       WITH_PKGNG=`make -f /etc/make.conf -V WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
-       WITHOUT_PKGNG=`make -f /etc/make.conf -V WITHOUT_PKGNG | tr '[:upper:]' '[:lower:]'`
-else
-       unset WITH_PKGNG
-       WITHOUT_PKGNG=yes
-fi
+WITH_PKGNG=`make -C "${PORTSDIR}" -V WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
 
-if [ "x$WITH_PKGNG" = xyes -a "x$WITHOUT_PKGNG" = xyes ]
-then
-       echo "ERROR: /etc/make.conf defines contradictory settings for WITH_PKGNG and WITHOUT_PKGNG" >&2
-       exit 1
-fi
 if [ "x$WITH_PKGNG" = xyes ]
 then
-       unset WITHOUT_PKGNG
+       which -s pkg || { echo "ERROR: WITH_PKGNG is set, but pkgng is not available" >&2; exit 1; }
        command_pkg_info='pkg info'
        command_pkg_create='pkg create'
        command_pkg_delete='pkg delete'
        command_pkg_add='pkg add'
        pkg_info_qoa ()
        {
-               pkg info -qoa
+               pkg info -qoa 2> /dev/null
        }
        pkg_info_qox ()
        {
-               pkg info -qox "$@"
+               pkg info -qox "$@" 2> /dev/null
        }
        pkg_info_qoX ()
        {
-               pkg info -qoX "$@"
+               pkg info -qoX "$@" 2> /dev/null
        }
        pkg_info_qO ()
        {
-               pkg info -qO "$@"
+               pkg info -qO "$@" 2> /dev/null
        }
        pkg_info_qo ()
        {
-               pkg info -qo "$@"
+               pkg info -qo "$@" 2> /dev/null
        }
        pkg_info_qr ()
        {
-               pkg info -qd "$@"
+               pkg info -qd "$@" 2> /dev/null
        }
        pkg_info_e ()
        {
-               pkg info -e "$@"
+               pkg info -e "$@" 2> /dev/null
        }
        pkg_info_qR ()
        {
-               pkg info -qr "$@"
+               pkg info -qr "$@" 2> /dev/null
        }
        pkg_info_Ex ()
        {
-               pkg info -Ex "$@"
+               pkg info -Ex "$@" 2> /dev/null
        }
        pkg_create_b ()
        {
@@ -509,8 +496,7 @@ then
        {
                env ASSUME_ALWAYS_YES=YES pkg add "$@"
        }
-elif  [ "x$WITHOUT_PKGNG" = xyes ]
-then
+else
        unset WITH_PKGNG
        command_pkg_info='pkg_info'
        command_pkg_create='pkg_create'
@@ -518,39 +504,39 @@ then
        command_pkg_add='pkg_add'
        pkg_info_qoa ()
        {
-               pkg_info -qoa
+               pkg_info -qoa 2> /dev/null
        }
        pkg_info_qox ()
        {
-               pkg_info -qox "$@"
+               pkg_info -qox "$@" 2> /dev/null
        }
        pkg_info_qoX ()
        {
-               pkg_info -qoX "$@"
+               pkg_info -qoX "$@" 2> /dev/null
        }
        pkg_info_qO ()
        {
-               pkg_info -qO "$@"
+               pkg_info -qO "$@" 2> /dev/null
        }
        pkg_info_qo ()
        {
-               pkg_info -qo "$@"
+               pkg_info -qo "$@" 2> /dev/null
        }
        pkg_info_qr ()
        {
-               pkg_info -qr "$@" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//'
+               pkg_info -qr "$@" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//' 2> /dev/null
        }
        pkg_info_e ()
        {
-               pkg_info -e "$@"
+               pkg_info -e "$@" 2> /dev/null
        }
        pkg_info_qR ()
        {
-               pkg_info -qR "$@" | grep -v '^$'
+               pkg_info -qR "$@" | grep -v '^$' 2> /dev/null
        }
        pkg_info_Ex ()
        {
-               pkg_info -Ex "$@"
+               pkg_info -Ex "$@" 2> /dev/null
        }
        pkg_create_b ()
        {
@@ -586,11 +572,11 @@ convert_portsglob_to_regexp_pattern ()
        glob_pattern=$1
        if expr "$glob_pattern" : '^:' > /dev/null 2>&1
        then
-               regexp_pattern=`echo $glob_pattern | sed 's/^://'`
+               regexp_pattern=`echo "$glob_pattern" | sed 's/^://'`
        else
-               regexp_pattern=`echo $glob_pattern | convert_glob_to_regexp_pattern`
+               regexp_pattern=`echo "$glob_pattern" | convert_glob_to_regexp_pattern`
        fi
-       echo $regexp_pattern
+       echo "$regexp_pattern"
 }
 
 if which -s ports_glob
@@ -600,27 +586,30 @@ else
        ports_glob ()
        {
                local glob index
-               glob=`convert_portsglob_to_regexp_pattern "$1"`
                [ -f "${DBDIR}/ports_glob:pkg.lst" ] || cut -d \| -f 1 "${PORTS_INDEX_DB}" > ${DBDIR}/ports_glob:pkg.lst
                [ -f "${DBDIR}/ports_glob:origin.lst" ] || cut -d \| -f 2 "${PORTS_INDEX_DB}" | sed -E "s/^`str_escape_regexp "${PORTSDIR}"`\///" > ${DBDIR}/ports_glob:origin.lst
-               if expr "$glob" : '[^\/][^\/]*\/[^\/][^\/]*$' 2> /dev/null > /dev/null
-               then
-                       grep -E "$glob" "${DBDIR}/ports_glob:origin.lst" > ${TMPDIR}/ports_glob:matched
-                       pkg_info_qoa | grep -E "$glob" >> ${TMPDIR}/ports_glob:matched
-               else
-                       grep -n -E "$glob" "${DBDIR}/ports_glob:pkg.lst" | cut -d : -f 1 | while read index
-                       do
-                               sed -n ${index}p "${DBDIR}/ports_glob:origin.lst"
-                       done > ${TMPDIR}/ports_glob:matched
-                       pkg_info_qox "$glob" >> ${TMPDIR}/ports_glob:matched
-               fi
-               sort -u "${TMPDIR}"/ports_glob:matched
+               while [ $# -gt 0 ]
+               do
+                       glob=`convert_portsglob_to_regexp_pattern "$1"`
+                       if expr "$glob" : '[^/][^/]*\/[^/][^/]*$' 2> /dev/null > /dev/null
+                       then
+                               grep -E "$glob" "${DBDIR}/ports_glob:origin.lst" || :
+                               pkg_info_qoa | grep -E "$glob" || :
+                       else
+                               grep -n -E "$glob" "${DBDIR}/ports_glob:pkg.lst" | cut -d : -f 1 | while read index
+                               do
+                                       sed -n ${index}p "${DBDIR}/ports_glob:origin.lst"
+                               done || :
+                               pkg_info_qox "$glob" || :
+                       fi
+                       shift
+               done | sort -u
        }
 fi
 
 str_escape_regexp ()
 {
-       echo $* | str_escape_regexp_filter
+       echo "$*" | str_escape_regexp_filter
 }
 
 rm_a_line ()
@@ -628,7 +617,7 @@ rm_a_line ()
        local item dstpath pattern
        item=$1
        dstpath=$2
-       pattern=`str_escape_regexp $item`
+       pattern=`str_escape_regexp "$item"`
        grep -v -E "^$pattern$" "$dstpath" 2> /dev/null > ${TMPDIR}/rm_a_line || :
        mv "${TMPDIR}/rm_a_line" "$dstpath"
 }
@@ -638,8 +627,8 @@ add_a_line_if_new ()
        local item dstpath pattern
        item=$1
        dstpath=$2
-       pattern=`str_escape_regexp $item`
-       grep -m 1 -E "^$pattern$" "$dstpath" 2> /dev/null > /dev/null || echo $item >> $dstpath
+       pattern=`str_escape_regexp "$item"`
+       grep -m 1 -E "^$pattern$" "$dstpath" 2> /dev/null > /dev/null || echo "$item" >> $dstpath
 }
 
 record_success ()
@@ -716,9 +705,9 @@ register_globs ()
        echo "`echo "$globlist1" | sed 's/,/ /g'`" "$globlist2" | sed -E 's/ +/\
 /g' | grep -v '^$' | while read glob
        do
-               if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
+               if expr "@$glob" : '^@[^/][^/]*\/[^/][^/]*$' > /dev/null 2> /dev/null
                then
-                       [ ! -d "${PORTSDIR}/$glob" ] || { echo $glob; continue; }
+                       [ ! -d "${PORTSDIR}/$glob" ] || { echo "$glob"; continue; }
                fi
                ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
                origin=`ports_glob "$glob"`
@@ -754,7 +743,7 @@ expand_glob_pattern_to_origins ()
                then
                        if [ "x$include_nonexistent" = xyes ]
                        then
-                               echo $glob_pattern
+                               echo "$glob_pattern"
                        else
                                pkg_info_qO "$glob_pattern" | xargs pkg_info_qo
                        fi
@@ -806,7 +795,7 @@ build_conflist_target_val_pair ()
                        do
                                path=${DBDIR}/requires_conflist/$origin
                                [ -d "$path" ] || mkdir -p "$path"
-                               echo $val > $path/${section}.conflist
+                               echo "$val" > $path/${section}.conflist
                        done
                done
                touch "${DBDIR}/COMPLETE_REFLECTCONF_${section}"
@@ -823,7 +812,7 @@ add_to_obsolete_if_not_yet ()
                [ -d "${DBDIR}/obsolete/$origin" ] || mkdir -p "${DBDIR}/obsolete/$origin"
                pkgtag=`pkg_info_qO "$origin"`
                [ -n "$pkgtag" ] || pkgtag='[not installed]'
-               echo $pkgtag > ${DBDIR}/obsolete/$origin/pkgtag
+               echo "$pkgtag" > ${DBDIR}/obsolete/$origin/pkgtag
        fi
 }
 
@@ -1025,7 +1014,7 @@ warn_update_ports ()
 
 linear_list ()
 {
-       echo $* | sed -E 's/^ +//; s/ +$//; s/ +/, /; s/, ([^ ]+)$/ and \1/'
+       echo "$*" | sed -E 's/^ +//; s/ +$//; s/ +/, /; s/, ([^ ]+)$/ and \1/'
 }
 
 chk_privilege ()
@@ -1271,11 +1260,11 @@ ok)
        case $opr in
        add)
                register_globs '' "$*" "${DBDIR}/manually_done.list"
-               echo "`linear_list $*` is/are registered to the list of manually resolved ports"
+               echo "`linear_list \"$*\"` is/are registered to the list of manually resolved ports"
                ;;
        del)
                register_globs '' "$*" "${DBDIR}/manually_done.list" remove
-               echo "`linear_list $*` is/are deregistered from the list of manually resolved ports"
+               echo "`linear_list \"$*\"` is/are deregistered from the list of manually resolved ports"
                ;;
        esac
        echo "Now the following ports have been manually resolved:"
@@ -1290,11 +1279,11 @@ taboo)
        case $opr in
        add)
                register_globs '' "$*" "${DBDIR}/taboo.list"
-               echo "`linear_list $*` is/are registered to the list of ports to be ignored."
+               echo "`linear_list \"$*\"` is/are registered to the list of ports to be ignored."
                ;;
        del)
                register_globs '' "$*" "${DBDIR}/taboo.list" remove
-               echo "`linear_list $*` is/are deregistered from the list of ports to be ignored."
+               echo "`linear_list \"$*\"` is/are deregistered from the list of ports to be ignored."
                ;;
        esac
        combine_lists TABOO_PORTS.conflist taboo.list taboo.all.list
index ae46ecc..3fe8056 100644 (file)
@@ -250,7 +250,7 @@ where \fIglob\fR is the ports glob of the concerned port, and then restart this
 .B portsreinstall redo
 command.
 .PP
-The current package system is automatically detected; the new generation package (pkgng) is used if it is installed and 'WITH_PKGNG=yes' is set and "WITHOUT_PKGNG=yes" is not set /etc/make.conf, and otherwise the conventional package is used.
+The current package system is automatically detected; the new generation package (pkgng) is used if "WITH_PKGNG=yes" is set and "WITHOUT_PKGNG=yes" is not set /etc/make.conf, and otherwise the conventional package is used.
 .PP
 If you are familiar to the mechanism of Ports Collections system, in order to minimize package conflictions, it may be a good idea to delete packages which you don't think necessary before starting to use this utility.
 Don't be afraid to delete necessary dependencies because all required ports are automatically installed.
@@ -283,7 +283,7 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-2.0.1 (09 December 2012)
+2.0.1 (10 December 2012)
 [NEW] New generation package (pkgng) is supported.
 
 [IMPROVED] A countermeasure for a build failure in a restarted build from a terminated build is implemented.
@@ -293,6 +293,8 @@ Configuration file of portupgrade(1).
 [BUG FIX] The transferring mechanism of option values to restarted run was broken.
 
 [BUG FIX] Error end in case that no packages are installed is fixed.
+
+[BUG FIX] A glob evaluation routine used when ports_glob(1) is not installed was broken.
 .TP
 2.0.0 (12 August 2012)
 [NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
index 8ad997a..24e3b33 100644 (file)
@@ -283,7 +283,7 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-2.0.1 (09 December 2012)
+2.0.1 (10 December 2012)
 [NEW] New generation package (pkgng) is supported.
 
 [IMPROVED] A countermeasure for a build failure in a restarted build from a terminated build is implemented.
@@ -291,6 +291,10 @@ Configuration file of portupgrade(1).
 [BUG FIX] Restoration of backup packages after failed installation was not working correctly.
 
 [BUG FIX] The transferring mechanism of option values to restarted run was broken.
+
+[BUG FIX] Error end in case that no packages are installed is fixed.
+
+[BUG FIX] A glob evaluation routine used when ports_glob(1) is not installed was broken.
 .TP
 2.0.0 (12 August 2012)
 [NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
index 5d9ad26..8a76385 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename "$0"`
-MYVERSION=2.0.0+toward_2.0.1_20121209183341
+MYVERSION=2.0.0+toward_2.0.1_20121210001550
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -403,9 +403,8 @@ then
        echo "port, and then restart this utility by 'redo' command."
        echo
        echo " The current package system is automatically detected; the new generation"
-       echo "package (pkgng) is used if it is installed and 'WITH_PKGNG=yes' is set and"
-       echo "'WITHOUT_PKGNG=yes' is not set /etc/make.conf, and otherwise the conventional"
-       echo "package is used."
+       echo "package (pkgng) is used if 'WITH_PKGNG=yes' is set and 'WITHOUT_PKGNG=yes' isf"
+       echo "not set /etc/make.conf, and otherwise the conventional package is used."
        echo
        echo " If you are familiar to the mechanism of Ports Collections system, in order to"
        echo "minimize package conflictions, it may be a good idea to delete packages which "
@@ -436,62 +435,50 @@ PORTSDIR=${PORTSDIR:-/usr/ports}
 PORTS_MOVED_DB=${PORTSDIR}/MOVED
 PORTS_INDEX_DB=${PORTSDIR}/INDEX-`uname -r | cut -d . -f 1`
 
-if which -s pkg
-then
-       WITH_PKGNG=`make -f /etc/make.conf -V WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
-       WITHOUT_PKGNG=`make -f /etc/make.conf -V WITHOUT_PKGNG | tr '[:upper:]' '[:lower:]'`
-else
-       unset WITH_PKGNG
-       WITHOUT_PKGNG=yes
-fi
+WITH_PKGNG=`make -C "${PORTSDIR}" -V WITH_PKGNG | tr '[:upper:]' '[:lower:]'`
 
-if [ "x$WITH_PKGNG" = xyes -a "x$WITHOUT_PKGNG" = xyes ]
-then
-       echo "ERROR: /etc/make.conf defines contradictory settings for WITH_PKGNG and WITHOUT_PKGNG" >&2
-       exit 1
-fi
 if [ "x$WITH_PKGNG" = xyes ]
 then
-       unset WITHOUT_PKGNG
+       which -s pkg || { echo "ERROR: WITH_PKGNG is set, but pkgng is not available" >&2; exit 1; }
        command_pkg_info='pkg info'
        command_pkg_create='pkg create'
        command_pkg_delete='pkg delete'
        command_pkg_add='pkg add'
        pkg_info_qoa ()
        {
-               pkg info -qoa
+               pkg info -qoa 2> /dev/null
        }
        pkg_info_qox ()
        {
-               pkg info -qox "$@"
+               pkg info -qox "$@" 2> /dev/null
        }
        pkg_info_qoX ()
        {
-               pkg info -qoX "$@"
+               pkg info -qoX "$@" 2> /dev/null
        }
        pkg_info_qO ()
        {
-               pkg info -qO "$@"
+               pkg info -qO "$@" 2> /dev/null
        }
        pkg_info_qo ()
        {
-               pkg info -qo "$@"
+               pkg info -qo "$@" 2> /dev/null
        }
        pkg_info_qr ()
        {
-               pkg info -qd "$@"
+               pkg info -qd "$@" 2> /dev/null
        }
        pkg_info_e ()
        {
-               pkg info -e "$@"
+               pkg info -e "$@" 2> /dev/null
        }
        pkg_info_qR ()
        {
-               pkg info -qr "$@"
+               pkg info -qr "$@" 2> /dev/null
        }
        pkg_info_Ex ()
        {
-               pkg info -Ex "$@"
+               pkg info -Ex "$@" 2> /dev/null
        }
        pkg_create_b ()
        {
@@ -509,8 +496,7 @@ then
        {
                env ASSUME_ALWAYS_YES=YES pkg add "$@"
        }
-elif  [ "x$WITHOUT_PKGNG" = xyes ]
-then
+else
        unset WITH_PKGNG
        command_pkg_info='pkg_info'
        command_pkg_create='pkg_create'
@@ -518,39 +504,39 @@ then
        command_pkg_add='pkg_add'
        pkg_info_qoa ()
        {
-               pkg_info -qoa
+               pkg_info -qoa 2> /dev/null
        }
        pkg_info_qox ()
        {
-               pkg_info -qox "$@"
+               pkg_info -qox "$@" 2> /dev/null
        }
        pkg_info_qoX ()
        {
-               pkg_info -qoX "$@"
+               pkg_info -qoX "$@" 2> /dev/null
        }
        pkg_info_qO ()
        {
-               pkg_info -qO "$@"
+               pkg_info -qO "$@" 2> /dev/null
        }
        pkg_info_qo ()
        {
-               pkg_info -qo "$@"
+               pkg_info -qo "$@" 2> /dev/null
        }
        pkg_info_qr ()
        {
-               pkg_info -qr "$@" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//'
+               pkg_info -qr "$@" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//' 2> /dev/null
        }
        pkg_info_e ()
        {
-               pkg_info -e "$@"
+               pkg_info -e "$@" 2> /dev/null
        }
        pkg_info_qR ()
        {
-               pkg_info -qR "$@" | grep -v '^$'
+               pkg_info -qR "$@" | grep -v '^$' 2> /dev/null
        }
        pkg_info_Ex ()
        {
-               pkg_info -Ex "$@"
+               pkg_info -Ex "$@" 2> /dev/null
        }
        pkg_create_b ()
        {
@@ -586,11 +572,11 @@ convert_portsglob_to_regexp_pattern ()
        glob_pattern=$1
        if expr "$glob_pattern" : '^:' > /dev/null 2>&1
        then
-               regexp_pattern=`echo $glob_pattern | sed 's/^://'`
+               regexp_pattern=`echo "$glob_pattern" | sed 's/^://'`
        else
-               regexp_pattern=`echo $glob_pattern | convert_glob_to_regexp_pattern`
+               regexp_pattern=`echo "$glob_pattern" | convert_glob_to_regexp_pattern`
        fi
-       echo $regexp_pattern
+       echo "$regexp_pattern"
 }
 
 if which -s ports_glob
@@ -600,27 +586,30 @@ else
        ports_glob ()
        {
                local glob index
-               glob=`convert_portsglob_to_regexp_pattern "$1"`
                [ -f "${DBDIR}/ports_glob:pkg.lst" ] || cut -d \| -f 1 "${PORTS_INDEX_DB}" > ${DBDIR}/ports_glob:pkg.lst
                [ -f "${DBDIR}/ports_glob:origin.lst" ] || cut -d \| -f 2 "${PORTS_INDEX_DB}" | sed -E "s/^`str_escape_regexp "${PORTSDIR}"`\///" > ${DBDIR}/ports_glob:origin.lst
-               if expr "$glob" : '[^\/][^\/]*\/[^\/][^\/]*$' 2> /dev/null > /dev/null
-               then
-                       grep -E "$glob" "${DBDIR}/ports_glob:origin.lst" > ${TMPDIR}/ports_glob:matched
-                       pkg_info_qoa | grep -E "$glob" >> ${TMPDIR}/ports_glob:matched
-               else
-                       grep -n -E "$glob" "${DBDIR}/ports_glob:pkg.lst" | cut -d : -f 1 | while read index
-                       do
-                               sed -n ${index}p "${DBDIR}/ports_glob:origin.lst"
-                       done > ${TMPDIR}/ports_glob:matched
-                       pkg_info_qox "$glob" >> ${TMPDIR}/ports_glob:matched
-               fi
-               sort -u "${TMPDIR}"/ports_glob:matched
+               while [ $# -gt 0 ]
+               do
+                       glob=`convert_portsglob_to_regexp_pattern "$1"`
+                       if expr "$glob" : '[^/][^/]*\/[^/][^/]*$' 2> /dev/null > /dev/null
+                       then
+                               grep -E "$glob" "${DBDIR}/ports_glob:origin.lst" || :
+                               pkg_info_qoa | grep -E "$glob" || :
+                       else
+                               grep -n -E "$glob" "${DBDIR}/ports_glob:pkg.lst" | cut -d : -f 1 | while read index
+                               do
+                                       sed -n ${index}p "${DBDIR}/ports_glob:origin.lst"
+                               done || :
+                               pkg_info_qox "$glob" || :
+                       fi
+                       shift
+               done | sort -u
        }
 fi
 
 str_escape_regexp ()
 {
-       echo $* | str_escape_regexp_filter
+       echo "$*" | str_escape_regexp_filter
 }
 
 rm_a_line ()
@@ -628,7 +617,7 @@ rm_a_line ()
        local item dstpath pattern
        item=$1
        dstpath=$2
-       pattern=`str_escape_regexp $item`
+       pattern=`str_escape_regexp "$item"`
        grep -v -E "^$pattern$" "$dstpath" 2> /dev/null > ${TMPDIR}/rm_a_line || :
        mv "${TMPDIR}/rm_a_line" "$dstpath"
 }
@@ -638,8 +627,8 @@ add_a_line_if_new ()
        local item dstpath pattern
        item=$1
        dstpath=$2
-       pattern=`str_escape_regexp $item`
-       grep -m 1 -E "^$pattern$" "$dstpath" 2> /dev/null > /dev/null || echo $item >> $dstpath
+       pattern=`str_escape_regexp "$item"`
+       grep -m 1 -E "^$pattern$" "$dstpath" 2> /dev/null > /dev/null || echo "$item" >> $dstpath
 }
 
 record_success ()
@@ -716,9 +705,9 @@ register_globs ()
        echo "`echo "$globlist1" | sed 's/,/ /g'`" "$globlist2" | sed -E 's/ +/\
 /g' | grep -v '^$' | while read glob
        do
-               if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
+               if expr "@$glob" : '^@[^/][^/]*\/[^/][^/]*$' > /dev/null 2> /dev/null
                then
-                       [ ! -d "${PORTSDIR}/$glob" ] || { echo $glob; continue; }
+                       [ ! -d "${PORTSDIR}/$glob" ] || { echo "$glob"; continue; }
                fi
                ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
                origin=`ports_glob "$glob"`
@@ -754,7 +743,7 @@ expand_glob_pattern_to_origins ()
                then
                        if [ "x$include_nonexistent" = xyes ]
                        then
-                               echo $glob_pattern
+                               echo "$glob_pattern"
                        else
                                pkg_info_qO "$glob_pattern" | xargs pkg_info_qo
                        fi
@@ -806,7 +795,7 @@ build_conflist_target_val_pair ()
                        do
                                path=${DBDIR}/requires_conflist/$origin
                                [ -d "$path" ] || mkdir -p "$path"
-                               echo $val > $path/${section}.conflist
+                               echo "$val" > $path/${section}.conflist
                        done
                done
                touch "${DBDIR}/COMPLETE_REFLECTCONF_${section}"
@@ -823,7 +812,7 @@ add_to_obsolete_if_not_yet ()
                [ -d "${DBDIR}/obsolete/$origin" ] || mkdir -p "${DBDIR}/obsolete/$origin"
                pkgtag=`pkg_info_qO "$origin"`
                [ -n "$pkgtag" ] || pkgtag='[not installed]'
-               echo $pkgtag > ${DBDIR}/obsolete/$origin/pkgtag
+               echo "$pkgtag" > ${DBDIR}/obsolete/$origin/pkgtag
        fi
 }
 
@@ -1025,7 +1014,7 @@ warn_update_ports ()
 
 linear_list ()
 {
-       echo $* | sed -E 's/^ +//; s/ +$//; s/ +/, /; s/, ([^ ]+)$/ and \1/'
+       echo "$*" | sed -E 's/^ +//; s/ +$//; s/ +/, /; s/, ([^ ]+)$/ and \1/'
 }
 
 chk_privilege ()
@@ -1271,11 +1260,11 @@ ok)
        case $opr in
        add)
                register_globs '' "$*" "${DBDIR}/manually_done.list"
-               echo "`linear_list $*` is/are registered to the list of manually resolved ports"
+               echo "`linear_list \"$*\"` is/are registered to the list of manually resolved ports"
                ;;
        del)
                register_globs '' "$*" "${DBDIR}/manually_done.list" remove
-               echo "`linear_list $*` is/are deregistered from the list of manually resolved ports"
+               echo "`linear_list \"$*\"` is/are deregistered from the list of manually resolved ports"
                ;;
        esac
        echo "Now the following ports have been manually resolved:"
@@ -1290,11 +1279,11 @@ taboo)
        case $opr in
        add)
                register_globs '' "$*" "${DBDIR}/taboo.list"
-               echo "`linear_list $*` is/are registered to the list of ports to be ignored."
+               echo "`linear_list \"$*\"` is/are registered to the list of ports to be ignored."
                ;;
        del)
                register_globs '' "$*" "${DBDIR}/taboo.list" remove
-               echo "`linear_list $*` is/are deregistered from the list of ports to be ignored."
+               echo "`linear_list \"$*\"` is/are deregistered from the list of ports to be ignored."
                ;;
        esac
        combine_lists TABOO_PORTS.conflist taboo.list taboo.all.list