Permalink
Browse files

Fix some bugs

  • Loading branch information...
cslux committed May 20, 2016
1 parent 6197e1d commit b45f7efd70afe24e5af4231a9ba0bf3b935dbef1
Showing with 43 additions and 18 deletions.
  1. +7 −8 CMakeLists.txt
  2. +1 −1 LICENSE.txt
  3. +35 −9 src/rtags-bash-completion.bash
View
@@ -28,13 +28,12 @@ endif()
configure_file("${CMAKE_MODULE_PATH}/Uninstall.cmake.in" "${CMAKE_BINARY_DIR}/Uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/Uninstall.cmake")
-include(PkgInfo)
-set(CPACK_PACKAGE_CONTACT "${PKG_USERNAME}")
-#set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
-#set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
-set(CPACK_PACKAGE_VERSION "${VERSION}")
-
-include(CPack)
-cpack_add_component(rtags)
+if (RTAGS_ENABLE_DEV_OPTIONS)
+ include(PkgInfo)
+ set(CPACK_PACKAGE_CONTACT "${PKG_USERNAME}")
+ set(CPACK_PACKAGE_VERSION "${VERSION}")
+ include(CPack)
+ cpack_add_component(rtags)
+endif ()
feature_summary(INCLUDE_QUIET_PACKAGES WHAT ALL)
View
@@ -1,4 +1,4 @@
-Copyright (C) 2011, 2012, 2013 Jan Erik Hanssen and Anders Bakken
+Copyright (C) 2011-2016 Jan Erik Hanssen and Anders Bakken
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1,22 +1,48 @@
_rtags ()
{
- local prev value_opts non_value_opts app cur
+ # Those local variables are needed by _init_completion.
+ local cur prev words cword
+ _init_completion || return
+ local app=${words[0]}
- app=${COMP_WORDS[0]}
- value_opts=$($app --help | grep '^ \+-' | grep "\[[A-Za-z]*\]" | sed -e 's,\([^ ]\) .*,\1,' -e 's,|, ,')
- prev=${COMP_WORDS[COMP_CWORD-1]}
+ if [[ $app == \~* ]]; then
+ # Tell shellcheck we know that single quotes prevent expansion.
+ # shellcheck disable=SC2016
+ eval app="${app%%/*}"/'${app#*/}'
+ fi
+
+ # In case app starts with a dollar sign, like $HOME/...
+ if [[ $app == \$* ]]; then
+ # shellcheck disable=SC2016
+ eval app="${app%%/*}"/'${app#*/}'
+ fi
+
+ # Always use absolute path to executable so we can verify it later.
+ if [[ $app != /* ]]; then
+ app=$(which $app)
+ fi
+
+ # If value of app doesn't point to an executable after possible expansion
+ # return immediately.
+ test -x $app || return
+
+ local -r value_opts=$($app --help | grep '^ \+-' | grep "\[[A-Za-z]*\]" | \
+ sed -e 's,\([^ ]\) .*,\1,' -e 's,|, ,')
- if [ -n "$prev" ] && [ ${COMP_CWORD} -gt 1 ] && printf -- "${value_opts}\n" | grep --quiet -- "$prev"; then
+ if [ -n "$prev" ] && [ $cword -gt 1 ] \
+ && printf -- "${value_opts}\n" | grep --quiet -- "$prev"; then
COMPREPLY=()
- return;
+ return
fi
- cur=${COMP_WORDS[COMP_CWORD]}
- non_value_opts=$($app --help | grep '^ \+-' | grep -v "\[[A-Za-z]*\]" | sed -e 's,\([^ ]\) .*,\1,' -e 's,|, ,')
+ local -r non_value_opts=$($app --help | grep '^ \+-' | \
+ grep -v "\[[A-Za-z]*\]" | \
+ sed -e 's,\([^ ]\) .*,\1,' -e 's,|, ,')
COMPREPLY=($(compgen -W "$value_opts $non_value_opts" -- $cur))
- if [ -n "$cur" ] && [ ${#COMPREPLY[@]} -eq 0 ] && printf -- "$cur\n" | grep --quiet -- "^-[^-]"; then
+ if [ -n "$cur" ] && [ ${#COMPREPLY[@]} -eq 0 ] \
+ && printf -- "$cur\n" | grep --quiet -- "^-[^-]"; then
COMPREPLY=($(compgen -W "$value_opts $non_value_opts" -- -$cur))
fi
}

0 comments on commit b45f7ef

Please sign in to comment.