diff options
Diffstat (limited to 'builtins')
-rw-r--r-- | builtins/declare.def | 4 | ||||
-rw-r--r-- | builtins/declare.def~ | 22 | ||||
-rw-r--r-- | builtins/help.def | 2 | ||||
-rw-r--r-- | builtins/help.def~ | 229 | ||||
-rw-r--r-- | builtins/printf.def | 6 | ||||
-rw-r--r-- | builtins/printf.def~ | 6 | ||||
-rw-r--r-- | builtins/read.def | 64 | ||||
-rw-r--r-- | builtins/read.def.save1 | 10 | ||||
-rw-r--r-- | builtins/read.def~ | 72 | ||||
-rw-r--r-- | builtins/setattr.def | 4 | ||||
-rw-r--r-- | builtins/setattr.def~ | 14 | ||||
-rw-r--r-- | builtins/type.def | 8 | ||||
-rw-r--r-- | builtins/type.def~ | 15 |
13 files changed, 402 insertions, 54 deletions
diff --git a/builtins/declare.def b/builtins/declare.def index 2bb9e1d2..f8fe32bf 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -1,7 +1,7 @@ This file is declare.def, from which is created declare.c. It implements the builtins "declare" and "local" in Bash. -Copyright (C) 1987-2006 Free Software Foundation, Inc. +Copyright (C) 1987-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -332,7 +332,7 @@ declare_internal (list, local_var) #endif /* DEBUGGER */ { t = nodefs ? var->name - : named_function_string (name, function_cell (var), 1); + : named_function_string (name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL); printf ("%s\n", t); any_failed = sh_chkwrite (any_failed); } diff --git a/builtins/declare.def~ b/builtins/declare.def~ index c472a86c..31c09012 100644 --- a/builtins/declare.def~ +++ b/builtins/declare.def~ @@ -1,7 +1,7 @@ This file is declare.def, from which is created declare.c. It implements the builtins "declare" and "local" in Bash. -Copyright (C) 1987-2004 Free Software Foundation, Inc. +Copyright (C) 1987-2006 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -89,10 +89,11 @@ declare_builtin (list) $BUILTIN local $FUNCTION local_builtin -$SHORT_DOC local name[=value] ... +$SHORT_DOC local [option] name[=value] ... Create a local variable called NAME, and give it VALUE. LOCAL can only be used within a function; it makes the variable NAME have a visible scope restricted to that function and its children. +OPTION can be any of the options accepted by `declare'. $END int local_builtin (list) @@ -190,16 +191,12 @@ declare_internal (list, local_var) free (vlist); } } + else if (flags_on == 0) + return (set_builtin ((WORD_LIST *)NULL)); else - { - if (flags_on == 0) - set_builtin ((WORD_LIST *)NULL); - else - set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs); - } + set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs); - fflush (stdout); - return (EXECUTION_SUCCESS); + return (sh_chkwrite (EXECUTION_SUCCESS)); } if (pflag) /* declare -p [-afFirtx] name [name...] */ @@ -213,7 +210,7 @@ declare_internal (list, local_var) any_failed++; } } - return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); + return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS)); } #define NEXT_VARIABLE() free (name); list = list->next; continue @@ -335,8 +332,9 @@ declare_internal (list, local_var) #endif /* DEBUGGER */ { t = nodefs ? var->name - : named_function_string (name, function_cell (var), 1); + : named_function_string (name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL); printf ("%s\n", t); + any_failed = sh_chkwrite (any_failed); } } else /* declare -[fF] -[rx] name [name...] */ diff --git a/builtins/help.def b/builtins/help.def index 059f9866..743685b1 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -208,7 +208,7 @@ A star (*) next to a name means that the command is disabled.\n\ blurb[width - 2] = '>'; /* indicate truncation */ blurb[width - 1] = '\0'; printf ("%s", blurb); - if ((i << 1) == num_shell_builtins) + if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins)) { printf ("\n"); break; diff --git a/builtins/help.def~ b/builtins/help.def~ new file mode 100644 index 00000000..067b83cf --- /dev/null +++ b/builtins/help.def~ @@ -0,0 +1,229 @@ +This file is help.def, from which is created help.c. +It implements the builtin "help" in Bash. + +Copyright (C) 1987-2006 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 help.c + +$BUILTIN help +$FUNCTION help_builtin +$DEPENDS_ON HELP_BUILTIN +$SHORT_DOC help [-s] [pattern ...] +Display helpful information about builtin commands. If PATTERN is +specified, gives detailed help on all commands matching PATTERN, +otherwise a list of the builtins is printed. The -s option +restricts the output for each builtin command matching PATTERN to +a short usage synopsis. +$END + +#include <config.h> + +#if defined (HELP_BUILTIN) +#include <stdio.h> + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include <sys/types.h> +# endif +# include <unistd.h> +#endif + +#include <errno.h> + +#include <filecntl.h> + +#include "../bashintl.h" + +#include "../shell.h" +#include "../builtins.h" +#include "../pathexp.h" +#include "common.h" +#include "bashgetopt.h" + +#include <glob/strmatch.h> +#include <glob/glob.h> + +#ifndef errno +extern int errno; +#endif + +static void show_builtin_command_help __P((void)); +static void show_longdoc __P((int)); + +/* Print out a list of the known functions in the shell, and what they do. + If LIST is supplied, print out the list which matches for each pattern + specified. */ +int +help_builtin (list) + WORD_LIST *list; +{ + register int i; + char *pattern, *name; + int plen, match_found, sflag; + + sflag = 0; + reset_internal_getopt (); + while ((i = internal_getopt (list, "s")) != -1) + { + switch (i) + { + case 's': + sflag = 1; + break; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + if (list == 0) + { + show_shell_version (0); + show_builtin_command_help (); + return (EXECUTION_SUCCESS); + } + + /* We should consider making `help bash' do something. */ + + if (glob_pattern_p (list->word->word)) + { + if (list->next) + printf (_("Shell commands matching keywords `")); + else + printf (_("Shell commands matching keyword `")); + print_word_list (list, ", "); + printf ("'\n\n"); + } + + for (match_found = 0, pattern = ""; list; list = list->next) + { + pattern = list->word->word; + plen = strlen (pattern); + + for (i = 0; name = shell_builtins[i].name; i++) + { + QUIT; + if ((strncmp (pattern, name, plen) == 0) || + (strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH)) + { + printf ("%s: %s\n", name, shell_builtins[i].short_doc); + + if (sflag == 0) + show_longdoc (i); + + match_found++; + } + } + } + + if (match_found == 0) + { + builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern); + return (EXECUTION_FAILURE); + } + + fflush (stdout); + return (EXECUTION_SUCCESS); +} + +/* By convention, enforced by mkbuiltins.c, if separate help files are being + used, the long_doc array contains one string -- the full pathname of the + help file for this builtin. */ +static void +show_longdoc (i) + int i; +{ + register int j; + char * const *doc; + int fd; + + doc = shell_builtins[i].long_doc; + + if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL) + { + fd = open (doc[0], O_RDONLY); + if (fd == -1) + { + builtin_error (_("%s: cannot open: %s"), doc[0], strerror (errno)); + return; + } + zcatfd (fd, 1, doc[0]); + close (fd); + } + else + for (j = 0; doc[j]; j++) + printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j])); +} + +static void +show_builtin_command_help () +{ + int i, j; + int height, width; + char *t, blurb[128]; + + printf ( +_("These shell commands are defined internally. Type `help' to see this list.\n\ +Type `help name' to find out more about the function `name'.\n\ +Use `info bash' to find out more about the shell in general.\n\ +Use `man -k' or `info' to find out more about commands not in this list.\n\ +\n\ +A star (*) next to a name means that the command is disabled.\n\ +\n")); + + t = get_string_value ("COLUMNS"); + width = (t && *t) ? atoi (t) : 80; + if (width <= 0) + width = 80; + + width /= 2; + if (width > sizeof (blurb)) + width = sizeof (blurb); + height = (num_shell_builtins + 1) / 2; /* number of rows */ + + for (i = 0; i < height; i++) + { + QUIT; + + /* first column */ + blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*'; + strncpy (blurb + 1, shell_builtins[i].short_doc, width - 2); + blurb[width - 2] = '>'; /* indicate truncation */ + blurb[width - 1] = '\0'; + printf ("%s", blurb); + if (((i << 1) >= num_shell_builtins)) /* || (i+height >= num_shell_builtins)) */ + { + printf ("\n"); + break; + } + + /* two spaces */ + for (j = strlen (blurb); j < width; j++) + putc (' ', stdout); + + /* second column */ + blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*'; + strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 3); + blurb[width - 3] = '>'; /* indicate truncation */ + blurb[width - 2] = '\0'; + printf ("%s\n", blurb); + } +} +#endif /* HELP_BUILTIN */ diff --git a/builtins/printf.def b/builtins/printf.def index e283323c..865b0478 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -148,6 +148,8 @@ extern int errno; vbsize = 0; \ vbuf = 0; \ } \ + else if (vbuf) \ + vbuf[0] = 0; \ fflush (stdout); \ if (ferror (stdout)) \ { \ @@ -228,6 +230,8 @@ printf_builtin (list) { vflag = 1; vblen = 0; + if (vbuf) + vbuf[0] = 0; } else { @@ -835,7 +839,7 @@ vbadd (buf, blen) if (blen == 1) vbuf[vblen++] = buf[0]; - else + else if (blen > 1) { FASTCOPY (buf, vbuf + vblen, blen); vblen += blen; diff --git a/builtins/printf.def~ b/builtins/printf.def~ index f268180a..5daface1 100644 --- a/builtins/printf.def~ +++ b/builtins/printf.def~ @@ -1,7 +1,7 @@ This file is printf.def, from which is created printf.c. It implements the builtin "printf" in Bash. -Copyright (C) 1997-2006 Free Software Foundation, Inc. +Copyright (C) 1997-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -228,6 +228,8 @@ printf_builtin (list) { vflag = 1; vblen = 0; + if (vbuf) + vbuf[0] = 0; } else { @@ -835,7 +837,7 @@ vbadd (buf, blen) if (blen == 1) vbuf[vblen++] = buf[0]; - else + else if (blen > 1) { FASTCOPY (buf, vbuf + vblen, blen); vblen += blen; diff --git a/builtins/read.def b/builtins/read.def index 0739059f..e5aff643 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -94,6 +94,9 @@ static void set_eol_delim __P((int)); static void reset_eol_delim __P((char *)); #endif static SHELL_VAR *bind_read_variable __P((char *, char *)); +#if defined (HANDLE_MULTIBYTE) +static int read_mbchar __P((int, char *, int, int, int)); +#endif static sighandler sigalrm __P((int)); static void reset_alarm __P((void)); @@ -441,7 +444,7 @@ read_builtin (list) } #endif - if (i + 2 >= size) + if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */ { input_string = (char *)xrealloc (input_string, size += 128); remove_unwind_protect (); @@ -456,7 +459,7 @@ read_builtin (list) if (c == '\n') { i--; /* back up over the CTLESC */ - if (interactive && raw == 0) + if (interactive && input_is_tty && raw == 0) print_ps2 = 1; } else @@ -487,6 +490,15 @@ read_builtin (list) add_char: input_string[i++] = c; + +#if defined (HANDLE_MULTIBYTE) + if (nchars > 0 && MB_CUR_MAX > 1) + { + input_string[i] = '\0'; /* for simplicity and debugging */ + i += read_mbchar (fd, input_string, i, c, unbuffered_read); + } +#endif + nr++; if (nchars > 0 && nr >= nchars) @@ -721,6 +733,54 @@ bind_read_variable (name, value) #endif /* !ARRAY_VARS */ } +#if defined (HANDLE_MULTIBYTE) +static int +read_mbchar (fd, string, ind, ch, unbuffered) + int fd; + char *string; + int ind, ch, unbuffered; +{ + char mbchar[MB_LEN_MAX + 1]; + int i, n, r; + char c; + size_t ret; + mbstate_t ps, ps_back; + wchar_t wc; + + memset (&ps, '\0', sizeof (mbstate_t)); + memset (&ps_back, '\0', sizeof (mbstate_t)); + + mbchar[0] = ch; + i = 1; + for (n = 0; n <= MB_LEN_MAX; n++) + { + ps_back = ps; + ret = mbrtowc (&wc, mbchar, i, &ps); + if (ret == (size_t)-2) + { + ps = ps_back; + if (unbuffered) + r = zread (fd, &c, 1); + else + r = zreadc (fd, &c); + if (r < 0) + goto mbchar_return; + mbchar[i++] = c; + continue; + } + else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0) + break; + } + +mbchar_return: + if (i > 1) /* read a multibyte char */ + /* mbchar[0] is already string[ind-1] */ + for (r = 1; r < i; r++) + string[ind+r-1] = mbchar[r]; + return i - 1; +} +#endif + #if defined (READLINE) static rl_completion_func_t *old_attempted_completion_function = 0; diff --git a/builtins/read.def.save1 b/builtins/read.def.save1 index e22f8228..5bfe00b4 100644 --- a/builtins/read.def.save1 +++ b/builtins/read.def.save1 @@ -128,7 +128,7 @@ read_builtin (list) { register char *varname; int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; - int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc; + int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; int raw, edit, nchars, silent, have_timeout, fd; unsigned int tmout; intmax_t intval; @@ -263,8 +263,8 @@ read_builtin (list) ifs_chars = getifs (); if (ifs_chars == 0) /* XXX - shouldn't happen */ ifs_chars = ""; - for (skip_ctlesc = 0, e = ifs_chars; *e; e++) - skip_ctlesc |= *e == CTLESC; + for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) + skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; input_string = (char *)xmalloc (size = 112); /* XXX was 128 */ @@ -456,7 +456,7 @@ read_builtin (list) if (c == '\n') { i--; /* back up over the CTLESC */ - if (interactive && raw == 0) + if (interactive && input_is_tty && raw == 0) print_ps2 = 1; } else @@ -479,7 +479,7 @@ read_builtin (list) if ((unsigned char)c == delim) break; - if ((skip_ctlesc == 0 && c == CTLESC) || c == CTLNUL) + if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL)) { saw_escape++; input_string[i++] = CTLESC; diff --git a/builtins/read.def~ b/builtins/read.def~ index e22f8228..9680c425 100644 --- a/builtins/read.def~ +++ b/builtins/read.def~ @@ -94,6 +94,9 @@ static void set_eol_delim __P((int)); static void reset_eol_delim __P((char *)); #endif static SHELL_VAR *bind_read_variable __P((char *, char *)); +#if defined (HANDLE_MULTIBYTE) +static int read_mbchar __P((int, char *, int, int, int)); +#endif static sighandler sigalrm __P((int)); static void reset_alarm __P((void)); @@ -128,7 +131,7 @@ read_builtin (list) { register char *varname; int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; - int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc; + int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; int raw, edit, nchars, silent, have_timeout, fd; unsigned int tmout; intmax_t intval; @@ -263,8 +266,8 @@ read_builtin (list) ifs_chars = getifs (); if (ifs_chars == 0) /* XXX - shouldn't happen */ ifs_chars = ""; - for (skip_ctlesc = 0, e = ifs_chars; *e; e++) - skip_ctlesc |= *e == CTLESC; + for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) + skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; input_string = (char *)xmalloc (size = 112); /* XXX was 128 */ @@ -441,7 +444,7 @@ read_builtin (list) } #endif - if (i + 2 >= size) + if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */ { input_string = (char *)xrealloc (input_string, size += 128); remove_unwind_protect (); @@ -456,7 +459,7 @@ read_builtin (list) if (c == '\n') { i--; /* back up over the CTLESC */ - if (interactive && raw == 0) + if (interactive && input_is_tty && raw == 0) print_ps2 = 1; } else @@ -479,7 +482,7 @@ read_builtin (list) if ((unsigned char)c == delim) break; - if ((skip_ctlesc == 0 && c == CTLESC) || c == CTLNUL) + if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL)) { saw_escape++; input_string[i++] = CTLESC; @@ -487,6 +490,15 @@ read_builtin (list) add_char: input_string[i++] = c; + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + { + input_string[i] = '\0'; /* for simplicity and debugging */ + i += read_mbchar (fd, input_string, i, c, unbuffered_read); + } +#endif + nr++; if (nchars > 0 && nr >= nchars) @@ -721,6 +733,54 @@ bind_read_variable (name, value) #endif /* !ARRAY_VARS */ } +#if defined (HANDLE_MULTIBYTE) +static int +read_mbchar (fd, string, ind, ch, unbuffered) + int fd; + char *string; + int ind, ch, unbuffered; +{ + char mbchar[MB_LEN_MAX + 1]; + int i, n, r; + char c; + size_t ret; + mbstate_t ps, ps_back; + wchar_t wc; + + memset (&ps, '\0', sizeof (mbstate_t)); + memset (&ps_back, '\0', sizeof (mbstate_t)); + + mbchar[0] = ch; + i = 1; + for (n = 0; n <= MB_LEN_MAX; n++) + { + ps_back = ps; + ret = mbrtowc (&wc, mbchar, i, &ps); + if (ret == (size_t)-2) + { + ps = ps_back; + if (unbuffered) + r = zread (fd, &c, 1); + else + r = zreadc (fd, &c); + if (r < 0) + goto mbchar_return; + mbchar[i++] = c; + continue; + } + else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0) + break; + } + +mbchar_return: + if (i > 1) /* read a multibyte char */ + /* mbchar[0] is already string[ind-1] */ + for (r = 1; r < i; r++) + string[ind+r-1] = mbchar[r]; + return i - 1; +} +#endif + #if defined (READLINE) static rl_completion_func_t *old_attempted_completion_function = 0; diff --git a/builtins/setattr.def b/builtins/setattr.def index 8507120b..a44bfde8 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -340,7 +340,7 @@ show_var_attributes (var, pattr, nodefs) reused as input to recreate the current state. */ if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0)) { - printf ("%s\n", named_function_string (var->name, function_cell (var), 1)); + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); nodefs++; if (pattr == 0 && i == 1 && flags[0] == 'f') return 0; /* don't print `declare -f name' */ @@ -363,7 +363,7 @@ show_var_attributes (var, pattr, nodefs) if (nodefs || (function_p (var) && pattr != 0 && posixly_correct)) printf ("%s\n", var->name); else if (function_p (var)) - printf ("%s\n", named_function_string (var->name, function_cell (var), 1)); + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); else if (invisible_p (var)) printf ("%s\n", var->name); else diff --git a/builtins/setattr.def~ b/builtins/setattr.def~ index 90f8dcc8..72bde0d1 100644 --- a/builtins/setattr.def~ +++ b/builtins/setattr.def~ @@ -1,7 +1,7 @@ This file is setattr.def, from which is created setattr.c. It implements the builtins "export" and "readonly", in Bash. -Copyright (C) 1987-2006 Free Software Foundation, Inc. +Copyright (C) 1987-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -52,7 +52,7 @@ extern int declare_builtin __P((WORD_LIST *)); $BUILTIN export $FUNCTION export_builtin -$SHORT_DOC export [-nf] [name[=value] ...] or export -p +$SHORT_DOC export [-fn] [name[=value] ...] or export -p NAMEs are marked for automatic export to the environment of subsequently executed commands. If the -f option is given, the NAMEs refer to functions. If no NAMEs are given, or if `-p' @@ -268,7 +268,11 @@ set_or_show_attributes (list, attribute, nodefs) continue; #endif if ((var->attributes & attribute)) - show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + { + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + if (any_failed = sh_chkwrite (any_failed)) + break; + } } free (variable_list); } @@ -336,7 +340,7 @@ show_var_attributes (var, pattr, nodefs) reused as input to recreate the current state. */ if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0)) { - printf ("%s\n", named_function_string (var->name, function_cell (var), 1)); + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE)); nodefs++; if (pattr == 0 && i == 1 && flags[0] == 'f') return 0; /* don't print `declare -f name' */ @@ -359,7 +363,7 @@ show_var_attributes (var, pattr, nodefs) if (nodefs || (function_p (var) && pattr != 0 && posixly_correct)) printf ("%s\n", var->name); else if (function_p (var)) - printf ("%s\n", named_function_string (var->name, function_cell (var), 1)); + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE)); else if (invisible_p (var)) printf ("%s\n", var->name); else diff --git a/builtins/type.def b/builtins/type.def index 370e596c..fa40ad25 100644 --- a/builtins/type.def +++ b/builtins/type.def @@ -1,7 +1,7 @@ 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-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -266,18 +266,14 @@ describe_command (command, dflags) 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... */ - 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); -#undef PRETTY_PRINT_FUNC } else if (dflags & CDESC_REUSABLE) printf ("%s\n", command); diff --git a/builtins/type.def~ b/builtins/type.def~ index d03ccb2d..54801235 100644 --- a/builtins/type.def~ +++ b/builtins/type.def~ @@ -1,7 +1,7 @@ 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-2007 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -185,9 +185,8 @@ type_builtin (list) list = list->next; } - fflush (stdout); - - return ((successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + opt = (successful_finds != 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE; + return (sh_chkwrite (opt)); } /* @@ -267,18 +266,14 @@ describe_command (command, dflags) 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... */ - result = named_function_string (command, - (COMMAND *) function_cell (func), - PRETTY_PRINT_FUNC); + result = named_function_string (command, function_cell (func), FUNC_MULTILINE); printf ("%s\n", result); -#undef PRETTY_PRINT_FUNC } else if (dflags & CDESC_REUSABLE) printf ("%s\n", command); @@ -390,7 +385,7 @@ describe_command (command, dflags) 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); |