1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-01-08 12:28:00 -05:00

* Updated bash_completion script to 3.0 options.

* Changed that removal message again, hopefully it sounds good now.
* Shortened a usage option description so it would not wrap at 81 chars.
This commit is contained in:
Dan McGee 2007-02-19 04:13:13 +00:00
parent d86bea5c8d
commit bd6adec40b
3 changed files with 104 additions and 89 deletions

View File

@ -1,25 +1,25 @@
# vim: set ft=sh: # vim: set ft=sh ts=2 sw=2 et:
# file: /etc/bash_completion.d/pacman # file: /etc/bash_completion.d/pacman
# Bash completion for ArchLinux # Bash completion for pacman
# Original: v.1.1 Manolis Tzanidakis <mtzanidakis@freemail.gr> # Original: Manolis Tzanidakis <mtzanidakis@freemail.gr>
# #
# Distributed under the terms of the GNU General Public License, v2 or later. # Distributed under the terms of the GNU General Public License, v2 or later.
# #
## Changelog #################################################### ## ChangeLog ##
# # #
# * 1.1 (20040117) # # * 3.0 (2007-02-18)
# - Code cleanup # # - Updated to pacman 3.0.0 options
# - Updated to pacman 2.7.2-2 # # * 1.1 (2004-01-17)
# * 20040216 (orelien) # # - Code cleanup
# - Improved available_{pkgs,groups) functions # # - Updated to pacman 2.7.2-2
# - Added support for querying groups # # * 2004-02-16 (orelien)
# # # - Improved available_{pkgs,groups) functions
################################################################# # - Added support for querying groups
#
## initial functions ## initial functions
#
rem_selected () rem_selected ()
{ {
@ -36,7 +36,7 @@ rem_selected ()
# remove word from list of completions # remove word from list of completions
COMPREPLY=(${COMPREPLY/ ${i%% *} / }) COMPREPLY=(${COMPREPLY/ ${i%% *} / })
done done
echo ${COMPREPLY[@]}))) echo ${COMPREPLY[@]})))
return 0 return 0
} }
@ -83,14 +83,7 @@ _available_groups ()
COMPREPLY=( $( compgen -W "$( for i in $available_groups; do echo ${i%-*-*}; done )" -- $cur ) ) COMPREPLY=( $( compgen -W "$( for i in $available_groups; do echo ${i%-*-*}; done )" -- $cur ) )
} }
## init (/etc/rc.d) script completion (quick 'n' dirty ;-)
#
complete -W "start stop restart" \
$(for i in /etc/rc.d/*; do echo ${i##*/}; done)
## makepkg completion ## makepkg completion
#
_makepkg () _makepkg ()
{ {
@ -100,30 +93,38 @@ _makepkg ()
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in case "$prev" in
-@(p|w)) -p)
_filedir _filedir
return 0 return 0
;; ;;
--help|--cleancache|--genmd5) --help|--cleancache)
COMPREPLY='' COMPREPLY=''
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b --builddeps \ COMPREPLY=( $( compgen -W '\
-b --builddeps \
-B --noccache \
-c --clean \ -c --clean \
-C --cleancache \ -C --cleancache \
-d --nodeps \ -d --nodeps \
-e --noextract \
-f --force \ -f --force \
-g --genmd5 \ -g --geninteg \
-h --help \ -h --help \
-i --install \ -i --install \
-j \
-L --log \
-m --nocolor \ -m --nocolor \
-n --nostrip \ -o --nobuild \
-p \
-r --rmdeps \ -r --rmdeps \
-s --syncdeps \ -s --syncdeps \
-p -w' -- $cur ) ) -S --usesudo \
--noconfirm \
--noprogressbar' -- $cur ) )
fi fi
rem_selected rem_selected
@ -131,18 +132,17 @@ _makepkg ()
complete -o default -F _makepkg makepkg complete -o default -F _makepkg makepkg
## pacman completion ## pacman completion
#
_instring () _instring ()
{ {
str="${1}" str="${1}"
shift 1 shift 1
for c in "${@}"; do for c in "${@}"; do
if [ $(expr index "${str}" "${c}") -gt 0 ]; then if [ $(expr index "${str}" "${c}") -gt 0 ]; then
return 0 return 0
fi fi
done done
return 1 return 1
} }
_pacman () _pacman ()
@ -153,7 +153,7 @@ _pacman ()
# This argument parsing is done so we can check for flag existance later # This argument parsing is done so we can check for flag existance later
# right now it's a tad crappy, but does the job # right now it's a tad crappy, but does the job
for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do for (( i=1; i < ${#COMP_WORDS[@]}-1; i++ )); do
a=${COMP_WORDS[i]} a=${COMP_WORDS[i]}
arg="${a:0:2}" arg="${a:0:2}"
toparse="${a:2}" toparse="${a:2}"
@ -210,36 +210,39 @@ _pacman ()
cur=${COMP_WORDS[COMP_CWORD]} cur=${COMP_WORDS[COMP_CWORD]}
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '\ COMPREPLY=( $( compgen -W '\
-A --add \ -A --add \
-F --freshen \ -F --freshen \
-h --help \ -h --help \
-Q --query \ -Q --query \
-R --remove \ -R --remove \
-S --sync \ -S --sync \
-U --upgrade \ -U --upgrade \
-V --version \ -V --version \
' -- $cur ) ) ' -- $cur ) )
rem_selected rem_selected
return 0 return 0
fi fi
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
case "${op}" in case "${op}" in
A|U|F) A|U|F)
COMPREPLY=( $( compgen -W '\ COMPREPLY=( $( compgen -W '\
-d --nodeps \ -d --nodeps \
-f --force \ -f --force \
-h --help \ -h --help \
--config \ --config \
--noconfirm \ --noconfirm \
--noprogressbar \ --ask \
-v --verbose \ --noprogressbar \
-r --root \ --noscriptlet \
-b --dbpath \ -v --verbose \
' -- $cur ) ) -r --root \
-b --dbpath \
--cachedir \
' -- $cur ) )
return 0 return 0
;; ;;
R) R)
COMPREPLY=( $( compgen -W '\ COMPREPLY=( $( compgen -W '\
-c --cascade \ -c --cascade \
@ -249,19 +252,23 @@ _pacman ()
-k --dbonly \ -k --dbonly \
-n --nosave \ -n --nosave \
-s --recursive \ -s --recursive \
--config \ --config \
--noconfirm \ --noconfirm \
--noprogressbar \ --ask \
--noprogressbar \
--noscriptlet \
-v --verbose \ -v --verbose \
-r --root \ -r --root \
-b --dbpath \ -b --dbpath \
--cachedir \
' -- $cur ) ) ' -- $cur ) )
return 0 return 0
;; ;;
S) S)
COMPREPLY=( $( compgen -W '\ COMPREPLY=( $( compgen -W '\
-c --clean \ -c --clean \
-d --nodeps \ -d --nodeps \
-e --dependsonly \
-f --force \ -f --force \
-g --groups \ -g --groups \
-h --help \ -h --help \
@ -272,17 +279,22 @@ _pacman ()
-u --sysupgrade \ -u --sysupgrade \
-w --downloadonly \ -w --downloadonly \
-y --refresh \ -y --refresh \
--config \ --ignore \
--noconfirm \ --config \
--noprogressbar \ --noconfirm \
--ask \
--noprogressbar \
--noscriptlet \
-v --verbose \ -v --verbose \
-r --root \ -r --root \
-b --dbpath \ -b --dbpath \
--cachedir \
' -- $cur ) ) ' -- $cur ) )
return 0 return 0
;; ;;
Q) Q)
COMPREPLY=( $( compgen -W '\ COMPREPLY=( $( compgen -W '\
-c --changelog \
-e --orphans \ -e --orphans \
-g --groups \ -g --groups \
-h --help \ -h --help \
@ -292,54 +304,57 @@ _pacman ()
-o --owns \ -o --owns \
-p --file \ -p --file \
-s --search \ -s --search \
--config \ --config \
--noconfirm \ --noconfirm \
--noprogressbar \ --ask \
--noprogressbar \
--noscriptlet \
-v --verbose \ -v --verbose \
-r --root \ -r --root \
-b --dbpath \ -b --dbpath \
--cachedir \
' -- $cur ) ) ' -- $cur ) )
return 0 return 0
;; ;;
esac esac
rem_selected rem_selected
else else
case "${op}" in case "${op}" in
A|U) A|U)
COMPREPLY=( $( compgen -d -- "$cur" ) \ COMPREPLY=( $( compgen -d -- "$cur" ) \
$( compgen -f -X '!*.pkg.tar.gz' -- "$cur" ) ) $( compgen -f -X '!*.pkg.tar.gz' -- "$cur" ) )
return 0 return 0
;; ;;
h|V) h|V)
COMPREPLY='' COMPREPLY=''
return 0 return 0
;; ;;
Q) Q)
if _instring $mod g; then if _instring $mod g; then
_installed_groups _installed_groups
elif _instring $mod o; then elif _instring $mod o; then
COMPREPLY=( $( compgen -d -- "$cur" ) \ COMPREPLY=( $( compgen -d -- "$cur" ) \
$( compgen -f -- "$cur" ) ) $( compgen -f -- "$cur" ) )
elif _instring $mod p; then elif _instring $mod p; then
COMPREPLY=( $( compgen -d -- "$cur" ) \ COMPREPLY=( $( compgen -d -- "$cur" ) \
$( compgen -f -X '!*.pkg.tar.gz' -- "$cur" ) ) $( compgen -f -X '!*.pkg.tar.gz' -- "$cur" ) )
else else
_installed_pkgs _installed_pkgs
fi fi
return 0 return 0
;; ;;
R) R)
_installed_pkgs _installed_pkgs
return 0 return 0
;; ;;
S) S)
if _instring $mod l; then if _instring $mod l; then
_available_repos _available_repos
else else
_available_pkgs _available_pkgs
fi fi
return 0 return 0
;; ;;
esac esac
fi fi

