diff options
author | Aaron W. Swenson <titanofold@gentoo.org> | 2011-03-31 17:42:05 -0400 |
---|---|---|
committer | Aaron W. Swenson <titanofold@gentoo.org> | 2011-03-31 17:42:05 -0400 |
commit | 3649a7c33c1da8e0d70a4ad436472ad502e6be5f (patch) | |
tree | 688411806b4db6b2352a547d83bee8028774c000 | |
parent | Bit harder to trick get_slots(). (diff) | |
download | eselect-3649a7c33c1da8e0d70a4ad436472ad502e6be5f.tar.gz eselect-3649a7c33c1da8e0d70a4ad436472ad502e6be5f.tar.bz2 eselect-3649a7c33c1da8e0d70a4ad436472ad502e6be5f.zip |
Variable quoting for paths.
-rw-r--r-- | postgresql.eselect | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/postgresql.eselect b/postgresql.eselect index 7b7501b..36fedb8 100644 --- a/postgresql.eselect +++ b/postgresql.eselect @@ -15,8 +15,8 @@ E_PATH="${EROOT%/}/etc/eselect/postgresql" ENV_FILE="${EROOT%/}/etc/env.d/50postgresql" active_slot() { - if [[ -r ${E_PATH}/active && -n ${E_PATH}/active ]] ; then - echo $( <${E_PATH}/active ) + if [[ -r "${E_PATH}"/active && -n "${E_PATH}"/active ]] ; then + echo $( <"${E_PATH}"/active ) else echo "(none)" fi @@ -48,16 +48,16 @@ linker() { local suffix=$4 local link_source - for link_source in $(find ${source_dir} -maxdepth 1 ${pattern}) ; do + for link_source in $(find "${source_dir}" -maxdepth 1 ${pattern}) ; do local link_target="${target_dir%/}/$(basename ${link_source})${suffix}" # For good measure, remove target before creating the symlink - [[ -h ${link_target} ]] && rm -f ${link_target} - [[ -e ${link_target} ]] && \ + [[ -h "${link_target}" ]] && rm -f "${link_target}" + [[ -e "${link_target}" ]] && \ die -q "The target '${link_target}' still exists and could not be removed!" - ln -s ${link_source} ${link_target} || die -q "Unable to create link!" - echo ${link_target} >> ${E_PATH}/active.links${suffix} + ln -s "${link_source}" "${link_target}" || die -q "Unable to create link!" + echo "${link_target}" >> "${E_PATH}"/active.links${suffix} done } @@ -66,15 +66,15 @@ linker() { # - Full path to active links file (e.g. /etc/eselect/postgresql/active.links) unlinker() { local active_link_file=$1 - if [ -r ${active_link_file} ] ; then - local active_links=($(<${active_link_file})) + if [ -r "${active_link_file}" ] ; then + local active_links=($(<"${active_link_file}")) for (( i=0; $i < ${#active_links[@]}; i++ )) ; do - [ -h ${active_links[$i]} ] && rm -f ${active_links[$i]} - [ -e ${active_links[$i]} ] && \ + [ -h "${active_links[$i]}" ] && rm -f "${active_links[$i]}" + [ -e "${active_links[$i]}" ] && \ die -q "The target '${active_links[$i]}' still exists and could not be removed!" done - rm -f ${active_link_file} + rm -f "${active_link_file}" fi } @@ -101,8 +101,8 @@ do_list() { for slot in $(get_slots) ; do local postgres_ebuilds="" local src - for src in ${E_PATH}/slots/${slot}/{server,service,base,docs} ; do - [ -r ${src} ] && source ${src} + for src in "${E_PATH}"/slots/${slot}/{server,service,base,docs} ; do + [ -r "${src}" ] && source "${src}" done case "${slot}" in @@ -143,7 +143,7 @@ describe_set() { do_set() { local SLOT=$1 - if [ ! -d ${B_PATH}/$(lib_dir)/postgresql-${SLOT} ] ; then + if [ ! -d "${B_PATH}"/$(lib_dir)/postgresql-${SLOT} ] ; then die -q "Not a valid slot." fi @@ -157,41 +157,41 @@ do_set() { echo -ne "\tGenerating new links..." # Sources and targets for header files local sources=( - ${B_PATH}/include/postgresql-${SLOT} - ${B_PATH}/include/postgresql-${SLOT}/libpq-fe.h - ${B_PATH}/include/postgresql-${SLOT}/pg_config_manual.h - ${B_PATH}/include/postgresql-${SLOT}/libpq - ${B_PATH}/include/postgresql-${SLOT}/postgres_ext.h + "${B_PATH}"/include/postgresql-${SLOT} + "${B_PATH}"/include/postgresql-${SLOT}/libpq-fe.h + "${B_PATH}"/include/postgresql-${SLOT}/pg_config_manual.h + "${B_PATH}"/include/postgresql-${SLOT}/libpq + "${B_PATH}"/include/postgresql-${SLOT}/postgres_ext.h ) local targets=( - ${B_PATH}/include/postgresql - ${B_PATH}/include/libpq-fe.h - ${B_PATH}/include/pg_config_manual.h - ${B_PATH}/include/libpq - ${B_PATH}/include/postgres_ext.h + "${B_PATH}"/include/postgresql + "${B_PATH}"/include/libpq-fe.h + "${B_PATH}"/include/pg_config_manual.h + "${B_PATH}"/include/libpq + "${B_PATH}"/include/postgres_ext.h ) # The linker function cannot accomadate this special purpose. local i for (( i=0; $i < ${#sources[@]}; i++ )) ; do # Remove target before creating the symlink - rm -f ${targets[$i]} + [[ -h "${targets[$i]}" ]] && rm -f "${targets[$i]}" # Check if link_target still exists - [[ -e ${targets[$i]} ]] && \ + [[ -e "${targets[$i]}" ]] && \ die -q "The target '${targets[$i]}' exists and could not be removed!" - ln -s ${sources[$i]} ${targets[$i]} || die -q "Unable to create link!" - echo ${targets[$i]} >> ${E_PATH}/active.links + ln -s "${sources[$i]}" "${targets[$i]}" || die -q "Unable to create link!" + echo "${targets[$i]}" >> "${E_PATH}"/active.links done # Link modules to /usr/lib{,lib32,lib64}/ local x for x in $(list_libdirs) ; do - if [[ -d ${B_PATH}/${x}/postgresql-${SLOT}/${x} ]] ; then + if [[ -d "${B_PATH}/${x}/postgresql-${SLOT}/${x}" ]] ; then # 'linker' function doesn't work for linking directories. # Default lib path - ln -s ${B_PATH}/${x}/postgresql-${SLOT}/${x} ${B_PATH}/${x}/postgresql - echo ${B_PATH}/${x}/postgresql >> ${E_PATH}/active.links + ln -s "${B_PATH}/${x}/postgresql-${SLOT}/${x}" "${B_PATH}/${x}/postgresql" + echo "${B_PATH}/${x}/postgresql" >> "${E_PATH}"/active.links # Linker works for files linker "${B_PATH}/${x}/postgresql-${SLOT}/${x}" \ "-name lib*[a|dylib|so]" "${B_PATH}/${x}" @@ -203,10 +203,10 @@ do_set() { "-xtype f" "${B_PATH}/bin" # Default share path - ln -s ${B_PATH}/share/postgresql-${SLOT} ${B_PATH}/share/postgresql - echo ${B_PATH}/share/postgresql >> ${E_PATH}/active.links + ln -s "${B_PATH}/share/postgresql-${SLOT}" "${B_PATH}/share/postgresql" + echo "${B_PATH}/share/postgresql" >> "${E_PATH}/active.links" - echo ${SLOT} > ${E_PATH}/active + echo ${SLOT} > "${E_PATH}/active" echo "done." echo "Setting ${SLOT} as default was successful!" } @@ -220,8 +220,8 @@ do_unset() { local SLOT=$1 if [[ "${SLOT}" = "$(active_slot)" ]] ; then echo -n "Unsetting ${SLOT} as the default installation..." - unlinker ${E_PATH}/active.links - rm -f ${E_PATH}/active + unlinker "${E_PATH}/active.links" + rm -f "${E_PATH}/active" echo "done." else echo "Inactive slot selected. No work to do." @@ -248,11 +248,10 @@ describe_update() { do_update() { local slot=$(active_slot) # Check for files managed by postgresql.eselect before 1.0 - [[ -h /etc/eselect/postgresql/active ]] && \ - slot="$(basename $(canonicalise /etc/eselect/postgesql/active))" + [[ -h "${E_PATH}active" ]] && \ + slot="$(basename $(canonicalise ${E_PATH/active))" # Remove service file outright. - [[ -h /etc/eselect/postgresql/service ]] && \ - rm -f /etc/eselect/postgresql/service + [[ -h "${E_PATH}/service" ]] && rm -f "${E_PATH}/service" local slots=($(get_slots)) local index=${#slots[@]} @@ -266,11 +265,12 @@ do_update() { echo -n " $i" sleep 1 done - for sym_links in ${E_PATH}/active.links* ; do - unlinker ${sym_links} + local sym_links + for sym_links in "${E_PATH}"/active.links* ; do + unlinker "${sym_links}" done - rm -f ${E_PATH}/active - rm -f ${ENV_FILE} + rm -f "${E_PATH}/active" + rm -f "${ENV_FILE}" do_action env update &> /dev/null echo "Done!" return 0 @@ -287,8 +287,8 @@ do_update() { echo -en "\nCleaning out old links before refreshing..." local sym_links - for sym_links in ${E_PATH}/active.links?* ; do - unlinker ${sym_links} + for sym_links in "${E_PATH}"/active.links?* ; do + unlinker "${sym_links}" done echo "done." @@ -296,7 +296,7 @@ do_update() { local ldpath local x for x in $(list_libdirs) ; do - [[ -h ${B_PATH}/${x}/postgresql ]] && \ + [[ -h "${B_PATH}"/${x}/postgresql ]] && \ ldpath+="${B_PATH}/${x}/postgresql:" done ldpath="${ldpath%:}" @@ -317,9 +317,9 @@ do_update() { done # Remove environment files that have been generated by the ebuilds - rm -f ${ENV_FILE}-* + rm -f "${ENV_FILE}"-* - store_config ${ENV_FILE} LDPATH "${ldpath}" - store_config ${ENV_FILE} MANPATH "${manpath}" + store_config "${ENV_FILE}" LDPATH "${ldpath}" + store_config "${ENV_FILE}" MANPATH "${manpath}" do_action env update &> /dev/null } |