Imported from ../bash-4.0-rc1.tar.gz.
[platform/upstream/bash.git] / builtins / type.def
index d03ccb2..ee341bb 100644 (file)
@@ -1,50 +1,53 @@
 This file is type.def, from which is created type.c.
 It implements the builtin "type" in Bash.
 
 This file is type.def, from which is created type.c.
 It implements the builtin "type" in Bash.
 
-Copyright (C) 1987-2002 Free Software Foundation, Inc.
+Copyright (C) 1987-2009 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
 
 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 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 3 of the License, 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.
+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.
+You should have received a copy of the GNU General Public License
+along with Bash.  If not, see <http://www.gnu.org/licenses/>.
 
 $PRODUCES type.c
 
 $BUILTIN type
 $FUNCTION type_builtin
 $SHORT_DOC type [-afptP] name [name ...]
 
 $PRODUCES type.c
 
 $BUILTIN type
 $FUNCTION type_builtin
 $SHORT_DOC type [-afptP] name [name ...]
+Display information about command type.
+
 For each NAME, indicate how it would be interpreted if used as a
 command name.
 
 For each NAME, indicate how it would be interpreted if used as a
 command name.
 
-If the -t option is used, `type' outputs a single word which is one of
-`alias', `keyword', `function', `builtin', `file' or `', if NAME is an
-alias, shell reserved word, shell function, shell builtin, disk file,
-or unfound, respectively.
-
-If the -p flag is used, `type' either returns the name of the disk
-file that would be executed, or nothing if `type -t NAME' would not
-return `file'.
-
-If the -a flag is used, `type' displays all of the places that contain
-an executable named `file'.  This includes aliases, builtins, and
-functions, if and only if the -p flag is not also used.
-
-The -f flag suppresses shell function lookup.
-
-The -P flag forces a PATH search for each NAME, even if it is an alias,
-builtin, or function, and returns the name of the disk file that would
-be executed.
+Options:
+  -a   display all locations containing an executable named NAME;
+       includes aliases, builtins, and functions, if and only if
+       the `-p' option is not also used
+  -f   suppress shell function lookup
+  -P   force a PATH search for each NAME, even if it is an alias,
+       builtin, or function, and returns the name of the disk file
+       that would be executed
+  -p   returns either the name of the disk file that would be executed,
+       or nothing if `type -t NAME' would not return `file'.
+  -t   output a single word which is one of `alias', `keyword',
+       `function', `builtin', `file' or `', if NAME is an alias, shell
+       reserved word, shell function, shell builtin, disk file, or not 
+       found, respectively
+
+Arguments:
+  NAME Command name to be interpreted.
+
+Exit Status:
+Returns success if all of the NAMEs are found; fails if any are not found.
 $END
 
 #include <config.h>
 $END
 
 #include <config.h>
@@ -108,14 +111,14 @@ int
 type_builtin (list)
      WORD_LIST *list;
 {
 type_builtin (list)
      WORD_LIST *list;
 {
-  int dflags, successful_finds, opt;
+  int dflags, any_failed, opt;
   WORD_LIST *this;
 
   if (list == 0)
     return (EXECUTION_SUCCESS);
 
   dflags = CDESC_SHORTDESC;    /* default */
   WORD_LIST *this;
 
   if (list == 0)
     return (EXECUTION_SUCCESS);
 
   dflags = CDESC_SHORTDESC;    /* default */
-  successful_finds = 0;
+  any_failed = 0;
 
   /* Handle the obsolescent `-type', `-path', and `-all' by prescanning
      the arguments and converting those options to the form that
 
   /* Handle the obsolescent `-type', `-path', and `-all' by prescanning
      the arguments and converting those options to the form that
@@ -181,13 +184,12 @@ type_builtin (list)
       if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0)
        sh_notfound (list->word->word);
 
       if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0)
        sh_notfound (list->word->word);
 
-      successful_finds += found;
+      any_failed += found == 0;
       list = list->next;
     }
 
       list = list->next;
     }
 
-  fflush (stdout);
-
-  return ((successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+  opt = (any_failed == 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE;
+  return (sh_chkwrite (opt));
 }
 
 /*
 }
 
 /*
@@ -267,18 +269,14 @@ describe_command (command, dflags)
        puts ("function");
       else if (dflags & CDESC_SHORTDESC)
        {
        puts ("function");
       else if (dflags & CDESC_SHORTDESC)
        {
-#define PRETTY_PRINT_FUNC 1
          char *result;
 
          printf (_("%s is a function\n"), command);
 
          /* We're blowing away THE_PRINTED_COMMAND here... */
 
          char *result;
 
          printf (_("%s is a function\n"), command);
 
          /* We're blowing away THE_PRINTED_COMMAND here... */
 
-         result = named_function_string (command,
-                                         (COMMAND *) function_cell (func),
-                                         PRETTY_PRINT_FUNC);
+         result = named_function_string (command, function_cell (func), FUNC_MULTILINE|FUNC_EXTERNAL);
          printf ("%s\n", result);
          printf ("%s\n", result);
-#undef PRETTY_PRINT_FUNC
        }
       else if (dflags & CDESC_REUSABLE)
        printf ("%s\n", command);
        }
       else if (dflags & CDESC_REUSABLE)
        printf ("%s\n", command);
@@ -390,7 +388,7 @@ describe_command (command, dflags)
       if (dflags & CDESC_TYPE)
        puts ("file");
       else if (dflags & CDESC_SHORTDESC)
       if (dflags & CDESC_TYPE)
        puts ("file");
       else if (dflags & CDESC_SHORTDESC)
-       printf ("%s is %s\n", command, full_path);
+       printf (_("%s is %s\n"), command, full_path);
       else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
        printf ("%s\n", full_path);
 
       else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY))
        printf ("%s\n", full_path);