patch-Completion_BSD_Command__bsd_pkg 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. $OpenBSD: patch-Completion_BSD_Command__bsd_pkg,v 1.4 2015/12/21 19:13:17 jasper Exp $
  2. From 3272bdce987a3e5d5448688529ccb8290e148a67 Mon Sep 17 00:00:00 2001
  3. From: Matthew Martin <phy1729@gmail.com>
  4. Date: Fri, 11 Dec 2015 11:51:09 +0100
  5. Subject: [PATCH] 37383: add completion type for object files
  6. --- Completion/BSD/Command/_bsd_pkg.orig Wed Jan 21 14:53:28 2004
  7. +++ Completion/BSD/Command/_bsd_pkg Mon Jan 23 21:30:02 2006
  8. @@ -6,15 +6,19 @@ _bsd_pkg_pkgfiles() {
  9. case $OSTYPE in
  10. netbsd*)
  11. - portsdir=/usr/pkgsrc
  12. + portsdir=${PORTSDIR:-/usr/pkgsrc}
  13. + pkgsdir=${PACKAGES:-$portsdir/packages}/All
  14. ;;
  15. + openbsd*)
  16. + portsdir=${PORTSDIR:-/usr/ports}
  17. + pkgsdir=${PACKAGES:-$portsdir/packages}/$(arch -s)/All
  18. + ;;
  19. *)
  20. portsdir=${PORTSDIR:-/usr/ports}
  21. + pkgsdir=${PACKAGES:-$portsdir/packages}/All
  22. ;;
  23. esac
  24. - pkgsdir=${PACKAGES:-$portsdir/packages}/All
  25. -
  26. paths=( "${(@)${(@s.:.)PKG_PATH}:#}" )
  27. _files "$@" -g '*.t[bg]z(-.)' && ret=0
  28. (( $#path )) && _files "$@" -W paths -g '*.t[bg]z(-.)' && ret=0
  29. @@ -25,7 +29,7 @@ _bsd_pkg_pkgfiles() {
  30. (( $+functions[_bsd_pkg_pkgs] )) ||
  31. _bsd_pkg_pkgs() {
  32. - compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t)
  33. + compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(-/:t)
  34. }
  35. (( $+functions[_bsd_pkg_pkgs_and_files] )) ||
  36. @@ -67,9 +71,9 @@ _bsd_pkg() {
  37. ;;
  38. netbsd*)
  39. flags=(
  40. - $flags[@]
  41. - '-u[update]'
  42. - '-V[show version and exit]'
  43. + $flags[@]
  44. + '-u[update]'
  45. + '-V[show version and exit]'
  46. )
  47. ;;
  48. esac
  49. @@ -83,37 +87,37 @@ _bsd_pkg() {
  50. case "$OSTYPE" in
  51. freebsd*)
  52. flags=(
  53. - '-f[specify plist file]:plist file:_files'
  54. - '(-b)-c[specify comment file]:comment file:_files'
  55. - '(-b)-d[specify descr file]:descr file:_files'
  56. - '-Y[assume YES for any questions asked]'
  57. - '-N[assume NO for any questions asked]'
  58. - '(-b)-O[packing list only mode]'
  59. - '-v[be verbose]'
  60. - '-h[force tar to follow symlinks]'
  61. - '(-b)-i[specify pre-install script]:pre-install script:_files'
  62. - '(-b)-I[specify post-install script]:post-install script:_files'
  63. - '(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs'
  64. - '(-b)-p[specify prefix]:prefix directory:_files -/'
  65. - '(-b)-k[specify deinstall script]:deinstall script:_files'
  66. - '(-b)-K[specify post-deinstall script]:post-deinstall script:_files'
  67. - '(-b)-r[specify req script]:req script:_files'
  68. - '(-b)-s[specify source directory]:source directory:_files -/'
  69. - '(-b)-t[specify mktemp template]:mktemp template:_files'
  70. - '(-b)-X[specify exclude file]:exclude file for tar:_files'
  71. - '(-b)-D[specify message file]:message file:_files'
  72. - '(-b)-m[specify mtree file]:mtree file:_files'
  73. - '(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/'
  74. - '-j[use bzip2]'
  75. - '-z[use gzip]'
  76. - '(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs'
  77. - '*:package file name:_files'
  78. + '-f[specify plist file]:plist file:_files'
  79. + '(-b)-c[specify comment file]:comment file:_files'
  80. + '(-b)-d[specify descr file]:descr file:_files'
  81. + '-Y[assume YES for any questions asked]'
  82. + '-N[assume NO for any questions asked]'
  83. + '(-b)-O[packing list only mode]'
  84. + '-v[be verbose]'
  85. + '-h[force tar to follow symlinks]'
  86. + '(-b)-i[specify pre-install script]:pre-install script:_files'
  87. + '(-b)-I[specify post-install script]:post-install script:_files'
  88. + '(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs'
  89. + '(-b)-p[specify prefix]:prefix directory:_files -/'
  90. + '(-b)-k[specify deinstall script]:deinstall script:_files'
  91. + '(-b)-K[specify post-deinstall script]:post-deinstall script:_files'
  92. + '(-b)-r[specify req script]:req script:_files'
  93. + '(-b)-s[specify source directory]:source directory:_files -/'
  94. + '(-b)-t[specify mktemp template]:mktemp template:_files'
  95. + '(-b)-X[specify exclude file]:exclude file for tar:_files'
  96. + '(-b)-D[specify message file]:message file:_files'
  97. + '(-b)-m[specify mtree file]:mtree file:_files'
  98. + '(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/'
  99. + '-j[use bzip2]'
  100. + '-z[use gzip]'
  101. + '(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs'
  102. + '*:package file name:_files'
  103. )
  104. ;;
  105. netbsd*)
  106. # NetBSD users, improve me!
  107. flags=(
  108. - '*:package name:_bsd_pkg_pkgs'
  109. + '*:package name:_bsd_pkg_pkgs'
  110. )
  111. ;;
  112. esac
  113. @@ -136,35 +140,43 @@ _bsd_pkg() {
  114. freebsd*)
  115. flags=(
  116. $flags[@]
  117. - '(:)-a[delete all installed packages]'
  118. + '(:)-a[delete all installed packages]'
  119. '-G[do not expand glob patterns]'
  120. - '-i[be interactive]'
  121. + '-i[be interactive]'
  122. '-r[delete recursively]'
  123. '-x[use regular expression]'
  124. )
  125. ;;
  126. netbsd*)
  127. flags=(
  128. - $flags[@]
  129. - '(:)-a[delete all installed packages]'
  130. - '-F[specify each package by an installed file]'
  131. - '-i[be interactive]'
  132. - '-O[only delete the package'\''s entries]'
  133. + $flags[@]
  134. + '(:)-a[delete all installed packages]'
  135. + '-F[specify each package by an installed file]'
  136. + '-i[be interactive]'
  137. + '-O[only delete the package'\''s entries]'
  138. '-R[delete upward recursively]'
  139. '-r[delete recursively]'
  140. - '-V[show version and exit]'
  141. + '-V[show version and exit]'
  142. )
  143. ;;
  144. esac
  145. - _arguments -s \
  146. - $flags[@] \
  147. - '(-a)*:package name:_bsd_pkg_pkgs_and_files'
  148. + case "$OSTYPE" in
  149. + openbsd*)
  150. + _arguments -s \
  151. + $flags[@] \
  152. + '*:installed package name:_bsd_pkg_pkgs'
  153. + ;;
  154. + *)
  155. + _arguments -s \
  156. + $flags[@] \
  157. + '(-a)*:package name:_bsd_pkg_pkgs_and_files'
  158. + ;;
  159. + esac
  160. ;;
  161. pkg_info)
  162. flags=(
  163. - '(:)-a[show all installed packages]'
  164. '-c[show comment fields]'
  165. '-D[show install-message files]'
  166. '-d[show long descriptions]'
  167. @@ -188,30 +200,41 @@ _bsd_pkg() {
  168. flags=(
  169. $flags[@]
  170. '-G[do not expand glob patterns]'
  171. - '-g[show files that'\''s modified]'
  172. - '-o[show origin]'
  173. - '-s[show total size occupied by each package]'
  174. - '-t[specify mktemp template]:mktemp template:_files -/'
  175. - '*-W[show which package the file belongs to]:file:_files'
  176. - '-x[use regular expression]'
  177. + '-g[show files that are modified]'
  178. + '-o[show origin]'
  179. + '-s[show total size occupied by each package]'
  180. + '-t[specify mktemp template]:mktemp template:_files -/'
  181. + '*-W[show which package the file belongs to]:file:_files'
  182. + '-x[use regular expression]'
  183. )
  184. ;;
  185. netbsd*)
  186. flags=(
  187. - $flags[@]
  188. - '-B[show build information]'
  189. - '-b[show RCS Id strings]'
  190. - '-F[specify each package by an installed file]'
  191. - '-S[show total size occupied by each package and its dependents]'
  192. - '-s[show total size occupied by each package]'
  193. - '-V[show version and exit]'
  194. + $flags[@]
  195. + '-B[show build information]'
  196. + '-b[show RCS Id strings]'
  197. + '-F[specify each package by an installed file]'
  198. + '-S[show total size occupied by each package and its dependents]'
  199. + '-s[show total size occupied by each package]'
  200. + '-V[show version and exit]'
  201. )
  202. ;;
  203. esac
  204. - _arguments -s \
  205. - $flags[@] \
  206. - '(-a)*:package name:_bsd_pkg_pkgs_and_files'
  207. + case "$OSTYPE" in
  208. + openbsd*)
  209. + _arguments -s \
  210. + '(* -)-a[show all installed packages]' \
  211. + $flags[@] \
  212. + '*:installed package name:_bsd_pkg_pkgs'
  213. + ;;
  214. + *)
  215. + _arguments -s \
  216. + '(:)-a[show all installed packages]' \
  217. + $flags[@] \
  218. + '(-a)*:package name:_bsd_pkg_pkgs_and_files'
  219. + ;;
  220. + esac
  221. ;;
  222. esac
  223. }