zsh-users
 help / color / mirror / code / Atom feed
From: James Devenish <j-devenish@users.sourceforge.net>
To: zsh-users@sunsite.dk
Cc: David Lebel <lebel@openbsd.org>
Subject: Re: Refactoring _bsd_pkg
Date: Thu, 2 Jan 2003 23:37:06 +0800	[thread overview]
Message-ID: <20030102153706.GA7459@gulag.guild.uwa.edu.au> (raw)
In-Reply-To: <2419.1041518512@finches.logica.co.uk>

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

In message <2419.1041518512@finches.logica.co.uk>
on Thu, Jan 02, 2003 at 03:41:52PM +0100, Oliver Kiddle wrote:
> Is there any chance that you could merge your OpenBSD functions into
> the _bsd_pkg HEAD and then submit a patch to the zsh-workers list. They
> can then be committed to cvs without upsetting FreeBSD users. It should
> just be a matter of sticking an `openbsd*)' section in the various `case
> "$OSTYPE" in' parts of the function.

Yes, that's fine, I have attached a diff for the beast, only improving
pkd_delete, and pkg_info. I also replaced tabs with spaces since the
file seemed to have a mixture, and that's made the patch a bit large.
This is just a heads-up and I don't really intent on anyone feeling
willing to commit this verbatim -- it's night-time here and I'll have
another look at it tomorrow. (And the person with the CC of my post is
the OpenBSD port maintainer for zsh, so he may have something useful to
add.)

