diff -uNr bash-2.05a~/bashline.c bash-2.05a/bashline.c
--- bash-2.05a~/bashline.c	Mon Nov  5 09:58:59 2001
+++ bash-2.05a/bashline.c	Thu Feb  7 14:43:03 2002
@@ -33,6 +33,8 @@
 #  include <grp.h>
 #endif
 
+#include <netdb.h>
+
 #include <stdio.h>
 #include "chartypes.h"
 #include "bashansi.h"
@@ -1470,6 +1472,69 @@
   return (value);
 #endif
 }
+
+char *
+bash_servicename_completion_function (text, state)
+     const char *text;
+     int state;
+{
+#if defined (__WIN32__) || defined (__OPENNT)
+  return (char *)NULL;
+#else
+  static char *sname = (char *)NULL;
+  static struct servent *entry;
+  static int snamelen, first_char;
+  char *value;
+  char **alist;
+  char *aentry;
+  int afound;
+
+  if (state == 0)
+    {
+      FREE (sname);
+
+      first_char = *text;
+
+      sname = savestring (&text[0]);
+      snamelen = strlen (sname);
+      setservent (0);
+    }
+
+  while (entry = getservent ())
+    {
+      afound = 0;
+      if (snamelen == 0 || (STREQN (sname, entry->s_name, snamelen)))
+       break;
+      alist = entry->s_aliases;
+      while (aentry = *alist)
+	{
+	  if (STREQN (sname, aentry, snamelen))
+	    {
+	      afound = 1;
+	      break;
+	    }
+	  alist++;
+	}
+        if (afound) break;
+    }
+
+  if (entry == 0)
+    {
+      endservent ();
+      return ((char *)NULL);
+    }
+
+  if (afound)
+    {
+      value = savestring (aentry);
+    }
+  else
+    {
+      value = savestring (entry->s_name);
+    }
+  return (value);
+#endif
+}
 
 /* Functions to perform history and alias expansions on the current line. */
 
diff -uNr bash-2.05a~/bashline.h bash-2.05a/bashline.h
--- bash-2.05a~/bashline.h	Mon Sep 10 10:45:18 2001
+++ bash-2.05a/bashline.h	Thu Feb  7 16:10:23 2002
@@ -36,6 +36,7 @@
 /* Used by programmable completion code. */
 extern char *command_word_completion_function __P((const char *, int));
 extern char *bash_groupname_completion_function __P((const char *, int));
+extern char *bash_servicename_completion_function __P((const char *, int));
 
 extern char **get_hostname_list __P((void));
 extern void clear_hostname_list __P((void));
diff -uNr bash-2.05a~/builtins/complete.def bash-2.05a/builtins/complete.def
--- bash-2.05a~/builtins/complete.def	Wed Jul 25 12:23:35 2001
+++ bash-2.05a/builtins/complete.def	Thu Feb  7 16:10:23 2002
@@ -90,6 +90,7 @@
   { "job",       CA_JOB,       'j' },
   { "keyword",   CA_KEYWORD,   'k' },
   { "running",   CA_RUNNING,    0 },
+  { "service",   CA_SERVICE,   's' },
   { "setopt",    CA_SETOPT,     0 },
   { "shopt",     CA_SHOPT,      0 },
   { "signal",    CA_SIGNAL,     0 },
@@ -160,7 +161,7 @@
   opt_given = 0;
 
   reset_internal_getopt ();