View File

@ -241,7 +241,7 @@ static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
} }
} }
if(skipit) { if(skipit) {
_alpm_log(PM_LOG_WARNING, _("%s has moved packages, skipping removal"), _alpm_log(PM_LOG_WARNING, _("%s has changed ownership, skipping removal"),
file); file);
} else if(needbackup) { } else if(needbackup) {
/* if the file is flagged, back it up to .pacsave */ /* if the file is flagged, back it up to .pacsave */

View File

@ -134,7 +134,7 @@ static void usage(int op, char *myname)
} else if(op == PM_OP_SYNC) { } else if(op == PM_OP_SYNC) {
printf(_("usage: %s {-S --sync} [options] [package]\n"), myname); printf(_("usage: %s {-S --sync} [options] [package]\n"), myname);
printf(_("options:\n")); printf(_("options:\n"));
printf(_(" -c, --clean remove old packages from cache directory (use -cc for all)\n")); printf(_(" -c, --clean remove old packages from cache directory (-cc for all)\n"));
printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -d, --nodeps skip dependency checks\n"));
printf(_(" -e, --dependsonly install dependencies only\n")); printf(_(" -e, --dependsonly install dependencies only\n"));
printf(_(" -f, --force force install, overwrite conflicting files\n")); printf(_(" -f, --force force install, overwrite conflicting files\n"));