]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
bash-20120831 additional cleanup
authorChet Ramey <chet.ramey@case.edu>
Thu, 13 Sep 2012 16:03:03 +0000 (12:03 -0400)
committerChet Ramey <chet.ramey@case.edu>
Thu, 13 Sep 2012 16:03:03 +0000 (12:03 -0400)
builtins/xkill.def [deleted file]
lib/sh/ddd1 [deleted file]
tests/foohist-46148 [deleted file]

diff --git a/builtins/xkill.def b/builtins/xkill.def
deleted file mode 100644 (file)
index de1a3ed..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-This file is kill.def, from which is created kill.c.
-It implements the builtin "kill" in Bash.
-
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
-
-$PRODUCES kill.c
-
-$BUILTIN kill
-$FUNCTION kill_builtin
-$SHORT_DOC kill [-s sigspec | -n signum | -sigspec] [pid | job]... or kill -l [sigspec]
-$_ "Send the processes named by PID (or JOB) the signal SIGSPEC.  If"
-$_ "SIGSPEC is not present, then SIGTERM is assumed.  An argument of `-l'"
-$_ "lists the signal names; if arguments follow `-l' they are assumed to"
-$_ "be signal numbers for which names should be listed.  Kill is a shell"
-$_ "builtin for two reasons: it allows job IDs to be used instead of"
-$_ "process IDs, and, if you have reached the limit on processes that"
-$_ "you can create, you don't have to start a process to kill another one."
-$END
-
-#include <config.h>
-
-#include <stdio.h>
-#include <errno.h>
-#if defined (HAVE_UNISTD_H)
-#  ifdef _MINIX
-#    include <sys/types.h>
-#  endif
-#  include <unistd.h>
-#endif
-
-#include "../bashansi.h"
-
-#include "../shell.h"
-#include "../trap.h"
-#include "../jobs.h"
-#include "common.h"
-
-/* Not all systems declare ERRNO in errno.h... and some systems #define it! */
-#if !defined (errno)
-extern int errno;
-#endif /* !errno */
-
-extern int posixly_correct;
-
-static void kill_error __P((pid_t, int));
-
-#if !defined (CONTINUE_AFTER_KILL_ERROR)
-#  define CONTINUE_OR_FAIL return (EXECUTION_FAILURE)
-#else
-#  define CONTINUE_OR_FAIL goto continue_killing
-#endif /* CONTINUE_AFTER_KILL_ERROR */
-
-/* Here is the kill builtin.  We only have it so that people can type
-   kill -KILL %1?  No, if you fill up the process table this way you
-   can still kill some. */
-int
-kill_builtin (list)
-     WORD_LIST *list;
-{
-  int sig, any_succeeded, listing, saw_signal, dflags;
-  char *sigspec, *word;
-  pid_t pid;
-  intmax_t pid_value;
-
-  if (list == 0)
-    {
-      builtin_usage ();
-      return (EXECUTION_FAILURE);
-    }
-
-  any_succeeded = listing = saw_signal = 0;
-  sig = SIGTERM;
-  sigspec = "TERM";
-
-  dflags = DSIG_NOCASE | ((posixly_correct == 0) ? DSIG_SIGPREFIX : 0);
-  /* Process options. */
-  while (list)
-    {
-      word = list->word->word;
-
-      if (ISOPTION (word, 'l'))
-       {
-         listing++;
-         list = list->next;
-       }
-      else if (ISOPTION (word, 's') || ISOPTION (word, 'n'))
-       {
-         list = list->next;
-         if (list)
-           {
-             sigspec = list->word->word;
-             if (sigspec[0] == '0' && sigspec[1] == '\0')
-               sig = 0;
-             else
-               sig = decode_signal (sigspec, dflags);
-             list = list->next;
-           }
-         else
-           {
-             sh_needarg (word);
-             return (EXECUTION_FAILURE);
-           }
-       }
-      else if (ISOPTION (word, '-'))
-       {
-         list = list->next;
-         break;
-       }
-      else if (ISOPTION (word, '?'))
-       {
-         builtin_usage ();
-         return (EXECUTION_SUCCESS);
-       }
-      /* If this is a signal specification then process it.  We only process
-        the first one seen; other arguments may signify process groups (e.g,
-        -num == process group num). */
-      else if ((*word == '-') && !saw_signal)
-       {
-         sigspec = word + 1;
-         sig = decode_signal (sigspec, dflags);
-         saw_signal++;
-         list = list->next;
-       }
-      else
-       break;
-    }
-
-  if (listing)
-    return (display_signal_list (list, 0));
-
-  /* OK, we are killing processes. */
-  if (sig == NO_SIG)
-    {
-      sh_invalidsig (sigspec);
-      return (EXECUTION_FAILURE);
-    }
-
-  if (list == 0)
-    {
-      builtin_usage ();
-      return (EXECUTION_FAILURE);
-    }
-
-  while (list)
-    {
-      word = list->word->word;
-
-      if (*word == '-')
-       word++;
-
-      /* Use the entire argument in case of minus sign presence. */
-      if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value))
-       {
-         pid = (pid_t) pid_value;
-
-         if ((pid < -1 ? kill_pid (-pid, sig, 1) : kill_pid (pid, sig, 0)) < 0)
-           {
-             if (errno == EINVAL)
-               sh_invalidsig (sigspec);
-             else
-               kill_error (pid, errno);
-             CONTINUE_OR_FAIL;
-           }
-         else
-           any_succeeded++;
-       }
-#if defined (JOB_CONTROL)
-      else if (*list->word->word && *list->word->word != '%')
-       {
-         builtin_error ("%s: arguments must be process or job IDs", list->word->word);
-         CONTINUE_OR_FAIL;
-       }
-      else if (*word && (interactive || job_control))
-       /* Posix.2 says you can kill without job control active (4.32.4) */
-       {                       /* Must be a job spec.  Check it out. */
-         int job;
-         sigset_t set, oset;
-
-         BLOCK_CHILD (set, oset);
-         job = get_job_spec (list);
-
-         if (job < 0 || job >= job_slots || !jobs[job])
-           {
-             if (job != DUP_JOB)
-               sh_badjob (list->word->word);
-             UNBLOCK_CHILD (oset);
-             CONTINUE_OR_FAIL;
-           }
-
-         /* Job spec used.  Kill the process group. If the job was started
-            without job control, then its pgrp == shell_pgrp, so we have
-            to be careful.  We take the pid of the first job in the pipeline
-            in that case. */
-         pid = IS_JOBCONTROL (job) ? jobs[job]->pgrp : jobs[job]->pipe->pid;
-
-         UNBLOCK_CHILD (oset);
-
-         if (kill_pid (pid, sig, 1) < 0)
-           {
-             if (errno == EINVAL)
-               sh_invalidsig (sigspec);
-             else
-               kill_error (pid, errno);
-             CONTINUE_OR_FAIL;
-           }
-         else
-           any_succeeded++;
-       }
-#endif /* !JOB_CONTROL */
-      else
-       {
-         sh_badpid (list->word->word);
-         CONTINUE_OR_FAIL;
-       }
-    continue_killing:
-      list = list->next;
-    }
-
-  return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
-}
-
-static void
-kill_error (pid, e)
-     pid_t pid;
-     int e;
-{
-  char *x;
-
-  x = strerror (e);
-  if (x == 0)
-    x = "Unknown error";
-  builtin_error ("(%ld) - %s", (long)pid, x);
-}
diff --git a/lib/sh/ddd1 b/lib/sh/ddd1
deleted file mode 100644 (file)
index 674e5f3..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-*** savedir/strftime.c.save1   2011-01-16 15:23:14.000000000 -0500
---- strftime.c 2012-04-20 10:16:28.000000000 -0400
-***************
-*** 39,42 ****
---- 39,43 ----
-   * Updated December, 2001
-   * Updated January, 2011
-+  * Updated April, 2012
-   *
-   * Fixes from ado@elsie.nci.nih.gov,
-***************
-*** 76,79 ****
---- 77,81 ----
-  #define HPUX_EXT     1       /* non-conflicting stuff in HP-UX date */
-  #define POSIX_SEMANTICS      1       /* call tzset() if TZ changes */
-+ #define POSIX_2008   1       /* flag and fw for C, F, G, Y formats */
-  
-  #undef strchr        /* avoid AIX weirdness */
-***************
-*** 97,101 ****
-  #define range(low, item, hi) max(low, min(item, hi))
-  
-! #if !defined(OS2) && !defined(MSDOS) && defined(HAVE_TZNAME)
-  extern char *tzname[2];
-  extern int daylight;
---- 99,104 ----
-  #define range(low, item, hi) max(low, min(item, hi))
-  
-! /* Whew! This stuff is a mess. */
-! #if !defined(OS2) && !defined(MSDOS) && !defined(__CYGWIN__) && defined(HAVE_TZNAME)
-  extern char *tzname[2];
-  extern int daylight;
-***************
-*** 103,121 ****
-  extern long int timezone, altzone;
-  #else
-! #  if defined (HPUX)
-  extern long int timezone;
-  #  else
-  extern int timezone, altzone;
-! #  endif /* !HPUX */
-! #endif /* !SOLARIS && !mips && !M_UNIX */
-  #endif
-  
-  #undef min   /* just in case */
-  
-- /* format for %+ -- currently unused */
-- #ifndef NATIONAL_FORMAT
-- #define NATIONAL_FORMAT "%a %b %e %H:%M:%S %Z %Y"
-- #endif
-- 
-  /* min --- return minimum of two numbers */
-  
---- 106,121 ----
-  extern long int timezone, altzone;
-  #else
-! #  if defined (HPUX) || defined(__hpux)
-  extern long int timezone;
-  #  else
-+ #    if !defined(__CYGWIN__)
-  extern int timezone, altzone;
-! #    endif
-! #  endif
-! #endif
-  #endif
-  
-  #undef min   /* just in case */
-  
-  /* min --- return minimum of two numbers */
-  
-***************
-*** 136,139 ****
---- 136,167 ----
-  }
-  
-+ #ifdef POSIX_2008
-+ /* iso_8601_2000_year --- format a year per ISO 8601:2000 as in 1003.1 */
-+ 
-+ static void
-+ iso_8601_2000_year(char *buf, int year, size_t fw)
-+ {
-+      int extra;
-+      char sign = '\0';
-+ 
-+      if (year >= -9999 && year <= 9999) {
-+              sprintf(buf, "%0*d", fw, year);
-+              return;
-+      }
-+ 
-+      /* now things get weird */
-+      if (year > 9999) {
-+              sign = '+';
-+      } else {
-+              sign = '-';
-+              year = -year;
-+      }
-+ 
-+      extra = year / 10000;
-+      year %= 10000;
-+      sprintf(buf, "%c_%04d_%d", sign, extra, year);
-+ }
-+ #endif /* POSIX_2008 */
-+ 
-  /* strftime --- produce formatted time */
-  
-***************
-*** 156,165 ****
---- 184,200 ----
-  #ifndef HAVE_TM_NAME
-  #ifndef HAVE_TZNAME
-+ #ifndef __CYGWIN__
-       extern char *timezone();
-       struct timeval tv;
-       struct timezone zone;
-+ #endif /* __CYGWIN__ */
-  #endif /* HAVE_TZNAME */
-  #endif /* HAVE_TM_NAME */
-  #endif /* HAVE_TM_ZONE */
-+ #ifdef POSIX_2008
-+      int pad;
-+      size_t fw;
-+      char flag;
-+ #endif /* POSIX_2008 */
-  
-       /* various tables, useful in North America */
-***************
-*** 235,238 ****
---- 270,307 ----
-                       continue;
-               }
-+ #ifdef POSIX_2008
-+              pad = '\0';
-+              fw = 0;
-+              flag = '\0';
-+              switch (*++format) {
-+              case '+':
-+                      flag = '+';
-+                      /* fall through */
-+              case '0':
-+                      pad = '0';
-+                      format++;
-+                      break;
-+ 
-+              case '1':
-+              case '2':
-+              case '3':
-+              case '4':
-+              case '5':
-+              case '6':
-+              case '7':
-+              case '8':
-+              case '9':
-+                      break;
-+ 
-+              default:
-+                      format--;
-+                      goto again;
-+              }
-+              for (; isdigit(*format); format++) {
-+                      fw = fw * 10 + (*format - '0');
-+              }
-+              format--;
-+ #endif /* POSIX_2008 */
-+ 
-       again:
-               switch (*++format) {
-***************
-*** 286,291 ****
-  
-               case 'C':
-               century:
-!                      sprintf(tbuf, "%02ld", (timeptr->tm_year + 1900L) / 100);
-                       break;
-  
---- 355,371 ----
-  
-               case 'C':
-+ #ifdef POSIX_2008
-+                      if (pad != '\0' && fw > 0) {
-+                              size_t min_fw = (flag ? 3 : 2);
-+ 
-+                              fw = max(fw, min_fw);
-+                              sprintf(tbuf, flag
-+                                              ? "%+0*ld"
-+                                              : "%0*ld", fw,
-+                                              (timeptr->tm_year + 1900L) / 100);
-+                      } else
-+ #endif /* POSIX_2008 */
-               century:
-!                              sprintf(tbuf, "%02ld", (timeptr->tm_year + 1900L) / 100);
-                       break;
-  
-***************
-*** 308,312 ****
---- 388,415 ----
-  
-               case 'F':       /* ISO 8601 date representation */
-+              {
-+ #ifdef POSIX_2008
-+                      /*
-+                       * Field width for %F is for the whole thing.
-+                       * It must be at least 10.
-+                       */
-+                      char m_d[10];
-+                      strftime(m_d, sizeof m_d, "-%m-%d", timeptr);
-+                      size_t min_fw = 10;
-+ 
-+                      if (pad != '\0' && fw > 0) {
-+                              fw = max(fw, min_fw);
-+                      } else {
-+                              fw = min_fw;
-+                      }
-+ 
-+                      fw -= 6;        /* -XX-XX at end are invariant */
-+ 
-+                      iso_8601_2000_year(tbuf, timeptr->tm_year + 1900, fw);
-+                      strcat(tbuf, m_d);
-+ #else
-                       strftime(tbuf, sizeof tbuf, "%Y-%m-%d", timeptr);
-+ #endif /* POSIX_2008 */
-+              }
-                       break;
-  
-***************
-*** 330,335 ****
-                               y = 1900L + timeptr->tm_year;
-  
-!                      if (*format == 'G')
-!                              sprintf(tbuf, "%ld", y);
-                       else
-                               sprintf(tbuf, "%02ld", y % 100);
---- 433,450 ----
-                               y = 1900L + timeptr->tm_year;
-  
-!                      if (*format == 'G') {
-! #ifdef POSIX_2008
-!                              if (pad != '\0' && fw > 0) {
-!                                      size_t min_fw = 4;
-! 
-!                                      fw = max(fw, min_fw);
-!                                      sprintf(tbuf, flag
-!                                                      ? "%+0*ld"
-!                                                      : "%0*ld", fw,
-!                                                      y);
-!                              } else
-! #endif /* POSIX_2008 */
-!                                      sprintf(tbuf, "%ld", y);
-!                      }
-                       else
-                               sprintf(tbuf, "%02ld", y % 100);
-***************
-*** 456,460 ****
-  
-               case 'Y':       /* year with century */
-!              fullyear:
-                       sprintf(tbuf, "%ld", 1900L + timeptr->tm_year);
-                       break;
---- 571,585 ----
-  
-               case 'Y':       /* year with century */
-! #ifdef POSIX_2008
-!                      if (pad != '\0' && fw > 0) {
-!                              size_t min_fw = 4;
-! 
-!                              fw = max(fw, min_fw);
-!                              sprintf(tbuf, flag
-!                                              ? "%+0*ld"
-!                                              : "%0*ld", fw,
-!                                              1900L + timeptr->tm_year);
-!                      } else
-! #endif /* POSIX_2008 */
-                       sprintf(tbuf, "%ld", 1900L + timeptr->tm_year);
-                       break;
-***************
-*** 497,506 ****
-                        * secs west of GMT.  Convert to mins east of GMT.
-                        */
-! #  ifdef HPUX
-                       off = -timezone / 60;
-  #  else
-                       /* ADR: 4 August 2001, fixed this per gazelle@interaccess.com */
-                       off = -(daylight ? altzone : timezone) / 60;
-! #  endif /* !HPUX */
-  #else /* !HAVE_TZNAME */
-                       gettimeofday(& tv, & zone);
---- 622,631 ----
-                        * secs west of GMT.  Convert to mins east of GMT.
-                        */
-! #  if defined(__hpux) || defined (HPUX) || defined(__CYGWIN__)
-                       off = -timezone / 60;
-  #  else
-                       /* ADR: 4 August 2001, fixed this per gazelle@interaccess.com */
-                       off = -(daylight ? altzone : timezone) / 60;
-! #  endif
-  #else /* !HAVE_TZNAME */
-                       gettimeofday(& tv, & zone);
diff --git a/tests/foohist-46148 b/tests/foohist-46148
deleted file mode 100644 (file)
index f578b68..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-cat <<!
-one
-two
-three
-!
-
-history
-cat <<!
-one
-two
-three
-!