-  while ((opt = internal_getopt (list, "abcdefgjko:pruvA:G:W:P:S:X:F:C:")) != -1)
+  while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:")) != -1)
     {
       opt_given = 1;
       switch (opt)
@@ -218,6 +219,9 @@
 	case 'k':
 	  acts |= CA_KEYWORD;
 	  break;
+	case 's':
+	  acts |= CA_SERVICE;
+	  break;
 	case 'u':
 	  acts |= CA_USER;
 	  break;
@@ -439,6 +443,7 @@
   PRINTOPT (CA_GROUP, "-g");
   PRINTOPT (CA_KEYWORD, "-k");
   PRINTOPT (CA_JOB, "-j");
+  PRINTOPT (CA_SERVICE, "-s");
   PRINTOPT (CA_USER, "-u");
   PRINTOPT (CA_VARIABLE, "-v");
 
@@ -503,7 +508,7 @@
 $BUILTIN compgen
 $DEPENDS_ON PROGRAMMABLE_COMPLETION
 $FUNCTION compgen_builtin
-$SHORT_DOC compgen [-abcdefgjkvu] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
+$SHORT_DOC compgen [-abcdefgjksvu] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
 Display the possible completions depending on the options.  Intended
 to be used from within a shell function generating possible completions.
 If the optional WORD argument is supplied, matches against WORD are
diff -uNr bash-2.05a~/doc/bash.1 bash-2.05a/doc/bash.1
--- bash-2.05a~/doc/bash.1	Thu Feb  7 16:08:31 2002
+++ bash-2.05a/doc/bash.1	Thu Feb  7 16:10:23 2002
@@ -5750,7 +5750,7 @@
 matches were generated.
 .TP
 .PD 0
-\fBcomplete\fP [\fB\-abcdefgjkvu\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
+\fBcomplete\fP [\fB\-abcdefgjksvu\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
 .br
 [\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
 .TP
@@ -5853,6 +5853,9 @@
 .B running
 Names of running jobs, if job control is active.
 .TP 8
+.B service
+Service names.  May also be specified as \fB\-s\fP.
+.TP 8
 .B setopt
 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
 .TP 8
diff -uNr bash-2.05a~/pcomplete.c bash-2.05a/pcomplete.c
--- bash-2.05a~/pcomplete.c	Mon Nov  5 10:13:11 2001
+++ bash-2.05a/pcomplete.c	Thu Feb  7 16:10:23 2002
@@ -153,6 +153,7 @@
 ITEMLIST it_jobs = { LIST_DYNAMIC, it_init_jobs, (STRINGLIST *)0 };
 ITEMLIST it_keywords = { 0, it_init_keywords, (STRINGLIST *)0 };
 ITEMLIST it_running = { LIST_DYNAMIC, it_init_running, (STRINGLIST *)0 };
+ITEMLIST it_services = { LIST_DYNAMIC };	/* unused */
 ITEMLIST it_setopts = { 0, it_init_setopts, (STRINGLIST *)0 };
 ITEMLIST it_shopts = { 0, it_init_shopts, (STRINGLIST *)0 };
 ITEMLIST it_signals = { 0, it_init_signals, (STRINGLIST *)0 };
@@ -759,6 +760,7 @@
   GEN_XCOMPS(flags, CA_FILE, text, pcomp_filename_completion_function, cmatches, ret, tmatches);
   GEN_XCOMPS(flags, CA_USER, text, rl_username_completion_function, cmatches, ret, tmatches);
   GEN_XCOMPS(flags, CA_GROUP, text, bash_groupname_completion_function, cmatches, ret, tmatches);
+  GEN_XCOMPS(flags, CA_SERVICE, text, bash_servicename_completion_function, cmatches, ret, tmatches);
 
   /* And lastly, the special case for directories */
   if (flags & CA_DIRECTORY)
diff -uNr bash-2.05a~/pcomplete.h bash-2.05a/pcomplete.h
--- bash-2.05a~/pcomplete.h	Tue Aug 28 09:55:19 2001
+++ bash-2.05a/pcomplete.h	Thu Feb  7 16:10:23 2002
@@ -57,12 +57,13 @@
 #define CA_JOB		(1<<14)
 #define CA_KEYWORD	(1<<15)
 #define CA_RUNNING	(1<<16)
-#define CA_SETOPT	(1<<17)
-#define CA_SHOPT	(1<<18)
-#define CA_SIGNAL	(1<<19)
-#define CA_STOPPED	(1<<20)
-#define CA_USER		(1<<21)
-#define CA_VARIABLE	(1<<22)
+#define CA_SERVICE	(1<<17)
+#define CA_SETOPT	(1<<18)
+#define CA_SHOPT	(1<<19)
+#define CA_SIGNAL	(1<<20)
+#define CA_STOPPED	(1<<21)
+#define CA_USER		(1<<22)
+#define CA_VARIABLE	(1<<23)
 
 /* Values for COMPSPEC options field. */
 #define COPT_RESERVED	(1<<0)		/* reserved for other use */
@@ -112,6 +113,7 @@
 extern ITEMLIST it_jobs;
 extern ITEMLIST it_keywords;
 extern ITEMLIST it_running;
+extern ITEMLIST it_services;
 extern ITEMLIST it_setopts;
 extern ITEMLIST it_shopts;
 extern ITEMLIST it_signals;