pkg_add still doesn't work quite right because it always has some
directories (those matching the pattern /*) in the completion list,
even if my current directory is not /.

PS. I replaced '\'' with '', but maybe that's not portable? Also, I
noticed that in my own script, I had an error for the -l option (I
suspect it's an option that's never used in an interactive shell,
let alone used with a completion mechanism).


[-- Attachment #2: patch-Completion_BSD_Command__bsd_pkg --]
[-- Type: text/plain, Size: 8687 bytes --]

Index: _bsd_pkg
OpenBSD compatability for pkg_delete and pkg_info options.
OpenBSD compatability for pkg_add packages list.
Detabbed.
Allow symlinks to directories in addition to directories.
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/BSD/Command/_bsd_pkg,v
retrieving revision 1.5
diff -u -r1.5 _bsd_pkg
--- _bsd_pkg	26 Sep 2002 10:30:01 -0000	1.5
+++ _bsd_pkg	2 Jan 2003 15:31:42 -0000
@@ -6,15 +6,19 @@
 
   case $OSTYPE in
   netbsd*)
-    portsdir=/usr/pkgsrc
+    portsdir=${PORTSDIR:-/usr/pkgsrc}
+    pkgsdir=${PACKAGES:-$portsdir/packages}/All
+    ;;
+  openbsd*)
+    portsdir=${PORTSDIR:-/usr/ports}
+    pkgsdir=${PACKAGES:-$portsdir/packages}/$(arch -s)/All
     ;;
   *)
     portsdir=${PORTSDIR:-/usr/ports}
+    pkgsdir=${PACKAGES:-$portsdir/packages}/All
     ;;
   esac
 
-  pkgsdir=${PACKAGES:-$portsdir/packages}/All
-
   paths=( "${(@)${(@s.:.)PKG_PATH}:#}" )
   _files "$@" -g '*.t[bg]z' && ret=0
   (( $#path )) && _files "$@" -W paths -g '*.t[bg]z' && ret=0
@@ -25,7 +29,7 @@
 
 (( $+functions[_bsd_pkg_pkgs] )) ||
 _bsd_pkg_pkgs() {
-  compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t)
+  compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(-/:t)
 }
 
 (( $+functions[_bsd_pkg_pkgs_and_files] )) ||
@@ -48,11 +52,11 @@
   pkg_add)
     flags=(
       '-f[force installation]'
-      '-I[don'\''t execute installation scripts]'
+      '-I[don''t execute installation scripts]'
       '-M[run in master mode]'
-      '-n[don'\''t really install packages]'
+      '-n[don''t really install packages]'
       '-p[specify prefix]:prefix directory:_files -/'
-      '-R[don'\''t record]'
+      '-R[don''t record]'
       '-S[run in slave mode]'
       '-t[specify mktemp template]:mktemp template:_files -/'
       '-v[be verbose]'
@@ -67,9 +71,9 @@
       ;;
     netbsd*)
       flags=(
-	$flags[@]
-	'-u[update]'
-	'-V[show version and exit]'
+        $flags[@]
+        '-u[update]'
+        '-V[show version and exit]'
       )
       ;;
     esac
@@ -83,37 +87,37 @@
     case "$OSTYPE" in
     freebsd*)
       flags=(
-	'-f[specify plist file]:plist file:_files'
-	'(-b)-c[specify comment file]:comment file:_files'
-	'(-b)-d[specify descr file]:descr file:_files'
-	'-Y[assume YES for any questions asked]'
-	'-N[assume NO for any questions asked]'
-	'(-b)-O[packing list only mode]'
-	'-v[be verbose]'
-	'-h[force tar to follow symlinks]'
-	'(-b)-i[specify pre-install script]:pre-install script:_files'
-	'(-b)-I[specify post-install script]:post-install script:_files'
-	'(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs'
-	'(-b)-p[specify prefix]:prefix directory:_files -/'
-	'(-b)-k[specify deinstall script]:deinstall script:_files'
-	'(-b)-K[specify post-deinstall script]:post-deinstall script:_files'
-	'(-b)-r[specify req script]:req script:_files'
-	'(-b)-s[specify source directory]:source directory:_files -/'
-	'(-b)-t[specify mktemp template]:mktemp template:_files'
-	'(-b)-X[specify exclude file]:exclude file for tar:_files'
-	'(-b)-D[specify message file]:message file:_files'
-	'(-b)-m[specify mtree file]:mtree file:_files'
-	'(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/'
-	'-j[use bzip2]'
-	'-z[use gzip]'
-	'(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs'
-	'*:package file name:_files'
+        '-f[specify plist file]:plist file:_files'
+        '(-b)-c[specify comment file]:comment file:_files'
+        '(-b)-d[specify descr file]:descr file:_files'
+        '-Y[assume YES for any questions asked]'
+        '-N[assume NO for any questions asked]'
+        '(-b)-O[packing list only mode]'
+        '-v[be verbose]'
+        '-h[force tar to follow symlinks]'
+        '(-b)-i[specify pre-install script]:pre-install script:_files'
+        '(-b)-I[specify post-install script]:post-install script:_files'
+        '(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs'
+        '(-b)-p[specify prefix]:prefix directory:_files -/'
+        '(-b)-k[specify deinstall script]:deinstall script:_files'
+        '(-b)-K[specify post-deinstall script]:post-deinstall script:_files'
+        '(-b)-r[specify req script]:req script:_files'
+        '(-b)-s[specify source directory]:source directory:_files -/'
+        '(-b)-t[specify mktemp template]:mktemp template:_files'
+        '(-b)-X[specify exclude file]:exclude file for tar:_files'
+        '(-b)-D[specify message file]:message file:_files'
+        '(-b)-m[specify mtree file]:mtree file:_files'
+        '(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/'
+        '-j[use bzip2]'
+        '-z[use gzip]'
+        '(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs'
+        '*:package file name:_files'
       )
       ;;
     netbsd*)
       # NetBSD users, improve me!
       flags=(
-	'*:package name:_bsd_pkg_pkgs'
+        '*:package name:_bsd_pkg_pkgs'
       )
       ;;
     esac
@@ -124,10 +128,10 @@
 
   pkg_delete)
     flags=(
-      '-D[don'\''t execute deinstallation scripts]'
+      '-D[don''t execute deinstallation scripts]'
       '-d[remove empty directories]'
       '-f[force deinstallation]'
-      '-n[don'\''t really deinstall packages]'
+      '-n[don''t really deinstall packages]'
       '-p[specify prefix]:prefix directory:_files -/'
       '-v[be verbose]'
     )
@@ -136,35 +140,43 @@
     freebsd*)
       flags=(
         $flags[@]
-	'(:)-a[delete all installed packages]'
+        '(:)-a[delete all installed packages]'
         '-G[do not expand glob patterns]'
-	'-i[be interactive]'
+        '-i[be interactive]'
         '-r[delete recursively]'
         '-x[use regular expression]'
       )
       ;;
     netbsd*)
       flags=(
-	$flags[@]
-	'(:)-a[delete all installed packages]'
-	'-F[specify each package by an installed file]'
-	'-i[be interactive]'
-	'-O[only delete the package'\''s entries]'
+        $flags[@]
+        '(:)-a[delete all installed packages]'
+        '-F[specify each package by an installed file]'
+        '-i[be interactive]'
+        '-O[only delete the package''s entries]'
         '-R[delete upward recursively]'
         '-r[delete recursively]'
-	'-V[show version and exit]'
+        '-V[show version and exit]'
       )
       ;;
     esac
 
-    _arguments -s \
-      $flags[@] \
-      '(-a)*:package name:_bsd_pkg_pkgs_and_files'
+    case "$OSTYPE" in
+    openbsd*)
+      _arguments -s \
+        $flags[@] \
+        '*:installed package name:_bsd_pkg_pkgs'
+      ;;
+    *)
+      _arguments -s \
+        $flags[@] \
+        '(-a)*:package name:_bsd_pkg_pkgs_and_files'
+      ;;
+    esac
     ;;
 
   pkg_info)
     flags=(
-      '(:)-a[show all installed packages]'
       '-c[show comment fields]'
       '-D[show install-message files]'
       '-d[show long descriptions]'
@@ -188,30 +200,41 @@
       flags=(
         $flags[@]
         '-G[do not expand glob patterns]'
-	'-g[show files that'\''s modified]'
-	'-o[show origin]'
-	'-s[show total size occupied by each package]'
-	'-t[specify mktemp template]:mktemp template:_files -/'
-	'*-W[show which package the file belongs to]:file:_files'
-	'-x[use regular expression]'
+        '-g[show files that are modified]'
+        '-o[show origin]'
+        '-s[show total size occupied by each package]'
+        '-t[specify mktemp template]:mktemp template:_files -/'
+        '*-W[show which package the file belongs to]:file:_files'
+        '-x[use regular expression]'
       )
       ;;
     netbsd*)
       flags=(
-	$flags[@]
-	'-B[show build information]'
-	'-b[show RCS Id strings]'
-	'-F[specify each package by an installed file]'
-	'-S[show total size occupied by each package and its dependents]'
-	'-s[show total size occupied by each package]'
-	'-V[show version and exit]'
+        $flags[@]
+        '-B[show build information]'
+        '-b[show RCS Id strings]'
+        '-F[specify each package by an installed file]'
+        '-S[show total size occupied by each package and its dependents]'
+        '-s[show total size occupied by each package]'
+        '-V[show version and exit]'
       )
       ;;
     esac
 
-    _arguments -s \
-      $flags[@] \
-      '(-a)*:package name:_bsd_pkg_pkgs_and_files'
+    case "$OSTYPE" in
+    openbsd*)
+      _arguments -s \
+        '(* -)-a[show all installed packages]' \
+        $flags[@] \
+        '*:installed package name:_bsd_pkg_pkgs'
+      ;;
+    *)
+      _arguments -s \
+        '(:)-a[show all installed packages]' \
+        $flags[@] \
+        '(-a)*:package name:_bsd_pkg_pkgs_and_files'
+      ;;
+    esac
     ;;
   esac
 }

  reply	other threads:[~2003-01-02 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-02 14:04 James Devenish
2003-01-02 14:41 ` Oliver Kiddle
2003-01-02 15:37   ` James Devenish [this message]
2003-01-03  8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish
2003-01-03  9:14   ` Roman Neuhauser
2003-01-03 10:19   ` Phil Pennock
2003-01-03 10:30     ` James Devenish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030102153706.GA7459@gulag.guild.uwa.edu.au \
    --to=j-devenish@users.sourceforge.net \
    --cc=lebel@openbsd.org \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).