From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Si7h6-0003Ii-2U for garchives@archives.gentoo.org; Fri, 22 Jun 2012 17:30:52 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 79314E077F; Fri, 22 Jun 2012 17:29:24 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 381E5E077F for ; Fri, 22 Jun 2012 17:29:24 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7521C1B401D for ; Fri, 22 Jun 2012 17:29:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 37D25E543D for ; Fri, 22 Jun 2012 17:29:21 +0000 (UTC) From: "Ulrich Mueller" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Mueller" Message-ID: <1180432925.0431fb90618d96dadbe153a3a51841149f23218b.ulm@gentoo> Subject: [gentoo-commits] proj/emacs-tools:eselect-emacs-1.1 commit in: / X-VCS-Repository: proj/emacs-tools X-VCS-Files: emacs.eselect X-VCS-Directories: / X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Mueller X-VCS-Revision: 0431fb90618d96dadbe153a3a51841149f23218b X-VCS-Branch: eselect-emacs-1.1 Date: Fri, 22 Jun 2012 17:29:21 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 2bf69b00-a49f-41be-8410-170ab2773c45 X-Archives-Hash: 27154b0db362de10460693b729403bc0 commit: 0431fb90618d96dadbe153a3a51841149f23218b Author: Christian Faulhammer gentoo org> AuthorDate: Tue May 29 10:02:05 2007 +0000 Commit: Ulrich Mueller gentoo org> CommitDate: Tue May 29 10:02:05 2007 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/emacs-tools.g= it;a=3Dcommit;h=3D0431fb90 * Took a check for modification right from do_update() to own function and use them in do_set(), too * Made a ndash out of a divis * Added quotes around use of ROOT variable in remove_infopath(), set_man_symlinks(), set_infopath(), find_targets(), do_list() * Commented functions remove_infopath() * Moved the comment for find_targets(), set_infopath(), remove_symlinks(), set_bin_symlinks(), set_man_symlinks(),set_symlinks() * Brief overview of functions completed in the header of the module * Change wording: implementation -> version svn path=3D/emacs-extra/eselect-emacs/; revision=3D344 --- emacs.eselect | 46 ++++++++++++++++++++++++++-------------------- 1 files changed, 26 insertions(+), 20 deletions(-) diff --git a/emacs.eselect b/emacs.eselect index 7adf8ff..f884daf 100644 --- a/emacs.eselect +++ b/emacs.eselect @@ -8,7 +8,7 @@ # * show do_show() # * list do_list() # * set do_set() -# * update do_update() +# * update do_update() # # Behaviour: # do_show(): @@ -16,11 +16,11 @@ # if yes, it outputs the currently linked Emacs version. # If it is no symlink, the user is told so, the same if there is # no /usr/bin/emacs or the target does not exist. -# do_list(): -# do_set(): -# do_update(): +# do_list(): List all available versions of GNU Emacs +# do_set(): Set a version to be target of the symlink. +# do_update(): Check if the target is still valid and reset it =20 -DESCRIPTION=3D"Manage /usr/bin/emacs implementations" +DESCRIPTION=3D"Manage /usr/bin/emacs version" MAINTAINER=3D"emacs@gentoo.org" SVN_DATE=3D'$Date$' VERSION=3D$(svn_date_to_version "${SVN_DATE}" ) @@ -28,26 +28,27 @@ VERSION=3D$(svn_date_to_version "${SVN_DATE}" ) BINARYLIST=3D"emacsclient etags ctags b2m ebrowse rcs-checkin grep-chang= elog" MANPAGELIST=3D"emacs emacsclient etags ctags gfdl" =20 -# Return the list of available Emacs binaries find_targets() { + # Return the list of available Emacs binaries local j - for j in ${ROOT}/usr/bin/emacs-[0-9]*; do + for j in "${ROOT}"/usr/bin/emacs-[0-9]*; do [[ -f ${j} ]] && basename ${j} done } =20 remove_infopath() { - rm -f ${ROOT}/etc/env.d/50emacs + # When cleaning symlinks this takes care of the info documentation sett= ings + rm -f "${ROOT}/etc/env.d/50emacs" } =20 # Define INFOPATH environment variable in env file set_infopath() { - [[ -d ${ROOT}/usr/share/info/${1} ]] || return 1 - echo "INFOPATH=3D/usr/share/info/${1}" >${ROOT}/etc/env.d/50emacs + [[ -d "${ROOT}"/usr/share/info/${1} ]] || return 1 + echo "INFOPATH=3D/usr/share/info/${1}" > "${ROOT}/etc/env.d/50emacs" } =20 -# Remove existing symlinks to binaries, man pages, and the env file remove_symlinks() { + # Remove existing symlinks to binaries, man pages, and the env file (ow= n function) local f rm -f "${ROOT}"/usr/bin/emacs for f in ${BINARYLIST}; do @@ -59,8 +60,8 @@ remove_symlinks() { remove_infopath } =20 -# Set symlinks to binaries in /usr/bin set_bin_symlinks() { + # Set symlinks to binaries in /usr/bin/ local target=3D${1} f for f in ${BINARYLIST}; do # set symlink only if target binary actually exists @@ -71,11 +72,11 @@ set_bin_symlinks() { done } =20 -# Set symlinks to man pages set_man_symlinks() { + # Set symlinks to man pages local target=3D${1} extension f i for f in ${MANPAGELIST}; do - for i in ${ROOT}/usr/share/man/man1/${f}-${target}.1*; do + for i in "${ROOT}"/usr/share/man/man1/${f}-${target}.1*; do if [[ -f ${i} ]]; then # target file exists; determine compress extension extension=3D${i##*/${f}-${target}.1} @@ -86,8 +87,8 @@ set_man_symlinks() { done } =20 -# Set symlinks to binaries and man pages, update info path set_symlinks() { + # Set symlinks to binaries and man pages, update info path local target=3D"${1}" targets # target may be specified by its name or its index if is_number "${target}"; then @@ -130,6 +131,11 @@ xemacs_info() { fi } =20 +test_for_root() { + # checks if the user has rights to modify /usr/bin/ + [[ -w "${ROOT}/usr/bin" ]] || die -q "You need to be root!" +} + ### show action ### =20 describe_show() { @@ -168,7 +174,7 @@ do_list() { if [[ -n ${targets[@]} ]]; then for (( i =3D 0; i < ${#targets[@]}; i =3D i + 1 )); do [[ ${targets[${i}]} =3D \ - $(basename $(canonicalise ${ROOT}/usr/bin/emacs) ) ]] && + $(basename $(canonicalise "${ROOT}/usr/bin/emacs") ) ]] && # Display a star to indicate the currently chosen version targets[${i}]=3D"${targets[${i}]} $(highlight '*')" done @@ -197,7 +203,7 @@ describe_set_parameters() { do_set() { [[ -z "${1}" ]] && die -q "You didn't tell me what to set the symlink t= o" [[ -n "${2}" ]] && die -q "Too many parameters" - [[ -w "${ROOT}/usr/bin" ]] || die -q "You need to be root!" + test_for_root =20 if [[ -L "${ROOT}/usr/bin/emacs" ]]; then remove_symlinks || die -q "Couldn't remove existing symlink" @@ -215,13 +221,13 @@ describe_update() { } =20 describe_update_options() { - echo "--if-unset : Do not override existing implementation" + echo "--if-unset : Do not override currently set version" } =20 do_update() { [[ -z "${1}" || ( -z "${2}" && "${1}" =3D=3D "--if-unset" ) ]] || die -q "Usage error" - [[ -w "${ROOT}/usr/bin" ]] || die -q "You need to be root!" + test_for_root =20 if [[ -L "${ROOT}/usr/bin/emacs" ]]; then [[ ${1} =3D=3D "--if-unset" \ @@ -235,7 +241,7 @@ do_update() { if [[ ${#targets[@]} -gt 0 ]]; then set_symlinks ${#targets[@]} || die -q "Couldn't set a new symlink" elif [[ -f "${ROOT}/usr/bin/xemacs" ]]; then - # no Emacs target found - link ctags, etags etc. to XEmacs versions + # no Emacs target found -- link ctags, etags etc. to XEmacs versions set_symlinks xemacs fi }