From: Chet Ramey Date: Tue, 13 May 2014 20:19:02 +0000 (-0400) Subject: commit bash-20140502 snapshot X-Git-Tag: bash-4.4-alpha~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=098cbb5c3d196ffc19434b1977a9a3e08bd2a540;p=thirdparty%2Fbash.git commit bash-20140502 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 674ec46cb..093972317 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -6185,11 +6185,48 @@ bashline.c 4/27 ---- subst.c - - parameter_brace_expand_indir: if parameter_brace_find_indir returns - NULL or "", report an error and return &expand_param_error so the - error can propagate up - parameter_brace_expand_rhs: if parameter_brace_find_indir returns NULL or "", or if it returns something that is not a valid identifier, report an error and return &expand_wdesc_error so the error can propagate up. Fixes bug reported by Andre Holzhey + + 4/29 + ---- +subst.c + - parameter_brace_substring: don't short-circuit right away if the + value is NULL but we are looking at the positional parameters. Part + of fix for bug reported by Pierre Gaston + - pos_params: if there are no positional parameters, only short-circuit + if we are looking for $1 and above. Rest of fix for bug reported + by Pierre Gaston + +subst.h + - SD_NOPROCSUB: new flag for skip_to_delim, means to not allow any + process subsitutions (should not have overloaded SD_NOSKIPCMD) + +subst.c + - skip_to_delim: honor SD_NOPROCSUB flag + +make_cmd.c + - make_arith_for_expr: set W_NOPROCSUB flag in the created word + - make_arith_for_command: set SD_NOPROCSUB in the flags argument to + skip_to_delim so we don't treat <( or >( as a process substitution + (we won't evaluate them in eval_arith_for_expr anyway). Fixes + bug reported by Pierre Gaston + + 5/1 + --- +lib/glob/gmisc.c + - glob_dirscan: new function, takes a pattern and a directory separator + argument and advances the pattern to the last occurrence of the + separator. Like strrchr, but understands extended glob patterns and + uses glob_patscan to skip over them + +lib/glob/glob.c + - extglob_skipname: if the extended globbing pattern is invalid, don't + skip the name + - glob_filename: if there is a slash in the pattern to be matched, and + extglob is enabled, use glob_dirscan to find the real last occurrence + of `/' to avoid being confused by slashes in extglob patterns. Fix + for bug reported by Pierre Gaston diff --git a/CWRU/POSIX.NOTES.old b/CWRU/POSIX.NOTES.old new file mode 100644 index 000000000..1707ab10c --- /dev/null +++ b/CWRU/POSIX.NOTES.old @@ -0,0 +1,82 @@ +Starting bash with the `--posix' command-line option or executing +`set -o posix' while bash is running will cause bash to conform more +closely to the Posix.2 standard by changing the behavior to match that +specified by Posix.2 in areas where the bash default differs. + +The following list is what's changed when `posix mode' is in effect: + +1. When a command in the hash table no longer exists, bash will re-search + $PATH to find the new location. This is also available with + `shopt -s checkhash'. + +2. The >& redirection does not redirect stdout and stderr. + +3. The message printed by the job control code and builtins when a job + exits with a non-zero status is `Done(status)'. + +4. Reserved words may not be aliased. + +5. The Posix.2 PS1 and PS2 expansions of `!' -> history number and + `!!' -> `!' are enabled, and parameter expansion is performed on + the value regardless of the setting of the `promptvars' option. + +6. Interactive comments are enabled by default. (Note that bash has + them on by default anyway.) + +7. The Posix.2 startup files are executed ($ENV) rather than the normal + bash files. + +8. Tilde expansion is only performed on assignments preceding a command + name, rather than on all assignment statements on the line. + +9. The default history file is ~/.sh_history (default value of $HISTFILE). + +10. The output of `kill -l' prints all the signal names on a single line, + separated by spaces. + +11. Non-interactive shells exit if `file' in `. file' is not found. + +12. Redirection operators do not perform pathname expansion on the word + in the redirection unless the shell is interactive + +13. Function names must be valid shell identifiers. That is, they may not + contain characters other than letters, digits, and underscores, and + may not start with a digit. Declaring a function with an illegal name + causes a fatal syntax error in non-interactive shells. + +14. Posix.2 `special' builtins are found before shell functions during command + lookup. + +15. If a Posix.2 special builtin returns an error status, a non-interactive + shell exits. The fatal errors are those listed in the POSIX.2 standard, + and include things like passing incorrect options, redirection errors, + variable assignment errors for assignments preceding the command name, + and so on. + +16. The environment passed to executed commands is not sorted. Neither is + the output of `set'. This is not strictly Posix.2 behavior, but sh + does it this way. Ksh does not. It's not necessary to sort the + environment; no program should rely on it being sorted. + +17. If the `cd' builtin finds a directory to change to using $CDPATH, the + value it assigns to $PWD does not contain any symbolic links, as if + `cd -P' had been executed. + +18. A non-interactive shell exits with an error status if a variable + assignment error occurs when no command name follows the assignment + statements. A variable assignment error occurs, for example, when + trying to assign a value to a read-only variable. + +19. A non-interactive shell exits with an error status if the iteration + variable in a for statement or the selection variable in a select + statement is a read-only variable. + +20. Process substitution is not available. + +21. Assignment statements preceding POSIX.2 `special' builtins persist in + the shell environment after the builtin completes. + +There is other Posix.2 behavior that bash does not implement. Specifically: + +1. Assignment statements affect the execution environment of all builtins, + not just special ones. diff --git a/CWRU/old/set.def.save b/CWRU/old/set.def.save new file mode 100644 index 000000000..87b78d7cc --- /dev/null +++ b/CWRU/old/set.def.save @@ -0,0 +1,544 @@ +This file is set.def, from which is created set.c. +It implements the "set" and "unset" builtins in Bash. + +Copyright (C) 1987, 1989, 1991 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. + +$PRODUCES set.c + +#include +#include "../shell.h" +#include "../flags.h" + +#include "bashgetopt.h" + +extern int interactive; +extern int noclobber, posixly_correct; +#if defined (READLINE) +extern int rl_editing_mode, no_line_editing; +#endif /* READLINE */ + +$BUILTIN set +$FUNCTION set_builtin +$SHORT_DOC set [--abefhkmnptuvxldBCHP] [-o option] [arg ...] + -a Mark variables which are modified or created for export. + -b Notify of job termination immediately. + -e Exit immediately if a command exits with a non-zero status. + -f Disable file name generation (globbing). + -h Locate and remember function commands as functions are + defined. Function commands are normally looked up when + the function is executed. + -i Force the shell to be an "interactive" one. Interactive shells + always read `~/.bashrc' on startup. + -k All keyword arguments are placed in the environment for a + command, not just those that precede the command name. + -m Job control is enabled. + -n Read commands but do not execute them. + -o option-name + Set the variable corresponding to option-name: + allexport same as -a + braceexpand same as -B +#if defined (READLINE) + emacs use an emacs-style line editing interface +#endif /* READLINE */ + errexit same as -e + histexpand same as -H + ignoreeof the shell will not exit upon reading EOF + interactive-comments + allow comments to appear in interactive commands + monitor same as -m + noclobber disallow redirection to existing files + noexec same as -n + noglob same as -f + nohash same as -d + notify save as -b + nounset same as -u + physical same as -P + posix change the behavior of bash where the default + operation differs from the 1003.2 standard to + match the standard + privileged same as -p + verbose same as -v +#if defined (READLINE) + vi use a vi-style line editing interface +#endif /* READLINE */ + xtrace same as -x + -p Turned on whenever the real and effective user ids do not match. + Disables processing of the $ENV file and importing of shell + functions. Turning this option off causes the effective uid and + gid to be set to the real uid and gid. + -t Exit after reading and executing one command. + -u Treat unset variables as an error when substituting. + -v Print shell input lines as they are read. + -x Print commands and their arguments as they are executed. + -l Save and restore the binding of the NAME in a FOR command. + -d Disable the hashing of commands that are looked up for execution. + Normally, commands are remembered in a hash table, and once + found, do not have to be looked up again. +#if defined (BRACE_EXPANSION) + -B the shell will perform brace expansion +#endif /* BRACE_EXPANSION */ +#if defined (BANG_HISTORY) + -H Enable ! style history substitution. This flag is on + by default. +#endif /* BANG_HISTORY */ + -C If set, disallow existing regular files to be overwritten + by redirection of output. + -P If set, do not follow symbolic links when executing commands + such as cd which change the current directory. + +Using + rather than - causes these flags to be turned off. The +flags can also be used upon invocation of the shell. The current +set of flags may be found in $-. The remaining n ARGs are positional +parameters and are assigned, in order, to $1, $2, .. $n. If no +ARGs are given, all shell variables are printed. +$END + +/* An a-list used to match long options for set -o to the corresponding + option letter. */ +struct { + char *name; + int letter; +} o_options[] = { + { "allexport", 'a' }, +#if defined (BRACE_EXPANSION) + { "braceexpand",'B' }, +#endif + { "errexit", 'e' }, + { "histexpand", 'H' }, + { "monitor", 'm' }, + { "noexec", 'n' }, + { "noglob", 'f' }, + { "nohash", 'd' }, +#if defined (JOB_CONTROL) + { "notify", 'b' }, +#endif /* JOB_CONTROL */ + {"nounset", 'u' }, + {"physical", 'P' }, + {"privileged", 'p' }, + {"verbose", 'v' }, + {"xtrace", 'x' }, + {(char *)NULL, 0}, +}; + +#define MINUS_O_FORMAT "%-15s\t%s\n" + +void +list_minus_o_opts () +{ + register int i; + char *on = "on", *off = "off"; + + printf (MINUS_O_FORMAT, "noclobber", (noclobber == 1) ? on : off); + + if (find_variable ("ignoreeof") || find_variable ("IGNOREEOF")) + printf (MINUS_O_FORMAT, "ignoreeof", on); + else + printf (MINUS_O_FORMAT, "ignoreeof", off); + + printf (MINUS_O_FORMAT, "interactive-comments", + interactive_comments ? on : off); + + printf (MINUS_O_FORMAT, "posix", posixly_correct ? on : off); + +#if defined (READLINE) + if (no_line_editing) + { + printf (MINUS_O_FORMAT, "emacs", off); + printf (MINUS_O_FORMAT, "vi", off); + } + else + { + /* Magic. This code `knows' how readline handles rl_editing_mode. */ + printf (MINUS_O_FORMAT, "emacs", (rl_editing_mode == 1) ? on : off); + printf (MINUS_O_FORMAT, "vi", (rl_editing_mode == 0) ? on : off); + } +#endif /* READLINE */ + + for (i = 0; o_options[i].name; i++) + { + int *on_or_off, zero = 0; + + on_or_off = find_flag (o_options[i].letter); + if (on_or_off == FLAG_UNKNOWN) + on_or_off = &zero; + printf (MINUS_O_FORMAT, o_options[i].name, (*on_or_off == 1) ? on : off); + } +} + +set_minus_o_option (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + int option_char = -1; + + if (STREQ (option_name, "noclobber")) + { + if (on_or_off == FLAG_ON) + bind_variable ("noclobber", ""); + else + unbind_variable ("noclobber"); + stupidly_hack_special_variables ("noclobber"); + } + else if (STREQ (option_name, "ignoreeof")) + { + unbind_variable ("ignoreeof"); + unbind_variable ("IGNOREEOF"); + if (on_or_off == FLAG_ON) + bind_variable ("IGNOREEOF", "10"); + stupidly_hack_special_variables ("IGNOREEOF"); + } + +#if defined (READLINE) + else if ((STREQ (option_name, "emacs")) || (STREQ (option_name, "vi"))) + { + if (on_or_off == FLAG_ON) + { + rl_variable_bind ("editing-mode", option_name); + + if (interactive) + with_input_from_stdin (); + no_line_editing = 0; + } + else + { + int isemacs = (rl_editing_mode == 1); + if ((isemacs && STREQ (option_name, "emacs")) || + (!isemacs && STREQ (option_name, "vi"))) + { + if (interactive) + with_input_from_stream (stdin, "stdin"); + no_line_editing = 1; + } + else + builtin_error ("not in %s editing mode", option_name); + } + } +#endif /* READLINE */ + else if (STREQ (option_name, "interactive-comments")) + interactive_comments = (on_or_off == FLAG_ON); + else if (STREQ (option_name, "posix")) + { + posixly_correct = (on_or_off == FLAG_ON); + unbind_variable ("POSIXLY_CORRECT"); + unbind_variable ("POSIX_PEDANTIC"); + if (on_or_off == FLAG_ON) + { + bind_variable ("POSIXLY_CORRECT", ""); + stupidly_hack_special_variables ("POSIXLY_CORRECT"); + } + } + else + { + register int i; + for (i = 0; o_options[i].name; i++) + { + if (STREQ (option_name, o_options[i].name)) + { + option_char = o_options[i].letter; + break; + } + } + if (option_char == -1) + { + builtin_error ("%s: unknown option name", option_name); + return (EXECUTION_FAILURE); + } + if (change_flag (option_char, on_or_off) == FLAG_ERROR) + { + bad_option (option_name); + return (EXECUTION_FAILURE); + } + } + return (EXECUTION_SUCCESS); +} + +/* Set some flags from the word values in the input list. If LIST is empty, + then print out the values of the variables instead. If LIST contains + non-flags, then set $1 - $9 to the successive words of LIST. */ +set_builtin (list) + WORD_LIST *list; +{ + int on_or_off, flag_name, force_assignment = 0; + + if (!list) + { + SHELL_VAR **vars; + + vars = all_shell_variables (); + if (vars) + { + print_var_list (vars); + free (vars); + } + + vars = all_shell_functions (); + if (vars) + { + print_var_list (vars); + free (vars); + } + + return (EXECUTION_SUCCESS); + } + + /* Check validity of flag arguments. */ + if (*list->word->word == '-' || *list->word->word == '+') + { + register char *arg; + WORD_LIST *save_list = list; + + while (list && (arg = list->word->word)) + { + char c; + + if (arg[0] != '-' && arg[0] != '+') + break; + + /* `-' or `--' signifies end of flag arguments. */ + if (arg[0] == '-' && + (!arg[1] || (arg[1] == '-' && !arg[2]))) + break; + + while (c = *++arg) + { + if (find_flag (c) == FLAG_UNKNOWN && c != 'o') + { + char s[2]; + s[0] = c; s[1] = '\0'; + bad_option (s); + if (c == '?') + builtin_usage (); + return (c == '?' ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + } + list = list->next; + } + list = save_list; + } + + /* Do the set command. While the list consists of words starting with + '-' or '+' treat them as flags, otherwise, start assigning them to + $1 ... $n. */ + while (list) + { + char *string = list->word->word; + + /* If the argument is `--' or `-' then signal the end of the list + and remember the remaining arguments. */ + if (string[0] == '-' && (!string[1] || (string[1] == '-' && !string[2]))) + { + list = list->next; + + /* `set --' unsets the positional parameters. */ + if (string[1] == '-') + force_assignment = 1; + + /* Until told differently, the old shell behaviour of + `set - [arg ...]' being equivalent to `set +xv [arg ...]' + stands. Posix.2 says the behaviour is marked as obsolescent. */ + else + { + change_flag ('x', '+'); + change_flag ('v', '+'); + } + + break; + } + + if ((on_or_off = *string) && + (on_or_off == '-' || on_or_off == '+')) + { + int i = 1; + while (flag_name = string[i++]) + { + if (flag_name == '?') + { + builtin_usage (); + return (EXECUTION_SUCCESS); + } + else if (flag_name == 'o') /* -+o option-name */ + { + char *option_name; + WORD_LIST *opt; + + opt = list->next; + + if (!opt) + { + list_minus_o_opts (); + continue; + } + + option_name = opt->word->word; + + if (!option_name || !*option_name || (*option_name == '-')) + { + list_minus_o_opts (); + continue; + } + list = list->next; /* Skip over option name. */ + + if (set_minus_o_option (on_or_off, option_name) != EXECUTION_SUCCESS) + return (EXECUTION_FAILURE); + } + else + { + if (change_flag (flag_name, on_or_off) == FLAG_ERROR) + { + char opt[3]; + opt[0] = on_or_off; + opt[1] = flag_name; + opt[2] = '\0'; + bad_option (opt); + builtin_usage (); + return (EXECUTION_FAILURE); + } + } + } + } + else + { + break; + } + list = list->next; + } + + /* Assigning $1 ... $n */ + if (list || force_assignment) + remember_args (list, 1); + return (EXECUTION_SUCCESS); +} + +$BUILTIN unset +$FUNCTION unset_builtin +$SHORT_DOC unset [-f] [-v] [name ...] +For each NAME, remove the corresponding variable or function. Given +the `-v', unset will only act on variables. Given the `-f' flag, +unset will only act on functions. With neither flag, unset first +tries to unset a variable, and if that fails, then tries to unset a +function. Some variables (such as PATH and IFS) cannot be unset; also +see readonly. +$END + +#define NEXT_VARIABLE() any_failed++; list = list->next; continue; + +unset_builtin (list) + WORD_LIST *list; +{ + int unset_function, unset_variable, unset_array, opt, any_failed; + char *name; + + unset_function = unset_variable = unset_array = any_failed = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "fv")) != -1) + { + switch (opt) + { + case 'f': + unset_function = 1; + break; + case 'v': + unset_variable = 1; + break; + default: + builtin_usage (); + return (EXECUTION_FAILURE); + } + } + + list = loptend; + + if (unset_function && unset_variable) + { + builtin_error ("cannot simultaneously unset a function and a variable"); + return (EXECUTION_FAILURE); + } + + while (list) + { + SHELL_VAR *var; + int tem; +#if defined (ARRAY_VARS) + char *t; +#endif + + name = list->word->word; + +#if defined (ARRAY_VARS) + if (!unset_function && valid_array_reference (name)) + { + t = strchr (name, '['); + *t++ = '\0'; + unset_array++; + } +#endif + + var = unset_function ? find_function (name) : find_variable (name); + + if (var && !unset_function && non_unsettable_p (var)) + { + builtin_error ("%s: cannot unset", name); + NEXT_VARIABLE (); + } + + /* Posix.2 says that unsetting readonly variables is an error. */ + if (var && readonly_p (var)) + { + builtin_error ("%s: cannot unset: readonly %s", + name, unset_function ? "function" : "variable"); + NEXT_VARIABLE (); + } + + /* Unless the -f option is supplied, the name refers to a variable. */ +#if defined (ARRAY_VARS) + if (var && unset_array) + { + if (array_p (var) == 0) + { + builtin_error ("%s: not an array variable", name); + NEXT_VARIABLE (); + } + else + tem = unbind_array_element (var, t); + } + else +#endif /* ARRAY_VARS */ + tem = makunbound (name, unset_function ? shell_functions : shell_variables); + + /* This is what Posix.2 draft 11+ says. ``If neither -f nor -v + is specified, the name refers to a variable; if a variable by + that name does not exist, a function by that name, if any, + shall be unset.'' */ + if ((tem == -1) && !unset_function && !unset_variable) + tem = makunbound (name, shell_functions); + + if (tem == -1) + any_failed++; + else if (!unset_function) + stupidly_hack_special_variables (name); + + list = list->next; + } + + if (any_failed) + return (EXECUTION_FAILURE); + else + return (EXECUTION_SUCCESS); +} diff --git a/CWRU/save/unwind_prot.h.save b/CWRU/save/unwind_prot.h.save new file mode 100644 index 000000000..998fd72b6 --- /dev/null +++ b/CWRU/save/unwind_prot.h.save @@ -0,0 +1,50 @@ +/* unwind_prot.h - Macros and functions for hacking unwind protection. */ + +/* Copyright (C) 1993 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if !defined (_UNWIND_PROT_H) +#define _UNWIND_PROT_H + +/* Run a function without interrupts. */ +extern void begin_unwind_frame (); +extern void discard_unwind_frame (); +extern void run_unwind_frame (); +extern void add_unwind_protect (); +extern void remove_unwind_protect (); +extern void run_unwind_protects (); +extern void unwind_protect_var (); + +/* Define for people who like their code to look a certain way. */ +#define end_unwind_frame() + +/* How to protect an integer. */ +#define unwind_protect_int(X) unwind_protect_var (&(X), (char *)(X), sizeof (int)) + +/* How to protect a pointer to a string. */ +#define unwind_protect_string(X) \ + unwind_protect_var ((int *)&(X), (X), sizeof (char *)) + +/* How to protect any old pointer. */ +#define unwind_protect_pointer(X) unwind_protect_string (X) + +/* How to protect the contents of a jmp_buf. */ +#define unwind_protect_jmp_buf(X) \ + unwind_protect_var ((int *)(X), (char *)(X), sizeof (procenv_t)) + +#endif /* _UNWIND_PROT_H */ diff --git a/builtins/shopt.def b/builtins/shopt.def index 6050a14d7..55d454376 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -180,8 +180,8 @@ static struct { #if defined (READLINE) { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL }, #endif - { "globstar", &glob_star, (shopt_set_func_t *)NULL }, { "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL }, + { "globstar", &glob_star, (shopt_set_func_t *)NULL }, { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL }, #if defined (HISTORY) { "histappend", &force_append_history, (shopt_set_func_t *)NULL }, diff --git a/cross-build/cygwin32.cache.old b/cross-build/cygwin32.cache.old new file mode 100644 index 000000000..640390fbf --- /dev/null +++ b/cross-build/cygwin32.cache.old @@ -0,0 +1,42 @@ +# This file is a shell script that caches the results of configure +# tests for CYGWIN32 so they don't need to be done when cross-compiling. + +# AC_FUNC_GETPGRP should also define GETPGRP_VOID +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} +# AC_FUNC_SETVBUF_REVERSED should not define anything else +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} +# on CYGWIN32, system calls do not restart +ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'} +bash_cv_sys_restartable_syscalls=${bash_cv_sys_restartable_syscalls='no'} + +# these may be necessary, but they are currently commented out +#ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} +ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} +ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} +ac_cv_sizeof_double=${ac_cv_sizeof_double='8'} + +bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} +bash_cv_type_rlimit=${bash_cv_type_rlimit='long'} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} +bash_cv_sys_siglist=${bash_cv_sys_siglist='no'} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} +bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} +bash_cv_printf_declared=${bash_cv_printf_declared='yes'} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} +bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen='no'} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} +bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='missing'} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='missing'} +bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} + +bash_cv_type_int32_t=${bash_cv_type_int32_t='int'} +bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'} + +ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'} + +# end of cross-build/cygwin32.cache diff --git a/doc/FAQ.orig b/doc/FAQ.orig new file mode 100644 index 000000000..1cff3c8ef --- /dev/null +++ b/doc/FAQ.orig @@ -0,0 +1,1745 @@ +This is the Bash FAQ, version 3.24, for Bash version 2.05b. + +This document contains a set of frequently-asked questions concerning +Bash, the GNU Bourne-Again Shell. Bash is a freely-available command +interpreter with advanced features for both interactive use and shell +programming. + +Another good source of basic information about shells is the collection +of FAQ articles periodically posted to comp.unix.shell. + +Questions and comments concerning this document should be sent to +chet@po.cwru.edu. + +This document is available for anonymous FTP with the URL + +ftp://ftp.cwru.edu/pub/bash/FAQ + +The Bash home page is http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html + +---------- +Contents: + +Section A: The Basics + +A1) What is it? +A2) What's the latest version? +A3) Where can I get it? +A4) On what machines will bash run? +A5) Will bash run on operating systems other than Unix? +A6) How can I build bash with gcc? +A7) How can I make bash my login shell? +A8) I just changed my login shell to bash, and now I can't FTP into my + machine. Why not? +A9) What's the `POSIX 1003.2 standard'? +A10) What is the bash `posix mode'? + +Section B: The latest version + +B1) What's new in version 2.05b? +B2) Are there any user-visible incompatibilities between bash-2.05b and + bash-1.14.7? + +Section C: Differences from other Unix shells + +C1) How does bash differ from sh, the Bourne shell? +C2) How does bash differ from the Korn shell, version ksh88? +C3) Which new features in ksh-93 are not in bash, and which are? + +Section D: Why does bash do some things differently than other Unix shells? + +D1) Why does bash run a different version of `command' than + `which command' says it will? +D2) Why doesn't bash treat brace expansions exactly like csh? +D3) Why doesn't bash have csh variable modifiers? +D4) How can I make my csh aliases work when I convert to bash? +D5) How can I pipe standard output and standard error from one command to + another, like csh does with `|&'? +D6) Now that I've converted from ksh to bash, are there equivalents to + ksh features like autoloaded functions and the `whence' command? + +Section E: Why does bash do certain things the way it does? + +E1) Why is the bash builtin `test' slightly different from /bin/test? +E2) Why does bash sometimes say `Broken pipe'? +E3) When I have terminal escape sequences in my prompt, why does bash + wrap lines at the wrong column? +E4) If I pipe the output of a command into `read variable', why doesn't + the output show up in $variable when the read command finishes? +E5) I have a bunch of shell scripts that use backslash-escaped characters + in arguments to `echo'. Bash doesn't interpret these characters. Why + not, and how can I make it understand them? +E6) Why doesn't a while or for loop get suspended when I type ^Z? +E7) What about empty for loops in Makefiles? +E8) Why does the arithmetic evaluation code complain about `08'? +E9) Why does the pattern matching expression [A-Z]* match files beginning + with every letter except `z'? +E10) Why does `cd //' leave $PWD as `//'? +E11) If I resize my xterm while another program is running, why doesn't bash + notice the change? + +Section F: Things to watch out for on certain Unix versions + +F1) Why can't I use command line editing in my `cmdtool'? +F2) I built bash on Solaris 2. Why do globbing expansions and filename + completion chop off the first few characters of each filename? +F3) Why does bash dump core after I interrupt username completion or + `~user' tilde expansion on a machine running NIS? +F4) I'm running SVR4.2. Why is the line erased every time I type `@'? +F5) Why does bash report syntax errors when my C News scripts use a + redirection before a subshell command? +F6) Why can't I use vi-mode editing on Red Hat Linux 6.1? +F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on + HP/UX 11.x? + +Section G: How can I get bash to do certain common things? + +G1) How can I get bash to read and display eight-bit characters? +G2) How do I write a function `x' to replace builtin command `x', but + still invoke the command from within the function? +G3) How can I find the value of a shell variable whose name is the value + of another shell variable? +G4) How can I make the bash `time' reserved word print timing output that + looks like the output from my system's /usr/bin/time? +G5) How do I get the current directory into my prompt? +G6) How can I rename "*.foo" to "*.bar"? +G7) How can I translate a filename from uppercase to lowercase? +G8) How can I write a filename expansion (globbing) pattern that will match + all files in the current directory except "." and ".."? + +Section H: Where do I go from here? + +H1) How do I report bugs in bash, and where should I look for fixes and + advice? +H2) What kind of bash documentation is there? +H3) What's coming in future versions? +H4) What's on the bash `wish list'? +H5) When will the next release appear? + +---------- +Section A: The Basics + +A1) What is it? + +Bash is a Unix command interpreter (shell). It is an implementation of +the Posix 1003.2 shell standard, and resembles the Korn and System V +shells. + +Bash contains a number of enhancements over those shells, both +for interactive use and shell programming. Features geared +toward interactive use include command line editing, command +history, job control, aliases, and prompt expansion. Programming +features include additional variable expansions, shell +arithmetic, and a number of variables and options to control +shell behavior. + +Bash was originally written by Brian Fox of the Free Software +Foundation. The current developer and maintainer is Chet Ramey +of Case Western Reserve University. + +A2) What's the latest version? + +The latest version is 2.05b, first made available on Wednesday, 17 +July, 2002. + +A3) Where can I get it? + +Bash is the GNU project's shell, and so is available from the +master GNU archive site, ftp.gnu.org, and its mirrors. The +latest version is also available for FTP from ftp.cwru.edu. +The following URLs tell how to get version 2.05b: + +ftp://ftp.gnu.org/pub/gnu/bash/bash-2.05b.tar.gz +ftp://ftp.cwru.edu/pub/bash/bash-2.05b.tar.gz + +Formatted versions of the documentation are available with the URLs: + +ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.05b.tar.gz +ftp://ftp.cwru.edu/pub/bash/bash-doc-2.05b.tar.gz + +A4) On what machines will bash run? + +Bash has been ported to nearly every version of UNIX. All you +should have to do to build it on a machine for which a port +exists is to type `configure' and then `make'. The build process +will attempt to discover the version of UNIX you have and tailor +itself accordingly, using a script created by GNU autoconf. + +More information appears in the file `INSTALL' in the distribution. + +The Bash web page (http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html) +explains how to obtain binary versions of bash for most of the major +commercial Unix systems. + +A5) Will bash run on operating systems other than Unix? + +Configuration specifics for Unix-like systems such as QNX and +LynxOS are included in the distribution. Bash-2.05 and later +versions should compile and run on Minix 2.0 (patches were +contributed), but I don't believe anyone has built bash-2.x on +earlier Minix versions yet. + +Bash has been ported to versions of Windows implementing the Win32 +programming interface. This includes Windows 95 and Windows NT. +The port was done by Cygnus Solutions as part of their CYGWIN +project. For more information about the project, look at the URLs + +http://www.cygwin.com/ +http://sourceware.cygnus.com/cygwin + +Cygnus originally ported bash-1.14.7, and that port was part of their +early GNU-Win32 (the original name) releases. Cygnus has also done a +port of bash-2.05 to the CYGWIN environment, and it is available as +part of their current release. + +Bash-2.05b should require no local Cygnus changes to build and run under +CYGWIN. + +The Cygnus port works only on Intel machines. There is a port of bash +(I don't know which version) to the alpha/NT environment available from + +ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz + +DJ Delorie has a port of bash-2.x which runs under MS-DOS, as part +of the DJGPP project. For more information on the project, see + +http://www.delorie.com/djgpp/ + +I have been told that the original DJGPP port was done by Daisuke Aoyama. + +Mark Elbrecht has sent me notice that bash-2.04 +is available for DJGPP V2. The files are available as: + +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204b.zip binary +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204d.zip documentation +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204s.zip source + +Mark has begun to work with bash-2.05, but I don't know the status. + +Ports of bash-1.12 and bash-2.0 are available for OS/2 from + +ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash_112.zip +ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash-2.0(253).zip + +I haven't looked at either, but the second appears to be a binary-only +distribution. Beware. + +I have received word that Bash (I'm not sure which version, but I +believe that it's at least bash-2.02.1) is the standard shell on +BeOS. + +A6) How can I build bash with gcc? + +Bash configures to use gcc by default if it is available. Read the +file INSTALL in the distribution for more information. + +A7) How can I make bash my login shell? + +Some machines let you use `chsh' to change your login shell. Other +systems use `passwd -s' or `passwd -e'. If one of these works for +you, that's all you need. Note that many systems require the full +pathname to a shell to appear in /etc/shells before you can make it +your login shell. For this, you may need the assistance of your +friendly local system administrator. + +If you cannot do this, you can still use bash as your login shell, but +you need to perform some tricks. The basic idea is to add a command +to your login shell's startup file to replace your login shell with +bash. + +For example, if your login shell is csh or tcsh, and you have installed +bash in /usr/gnu/bin/bash, add the following line to ~/.login: + + if ( -f /usr/gnu/bin/bash ) exec /usr/gnu/bin/bash --login + +(the `--login' tells bash that it is a login shell). + +It's not a good idea to put this command into ~/.cshrc, because every +csh you run without the `-f' option, even ones started to run csh scripts, +reads that file. If you must put the command in ~/.cshrc, use something +like + + if ( $?prompt ) exec /usr/gnu/bin/bash --login + +to ensure that bash is exec'd only when the csh is interactive. + +If your login shell is sh or ksh, you have to do two things. + +First, create an empty file in your home directory named `.bash_profile'. +The existence of this file will prevent the exec'd bash from trying to +read ~/.profile, and re-execing itself over and over again. ~/.bash_profile +is the first file bash tries to read initialization commands from when +it is invoked as a login shell. + +Next, add a line similar to the above to ~/.profile: + + [ -f /usr/gnu/bin/bash ] && [ -x /usr/gnu/bin/bash ] && \ + exec /usr/gnu/bin/bash --login + +This will cause login shells to replace themselves with bash running as +a login shell. Once you have this working, you can copy your initialization +code from ~/.profile to ~/.bash_profile. + +I have received word that the recipe supplied above is insufficient for +machines running CDE. CDE has a maze of twisty little startup files, all +slightly different. + +If you cannot change your login shell in the password file to bash, you +will have to (apparently) live with CDE using the shell in the password +file to run its startup scripts. If you have changed your shell to bash, +there is code in the CDE startup files (on Solaris, at least) that attempts +to do the right thing. It is, however, often broken, and may require that +you use the $BASH_ENV trick described below. + +`dtterm' claims to use $SHELL as the default program to start, so if you +can change $SHELL in the CDE startup files, you should be able to use bash +in your terminal windows. + +Setting DTSOURCEPROFILE in ~/.dtprofile will cause the `Xsession' program +to read your login shell's startup files. You may be able to use bash for +the rest of the CDE programs by setting SHELL to bash in ~/.dtprofile as +well, but I have not tried this. + +You can use the above `exec' recipe to start bash when not logging in with +CDE by testing the value of the DT variable: + + if [ -n "$DT" ]; then + [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login + fi + +If CDE starts its shells non-interactively during login, the login shell +startup files (~/.profile, ~/.bash_profile) will not be sourced at login. +To get around this problem, append a line similar to the following to your +~/.dtprofile: + + BASH_ENV=${HOME}/.bash_profile ; export BASH_ENV + +and add the following line to the beginning of ~/.bash_profile: + + unset BASH_ENV + +A8) I just changed my login shell to bash, and now I can't FTP into my + machine. Why not? + +You must add the full pathname to bash to the file /etc/shells. As +noted in the answer to the previous question, many systems require +this before you can make bash your login shell. + +Most versions of ftpd use this file to prohibit `special' users +such as `uucp' and `news' from using FTP. + +A9) What's the `POSIX 1003.2 standard'? + +POSIX is a name originally coined by Richard Stallman for a +family of open system standards based on UNIX. There are a +number of aspects of UNIX under consideration for +standardization, from the basic system services at the system +call and C library level to applications and tools to system +administration and management. Each area of standardization is +assigned to a working group in the 1003 series. + +The POSIX Shell and Utilities standard has been developed by IEEE +Working Group 1003.2 (POSIX.2). It concentrates on the command +interpreter interface and utility programs commonly executed from +the command line or by other programs. An initial version of the +standard has been approved and published by the IEEE, and work is +currently underway to update it. + +Bash is concerned with the aspects of the shell's behavior +defined by POSIX.2. The shell command language has of course +been standardized, including the basic flow control and program +execution constructs, I/O redirection and pipelining, argument +handling, variable expansion, and quoting. + +The `special' builtins, which must be implemented as part of the +shell to provide the desired functionality, are specified as +being part of the shell; examples of these are `eval' and +`export'. Other utilities appear in the sections of POSIX.2 not +devoted to the shell which are commonly (and in some cases must +be) implemented as builtin commands, such as `read' and `test'. +POSIX.2 also specifies aspects of the shell's interactive +behavior as part of the UPE, including job control and command +line editing. Only vi-style line editing commands have been +standardized; emacs editing commands were left out due to +objections. + +The Open Group has made an older version of its Single Unix +Specification (version 2), which is very similar to POSIX.2, +available on the web at + +http://www.opengroup.org/onlinepubs/007908799/ + +The Single Unix Specification, version 3, is available on the web at + +http://www.opengroup.org/onlinepubs/007904975/ + +A10) What is the bash `posix mode'? + +Although bash is an implementation of the POSIX.2 shell +specification, there are areas where the bash default behavior +differs from that spec. The bash `posix mode' changes the bash +behavior in these areas so that it obeys the spec more closely. + +Posix mode is entered by starting bash with the --posix or +'-o posix' option or executing `set -o posix' after bash is running. + +The specific aspects of bash which change when posix mode is +active are listed in the file POSIX in the bash distribution. +They are also listed in a section in the Bash Reference Manual +(from which that file is generated). + +Section B: The latest version + +B1) What's new in version 2.05b? + +The raison d'etre for bash-2.05b is to make a second intermediate +release containing the first of the new features to be available +in bash-3.0 and get feedback on those features before proceeding. +The major new feature is multibyte character support in both Bash +and Readline. + +Bash-2.05b contains the following new features (see the manual page for +complete descriptions and the CHANGES and NEWS files in the bash-2.05b +distribution): + +o support for multibyte characters has been added to both bash and readline + +o the DEBUG trap is now run *before* simple commands, ((...)) commands, + [[...]] conditional commands, and for ((...)) loops + +o the shell now performs arithmetic in the largest integer size the machine + supports (intmax_t) + +o there is a new \D{...} prompt expansion; passes the `...' to strftime(3) + and inserts the result into the expanded prompt + +o there is a new `here-string' redirection operator: <<< word + +o when displaying variables, function attributes and definitions are shown + separately, allowing them to be re-used as input (attempting to re-use + the old output would result in syntax errors). + +o `read' has a new `-u fd' option to read from a specified file descriptor + +o the bash debugger in examples/bashdb has been modified to work with the + new DEBUG trap semantics, the command set has been made more gdb-like, + and the changes to $LINENO make debugging functions work better + +o the expansion of $LINENO inside a shell function is only relative to the + function start if the shell is interactive -- if the shell is running a + script, $LINENO expands to the line number in the script. This is as + POSIX-2001 requires + + +A short feature history dating from Bash-2.0: + +Bash-2.05a introduced the following new features: + +o The `printf' builtin has undergone major work + +o There is a new read-only `shopt' option: login_shell, which is set by + login shells and unset otherwise + +o New `\A' prompt string escape sequence; expanding to time in 24-hour + HH:MM format + +o New `-A group/-g' option to complete and compgen; goes group name + completion + +o New [+-]O invocation option to set and unset `shopt' options at startup + +o ksh-like `ERR' trap + +o `for' loops now allow empty word lists after the `in' reserved word + +o new `hard' and `soft' arguments for the `ulimit' builtin + +o Readline can be configured to place the user at the same point on the line + when retrieving commands from the history list + +o Readline can be configured to skip `hidden' files (filenames with a leading + `.' on Unix) when performing completion + +Bash-2.05 introduced the following new features: + +o This version has once again reverted to using locales and strcoll(3) when + processing pattern matching bracket expressions, as POSIX requires. +o Added a new `--init-file' invocation argument as a synonym for `--rcfile', + per the new GNU coding standards. +o The /dev/tcp and /dev/udp redirections now accept service names as well as + port numbers. +o `complete' and `compgen' now take a `-o value' option, which controls some + of the aspects of that compspec. Valid values are: + + default - perform bash default completion if programmable + completion produces no matches + dirnames - perform directory name completion if programmable + completion produces no matches + filenames - tell readline that the compspec produces filenames, + so it can do things like append slashes to + directory names and suppress trailing spaces +o A new loadable builtin, realpath, which canonicalizes and expands symlinks + in pathname arguments. +o When `set' is called without options, it prints function defintions in a + way that allows them to be reused as input. This affects `declare' and + `declare -p' as well. This only happens when the shell is not in POSIX + mode, since POSIX.2 forbids this behavior. + +Bash-2.04 introduced the following new features: + +o Programmable word completion with the new `complete' and `compgen' builtins; + examples are provided in examples/complete/complete-examples +o `history' has a new `-d' option to delete a history entry +o `bind' has a new `-x' option to bind key sequences to shell commands +o The prompt expansion code has new `\j' and `\l' escape sequences +o The `no_empty_cmd_completion' shell option, if enabled, inhibits + command completion when TAB is typed on an empty line +o `help' has a new `-s' option to print a usage synopsis +o New arithmetic operators: var++, var--, ++var, --var, expr1,expr2 (comma) +o New ksh93-style arithmetic for command: + for ((expr1 ; expr2; expr3 )); do list; done +o `read' has new options: `-t', `-n', `-d', `-s' +o The redirection code handles several filenames specially: /dev/fd/N, + /dev/stdin, /dev/stdout, /dev/stderr +o The redirection code now recognizes /dev/tcp/HOST/PORT and + /dev/udp/HOST/PORT and tries to open a TCP or UDP socket, respectively, + to the specified port on the specified host +o The ${!prefix*} expansion has been implemented +o A new FUNCNAME variable, which expands to the name of a currently-executing + function +o The GROUPS variable is no longer readonly +o A new shopt `xpg_echo' variable, to control the behavior of echo with + respect to backslash-escape sequences at runtime +o The NON_INTERACTIVE_LOGIN_SHELLS #define has returned + +The version of Readline released with Bash-2.04, Readline-4.1, had several +new features as well: + +o Parentheses matching is always compiled into readline, and controllable + with the new `blink-matching-paren' variable +o The history-search-forward and history-search-backward functions now leave + point at the end of the line when the search string is empty, like + reverse-search-history, and forward-search-history +o A new function for applications: rl_on_new_line_with_prompt() +o New variables for applications: rl_already_prompted, and rl_gnu_readline_p + + +Bash-2.03 had very few new features, in keeping with the convention +that odd-numbered releases provide mainly bug fixes. A number of new +features were added to Readline, mostly at the request of the Cygnus +folks. + +A new shopt option, `restricted_shell', so that startup files can test + whether or not the shell was started in restricted mode +Filename generation is now performed on the words between ( and ) in + compound array assignments (this is really a bug fix) +OLDPWD is now auto-exported, as POSIX.2 requires +ENV and BASH_ENV are read-only variables in a restricted shell +Bash may now be linked against an already-installed Readline library, + as long as the Readline library is version 4 or newer +All shells begun with the `--login' option will source the login shell + startup files, even if the shell is not interactive + +There were lots of changes to the version of the Readline library released +along with Bash-2.03. For a complete list of the changes, read the file +CHANGES in the Bash-2.03 distribution. + +Bash-2.02 contained the following new features: + +a new version of malloc (based on the old GNU malloc code in previous + bash versions) that is more page-oriented, more conservative + with memory usage, does not `orphan' large blocks when they + are freed, is usable on 64-bit machines, and has allocation + checking turned on unconditionally +POSIX.2-style globbing character classes ([:alpha:], [:alnum:], etc.) +POSIX.2-style globbing equivalence classes +POSIX.2-style globbing collating symbols +the ksh [[...]] extended conditional command +the ksh egrep-style extended pattern matching operators +a new `printf' builtin +the ksh-like $(, &>, >|, <<<, [n]<&word-, [n]>&word- + prompt string special char translation and variable expansion + auto-export of variables in initial environment + command search finds functions before builtins + bash return builtin will exit a file sourced with `.' + builtins: cd -/-L/-P, exec -l/-c/-a, echo -e/-E, hash -d/-l/-p/-t. + export -n/-f/-p/name=value, pwd -L/-P, + read -e/-p/-a/-t/-n/-d/-s/-u, + readonly -a/-f/name=value, trap -l, set +o, + set -b/-m/-o option/-h/-p/-B/-C/-H/-P, + unset -f/-v, ulimit -m/-p/-u, + type -a/-p/-t/-f/-P, suspend -f, kill -n, + test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S + bash reads ~/.bashrc for interactive shells, $ENV for non-interactive + bash restricted shell mode is more extensive + bash allows functions and variables with the same name + brace expansion + tilde expansion + arithmetic expansion with $((...)) and `let' builtin + the `[[...]]' extended conditional command + process substitution + aliases and alias/unalias builtins + local variables in functions and `local' builtin + readline and command-line editing with programmable completion + command history and history/fc builtins + csh-like history expansion + other new bash builtins: bind, command, compgen, complete, builtin, + declare/typeset, dirs, enable, fc, help, + history, logout, popd, pushd, disown, shopt, + printf + exported functions + filename generation when using output redirection (command >a*) + POSIX.2-style globbing character classes + POSIX.2-style globbing equivalence classes + POSIX.2-style globbing collating symbols + egrep-like extended pattern matching operators + case-insensitive pattern matching and globbing + variable assignments preceding commands affect only that command, + even for builtins and functions + posix mode + redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr, + /dev/tcp/host/port, /dev/udp/host/port + +Things sh has that bash does not: + uses variable SHACCT to do shell accounting + includes `stop' builtin (bash can use alias stop='kill -s STOP') + `newgrp' builtin + turns on job control if called as `jsh' + $TIMEOUT (like bash $TMOUT) + `^' is a synonym for `|' + new SVR4.2 sh builtins: mldmode, priv + +Implementation differences: + redirection to/from compound commands causes sh to create a subshell + bash does not allow unbalanced quotes; sh silently inserts them at EOF + bash does not mess with signal 11 + sh sets (euid, egid) to (uid, gid) if -p not supplied and uid < 100 + bash splits only the results of expansions on IFS, using POSIX.2 + field splitting rules; sh splits all words on IFS + sh does not allow MAILCHECK to be unset (?) + sh does not allow traps on SIGALRM or SIGCHLD + bash allows multiple option arguments when invoked (e.g. -x -v); + sh allows only a single option argument (`sh -x -v' attempts + to open a file named `-v', and, on SunOS 4.1.4, dumps core. + On Solaris 2.4 and earlier versions, sh goes into an infinite + loop.) + sh exits a script if any builtin fails; bash exits only if one of + the POSIX.2 `special' builtins fails + +C2) How does bash differ from the Korn shell, version ksh88? + +Things bash has or uses that ksh88 does not: + long invocation options + [-+]O invocation option + -l invocation option + `!' reserved word + arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done + arithmetic in largest machine-supported size (intmax_t) + posix mode and posix conformance + command hashing + tilde expansion for assignment statements that look like $PATH + process substitution with named pipes if /dev/fd is not available + the ${!param} indirect parameter expansion operator + the ${!param*} prefix expansion operator + the ${param:offset[:length]} parameter substring operator + the ${param/pat[/string]} parameter pattern substitution operator + variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL, + TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE, + HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND, + IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK, + PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE, + GROUPS, FUNCNAME, histchars, auto_resume + prompt expansion with backslash escapes and command substitution + redirection: &> (stdout and stderr), <<<, [n]<&word-, [n]>&word- + more extensive and extensible editing and programmable completion + builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable, + exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history, + jobs -x/-r/-s, kill -s/-n/-l, local, logout, popd, pushd, + read -e/-p/-a/-t/-n/-d/-s, readonly -a/-n/-f/-p, + set -o braceexpand/-o histexpand/-o interactive-comments/ + -o notify/-o physical/-o posix/-o hashall/-o onecmd/ + -h/-B/-C/-b/-H/-P, set +o, suspend, trap -l, type, + typeset -a/-F/-p, ulimit -u, umask -S, alias -p, shopt, + disown, printf, complete, compgen + `!' csh-style history expansion + POSIX.2-style globbing character classes + POSIX.2-style globbing equivalence classes + POSIX.2-style globbing collating symbols + egrep-like extended pattern matching operators + case-insensitive pattern matching and globbing + `**' arithmetic operator to do exponentiation + redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr + arrays of unlimited size + TMOUT is default timeout for `read' and `select' + +Things ksh88 has or uses that bash does not: + tracked aliases (alias -t) + variables: ERRNO, FPATH, EDITOR, VISUAL + co-processes (|&, >&p, <&p) + weirdly-scoped functions + typeset +f to list all function names without definitions + text of command history kept in a file, not memory + builtins: alias -x, cd old new, fc -e -, newgrp, print, + read -p/-s/var?prompt, set -A/-o gmacs/ + -o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s, + typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-l/-u/-t, whence + using environment to pass attributes of exported variables + arithmetic evaluation done on arguments to some builtins + reads .profile from $PWD when invoked as login shell + +Implementation differences: + ksh runs last command of a pipeline in parent shell context + bash has brace expansion by default (ksh88 compile-time option) + bash has fixed startup file for all interactive shells; ksh reads $ENV + bash has exported functions + bash command search finds functions before builtins + bash waits for all commands in pipeline to exit before returning status + emacs-mode editing has some slightly different key bindings + +C3) Which new features in ksh-93 are not in bash, and which are? + +New things in ksh-93 not in bash-2.05b: + associative arrays + floating point arithmetic and variables + math library functions + ${!name[sub]} name of subscript for associative array + `.' is allowed in variable names to create a hierarchical namespace + more extensive compound assignment syntax + discipline functions + `sleep' and `getconf' builtins (bash has loadable versions) + typeset -n and `nameref' variables + KEYBD trap + variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version, + .sh.name, .sh.subscript, .sh.value, .sh.match, HISTEDIT + backreferences in pattern matching (\N) + `&' operator in pattern lists for matching + print -f (bash uses printf) + `fc' has been renamed to `hist' + `.' can execute shell functions + exit statuses between 0 and 255 + set -o pipefail + `+=' variable assignment operator + FPATH and PATH mixing + getopts -a + -I invocation option + DEBUG trap now executed before each simple command, instead of after + printf %H, %P, %T, %Z modifiers, output base for %d + lexical scoping for local variables in `ksh' functions + no scoping for local variables in `POSIX' functions + +New things in ksh-93 present in bash-2.05b: + [n]<&word- and [n]>&word- redirections (combination dup and close) + for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command + ?:, ++, --, `expr1 , expr2' arithmetic operators + expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}, + ${!param*} + compound array assignment + the `!' reserved word + loadable builtins -- but ksh uses `builtin' while bash uses `enable' + `command', `builtin', `disown' builtins + new $'...' and $"..." quoting + FIGNORE (but bash uses GLOBIGNORE), HISTCMD + set -o notify/-C + changes to kill builtin + read -A (bash uses read -a) + read -t/-d + trap -p + exec -c/-a + `.' restores the positional parameters when it completes + POSIX.2 `test' + umask -S + unalias -a + command and arithmetic substitution performed on PS1, PS4, and ENV + command name completion + ENV processed only for interactive shells + +Section D: Why does bash do some things differently than other Unix shells? + +D1) Why does bash run a different version of `command' than + `which command' says it will? + +On many systems, `which' is actually a csh script that assumes +you're running csh. In tcsh, `which' and its cousin `where' +are builtins. On other Unix systems, `which' is a perl script +that uses the PATH environment variable. + +The csh script version reads the csh startup files from your +home directory and uses those to determine which `command' will +be invoked. Since bash doesn't use any of those startup files, +there's a good chance that your bash environment differs from +your csh environment. The bash `type' builtin does everything +`which' does, and will report correct results for the running +shell. If you're really wedded to the name `which', try adding +the following function definition to your .bashrc: + + which() + { + builtin type "$@" + } + +If you're moving from tcsh and would like to bring `where' along +as well, use this function: + + where() + { + builtin type -a "$@" + } + +D2) Why doesn't bash treat brace expansions exactly like csh? + +The only difference between bash and csh brace expansion is that +bash requires a brace expression to contain at least one unquoted +comma if it is to be expanded. Any brace-surrounded word not +containing an unquoted comma is left unchanged by the brace +expansion code. This affords the greatest degree of sh +compatibility. + +Bash, ksh, zsh, and pd-ksh all implement brace expansion this way. + +D3) Why doesn't bash have csh variable modifiers? + +Posix has specified a more powerful, albeit somewhat more cryptic, +mechanism cribbed from ksh, and bash implements it. + +${parameter%word} + Remove smallest suffix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + smallest portion of the suffix matched by the pattern deleted. + + x=file.c + echo ${x%.c}.o + -->file.o + +${parameter%%word} + + Remove largest suffix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + largest portion of the suffix matched by the pattern deleted. + + x=posix/src/std + echo ${x%%/*} + -->posix + +${parameter#word} + Remove smallest prefix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + smallest portion of the prefix matched by the pattern deleted. + + x=$HOME/src/cmd + echo ${x#$HOME} + -->/src/cmd + +${parameter##word} + Remove largest prefix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + largest portion of the prefix matched by the pattern deleted. + + x=/one/two/three + echo ${x##*/} + -->three + + +Given + a=/a/b/c/d + b=b.xxx + + csh bash result + --- ---- ------ + $a:h ${a%/*} /a/b/c + $a:t ${a##*/} d + $b:r ${b%.*} b + $b:e ${b##*.} xxx + + +D4) How can I make my csh aliases work when I convert to bash? + +Bash uses a different syntax to support aliases than csh does. +The details can be found in the documentation. We have provided +a shell script which does most of the work of conversion for you; +this script can be found in ./examples/misc/aliasconv.sh. Here is +how you use it: + +Start csh in the normal way for you. (e.g., `csh') + +Pipe the output of `alias' through `aliasconv.sh', saving the +results into `bash_aliases': + + alias | bash aliasconv.sh >bash_aliases + +Edit `bash_aliases', carefully reading through any created +functions. You will need to change the names of some csh specific +variables to the bash equivalents. The script converts $cwd to +$PWD, $term to $TERM, $home to $HOME, $user to $USER, and $prompt +to $PS1. You may also have to add quotes to avoid unwanted +expansion. + +For example, the csh alias: + + alias cd 'cd \!*; echo $cwd' + +is converted to the bash function: + + cd () { command cd "$@"; echo $PWD ; } + +The only thing that needs to be done is to quote $PWD: + + cd () { command cd "$@"; echo "$PWD" ; } + +Merge the edited file into your ~/.bashrc. + +There is an additional, more ambitious, script in +examples/misc/cshtobash that attempts to convert your entire csh +environment to its bash equivalent. This script can be run as +simply `cshtobash' to convert your normal interactive +environment, or as `cshtobash ~/.login' to convert your login +environment. + +D5) How can I pipe standard output and standard error from one command to + another, like csh does with `|&'? + +Use + command 2>&1 | command2 + +The key is to remember that piping is performed before redirection, so +file descriptor 1 points to the pipe when it is duplicated onto file +descriptor 2. + +D6) Now that I've converted from ksh to bash, are there equivalents to + ksh features like autoloaded functions and the `whence' command? + +There are features in ksh-88 and ksh-93 that do not have direct bash +equivalents. Most, however, can be emulated with very little trouble. + +ksh-88 feature Bash equivalent +-------------- --------------- +compiled-in aliases set up aliases in .bashrc; some ksh aliases are + bash builtins (hash, history, type) +coprocesses named pipe pairs (one for read, one for write) +typeset +f declare -F +cd, print, whence function substitutes in examples/functions/kshenv +autoloaded functions examples/functions/autoload is the same as typeset -fu +read var?prompt read -p prompt var + +ksh-93 feature Bash equivalent +-------------- --------------- +sleep, getconf Bash has loadable versions in examples/loadables +${.sh.version} $BASH_VERSION +print -f printf +hist alias hist=fc +$HISTEDIT $FCEDIT + +Section E: How can I get bash to do certain things, and why does bash do + things the way it does? + +E1) Why is the bash builtin `test' slightly different from /bin/test? + +The specific example used here is [ ! x -o x ], which is false. + +Bash's builtin `test' implements the Posix.2 spec, which can be +summarized as follows (the wording is due to David Korn): + +Here is the set of rules for processing test arguments. + + 0 Args: False + 1 Arg: True iff argument is not null. + 2 Args: If first arg is !, True iff second argument is null. + If first argument is unary, then true if unary test is true + Otherwise error. + 3 Args: If second argument is a binary operator, do binary test of $1 $3 + If first argument is !, negate two argument test of $2 $3 + If first argument is `(' and third argument is `)', do the + one-argument test of the second argument. + Otherwise error. + 4 Args: If first argument is !, negate three argument test of $2 $3 $4. + Otherwise unspecified + 5 or more Args: unspecified. (Historical shells would use their + current algorithm). + +The operators -a and -o are considered binary operators for the purpose +of the 3 Arg case. + +As you can see, the test becomes (not (x or x)), which is false. + +E2) Why does bash sometimes say `Broken pipe'? + +If a sequence of commands appears in a pipeline, and one of the +reading commands finishes before the writer has finished, the +writer receives a SIGPIPE signal. Many other shells special-case +SIGPIPE as an exit status in the pipeline and do not report it. +For example, in: + + ps -aux | head + +`head' can finish before `ps' writes all of its output, and ps +will try to write on a pipe without a reader. In that case, bash +will print `Broken pipe' to stderr when ps is killed by a +SIGPIPE. + +You can build a version of bash that will not report SIGPIPE errors +by uncommenting the definition of DONT_REPORT_SIGPIPE in the file +config-top.h. + +E3) When I have terminal escape sequences in my prompt, why does bash + wrap lines at the wrong column? + +Readline, the line editing library that bash uses, does not know +that the terminal escape sequences do not take up space on the +screen. The redisplay code assumes, unless told otherwise, that +each character in the prompt is a `printable' character that +takes up one character position on the screen. + +You can use the bash prompt expansion facility (see the PROMPTING +section in the manual page) to tell readline that sequences of +characters in the prompt strings take up no screen space. + +Use the \[ escape to begin a sequence of non-printing characters, +and the \] escape to signal the end of such a sequence. + +E4) If I pipe the output of a command into `read variable', why doesn't + the output show up in $variable when the read command finishes? + +This has to do with the parent-child relationship between Unix +processes. It affects all commands run in pipelines, not just +simple calls to `read'. For example, piping a command's output +into a `while' loop that repeatedly calls `read' will result in +the same behavior. + +Each element of a pipeline runs in a separate process, a child of +the shell running the pipeline. A subprocess cannot affect its +parent's environment. When the `read' command sets the variable +to the input, that variable is set only in the subshell, not the +parent shell. When the subshell exits, the value of the variable +is lost. + +Many pipelines that end with `read variable' can be converted +into command substitutions, which will capture the output of +a specified command. The output can then be assigned to a +variable: + + grep ^gnu /usr/lib/news/active | wc -l | read ngroup + +can be converted into + + ngroup=$(grep ^gnu /usr/lib/news/active | wc -l) + +This does not, unfortunately, work to split the text among +multiple variables, as read does when given multiple variable +arguments. If you need to do this, you can either use the +command substitution above to read the output into a variable +and chop up the variable using the bash pattern removal +expansion operators or use some variant of the following +approach. + +Say /usr/local/bin/ipaddr is the following shell script: + +#! /bin/sh +host `hostname` | awk '/address/ {print $NF}' + +Instead of using + + /usr/local/bin/ipaddr | read A B C D + +to break the local machine's IP address into separate octets, use + + OIFS="$IFS" + IFS=. + set -- $(/usr/local/bin/ipaddr) + IFS="$OIFS" + A="$1" B="$2" C="$3" D="$4" + +Beware, however, that this will change the shell's positional +parameters. If you need them, you should save them before doing +this. + +This is the general approach -- in most cases you will not need to +set $IFS to a different value. + +Some other user-supplied alternatives include: + +read A B C D << HERE + $(IFS=.; echo $(/usr/local/bin/ipaddr)) +HERE + +and, where process substitution is available, + +read A B C D < <(IFS=.; echo $(/usr/local/bin/ipaddr)) + +E5) I have a bunch of shell scripts that use backslash-escaped characters + in arguments to `echo'. Bash doesn't interpret these characters. Why + not, and how can I make it understand them? + +This is the behavior of echo on most Unix System V machines. + +The bash builtin `echo' is modeled after the 9th Edition +Research Unix version of `echo'. It does not interpret +backslash-escaped characters in its argument strings by default; +it requires the use of the -e option to enable the +interpretation. The System V echo provides no way to disable the +special characters; the bash echo has a -E option to disable +them. + +There is a configuration option that will make bash behave like +the System V echo and interpret things like `\t' by default. Run +configure with the --enable-xpg-echo-default option to turn this +on. Be aware that this will cause some of the tests run when you +type `make tests' to fail. + +There is a shell option, `xpg_echo', settable with `shopt', that will +change the behavior of echo at runtime. Enabling this option turns +on expansion of backslash-escape sequences. + +E6) Why doesn't a while or for loop get suspended when I type ^Z? + +This is a consequence of how job control works on Unix. The only +thing that can be suspended is the process group. This is a single +command or pipeline of commands that the shell forks and executes. + +When you run a while or for loop, the only thing that the shell forks +and executes are any commands in the while loop test and commands in +the loop bodies. These, therefore, are the only things that can be +suspended when you type ^Z. + +If you want to be able to stop the entire loop, you need to put it +within parentheses, which will force the loop into a subshell that +may be stopped (and subsequently restarted) as a single unit. + +E7) What about empty for loops in Makefiles? + +It's fairly common to see constructs like this in automatically-generated +Makefiles: + +SUBDIRS = @SUBDIRS@ + + ... + +subdirs-clean: + for d in ${SUBDIRS}; do \ + ( cd $$d && ${MAKE} ${MFLAGS} clean ) \ + done + +When SUBDIRS is empty, this results in a command like this being passed to +bash: + + for d in ; do + ( cd $d && ${MAKE} ${MFLAGS} clean ) + done + +In versions of bash before bash-2.05a, this was a syntax error. If the +reserved word `in' was present, a word must follow it before the semicolon +or newline. The language in the manual page referring to the list of words +being empty referred to the list after it is expanded. These versions of +bash required that there be at least one word following the `in' when the +construct was parsed. + +The idiomatic Makefile solution is something like: + +SUBDIRS = @SUBDIRS@ + +subdirs-clean: + subdirs=$SUBDIRS ; for d in $$subdirs; do \ + ( cd $$d && ${MAKE} ${MFLAGS} clean ) \ + done + +The latest drafts of the updated POSIX standard have changed this: the +word list is no longer required. Bash versions 2.05a and later accept +the new syntax. + +E8) Why does the arithmetic evaluation code complain about `08'? + +The bash arithmetic evaluation code (used for `let', $(()), (()), and in +other places), interprets a leading `0' in numeric constants as denoting +an octal number, and a leading `0x' as denoting hexadecimal. This is +in accordance with the POSIX.2 spec, section 2.9.2.1, which states that +arithmetic constants should be handled as signed long integers as defined +by the ANSI/ISO C standard. + +The POSIX.2 interpretation committee has confirmed this: + +http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-173.html + +E9) Why does the pattern matching expression [A-Z]* match files beginning + with every letter except `z'? + +Bash-2.03, Bash-2.05 and later versions honor the current locale setting +when processing ranges within pattern matching bracket expressions ([A-Z]). +This is what POSIX.2 and SUSv3/XPG6 specify. + +The behavior of the matcher in bash-2.05 and later versions depends on the +current LC_COLLATE setting. Setting this variable to `C' or `POSIX' will +result in the traditional behavior ([A-Z] matches all uppercase ASCII +characters). Many other locales, including the en_US locale (the default +on many US versions of Linux) collate the upper and lower case letters like +this: + + AaBb...Zz + +which means that [A-Z] matches every letter except `z'. Others collate like + + aAbBcC...zZ + +which means that [A-Z] matches every letter except `a'. + +The portable way to specify upper case letters is [:upper:] instead of +A-Z; lower case may be specified as [:lower:] instead of a-z. + +Look at the manual pages for setlocale(3), strcoll(3), and, if it is +present, locale(1). If you have locale(1), you can use it to find +your current locale information even if you do not have any of the +LC_ variables set. + +My advice is to put + + export LC_COLLATE=C + +into /etc/profile and inspect any shell scripts run from cron for +constructs like [A-Z]. This will prevent things like + + rm [A-Z]* + +from removing every file in the current directory except those beginning +with `z' and still allow individual users to change the collation order. +Users may put the above command into their own profiles as well, of course. + +E10) Why does `cd //' leave $PWD as `//'? + +POSIX.2, in its description of `cd', says that *three* or more leading +slashes may be replaced with a single slash when canonicalizing the +current working directory. + +This is, I presume, for historical compatibility. Certain versions of +Unix, and early network file systems, used paths of the form +//hostname/path to access `path' on server `hostname'. + +E11) If I resize my xterm while another program is running, why doesn't bash + notice the change? + +This is another issue that deals with job control. + +The kernel maintains a notion of a current terminal process group. Members +of this process group (processes whose process group ID is equal to the +current terminal process group ID) receive terminal-generated signals like +SIGWINCH. (For more details, see the JOB CONTROL section of the bash +man page.) + +If a terminal is resized, the kernel sends SIGWINCH to each member of +the terminal's current process group (the `foreground' process group). + +When bash is running with job control enabled, each pipeline (which may be +a single command) is run in its own process group, different from bash's +process group. This foreground process group receives the SIGWINCH; bash +does not. Bash has no way of knowing that the terminal has been resized. + +There is a `checkwinsize' option, settable with the `shopt' builtin, that +will cause bash to check the window size and adjust its idea of the +terminal's dimensions each time a process stops or exits and returns control +of the terminal to bash. Enable it with `shopt -s checkwinsize'. + +Section F: Things to watch out for on certain Unix versions + +F1) Why can't I use command line editing in my `cmdtool'? + +The problem is `cmdtool' and bash fighting over the input. When +scrolling is enabled in a cmdtool window, cmdtool puts the tty in +`raw mode' to permit command-line editing using the mouse for +applications that cannot do it themselves. As a result, bash and +cmdtool each try to read keyboard input immediately, with neither +getting enough of it to be useful. + +This mode also causes cmdtool to not implement many of the +terminal functions and control sequences appearing in the +`sun-cmd' termcap entry. For a more complete explanation, see +that file examples/suncmd.termcap in the bash distribution. + +`xterm' is a better choice, and gets along with bash much more +smoothly. + +If you must use cmdtool, you can use the termcap description in +examples/suncmd.termcap. Set the TERMCAP variable to the terminal +description contained in that file, i.e. + +TERMCAP='Mu|sun-cmd:am:bs:km:pt:li#34:co#80:cl=^L:ce=\E[K:cd=\E[J:rs=\E[s:' + +Then export TERMCAP and start a new cmdtool window from that shell. +The bash command-line editing should behave better in the new +cmdtool. If this works, you can put the assignment to TERMCAP +in your bashrc file. + +F2) I built bash on Solaris 2. Why do globbing expansions and filename + completion chop off the first few characters of each filename? + +This is the consequence of building bash on SunOS 5 and linking +with the libraries in /usr/ucblib, but using the definitions +and structures from files in /usr/include. + +The actual conflict is between the dirent structure in +/usr/include/dirent.h and the struct returned by the version of +`readdir' in libucb.a (a 4.3-BSD style `struct direct'). + +Make sure you've got /usr/ccs/bin ahead of /usr/ucb in your $PATH +when configuring and building bash. This will ensure that you +use /usr/ccs/bin/cc or acc instead of /usr/ucb/cc and that you +link with libc before libucb. + +If you have installed the Sun C compiler, you may also need to +put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before +/usr/ucb. + +F3) Why does bash dump core after I interrupt username completion or + `~user' tilde expansion on a machine running NIS? + +This is a famous and long-standing bug in the SunOS YP (sorry, NIS) +client library, which is part of libc. + +The YP library code keeps static state -- a pointer into the data +returned from the server. When YP initializes itself (setpwent), +it looks at this pointer and calls free on it if it's non-null. +So far, so good. + +If one of the YP functions is interrupted during getpwent (the +exact function is interpretwithsave()), and returns NULL, the +pointer is freed without being reset to NULL, and the function +returns. The next time getpwent is called, it sees that this +pointer is non-null, calls free, and the bash free() blows up +because it's being asked to free freed memory. + +The traditional Unix mallocs allow memory to be freed multiple +times; that's probably why this has never been fixed. You can +run configure with the `--without-gnu-malloc' option to use +the C library malloc and avoid the problem. + +F4) I'm running SVR4.2. Why is the line erased every time I type `@'? + +The `@' character is the default `line kill' character in most +versions of System V, including SVR4.2. You can change this +character to whatever you want using `stty'. For example, to +change the line kill character to control-u, type + + stty kill ^U + +where the `^' and `U' can be two separate characters. + +F5) Why does bash report syntax errors when my C News scripts use a + redirection before a subshell command? + +The actual command in question is something like + + < file ( command ) + +According to the grammar given in the POSIX.2 standard, this construct +is, in fact, a syntax error. Redirections may only precede `simple +commands'. A subshell construct such as the above is one of the shell's +`compound commands'. A redirection may only follow a compound command. + +This affects the mechanical transformation of commands that use `cat' +to pipe a file into a command (a favorite Useless-Use-Of-Cat topic on +comp.unix.shell). While most commands of the form + + cat file | command + +can be converted to `< file command', shell control structures such as +loops and subshells require `command < file'. + +The file CWRU/sh-redir-hack in the bash-2.05a distribution is an +(unofficial) patch to parse.y that will modify the grammar to +support this construct. It will not apply with `patch'; you must +modify parse.y by hand. Note that if you apply this, you must +recompile with -DREDIRECTION_HACK. This introduces a large +number of reduce/reduce conflicts into the shell grammar. + +F6) Why can't I use vi-mode editing on Red Hat Linux 6.1? + +The short answer is that Red Hat screwed up. + +The long answer is that they shipped an /etc/inputrc that only works +for emacs mode editing, and then screwed all the vi users by setting +INPUTRC to /etc/inputrc in /etc/profile. + +The short fix is to do one of the following: remove or rename +/etc/inputrc, set INPUTRC=~/.inputrc in ~/.bashrc (or .bash_profile, +but make sure you export it if you do), remove the assignment to +INPUTRC from /etc/profile, add + + set keymap emacs + +to the beginning of /etc/inputrc, or bracket the key bindings in +/etc/inputrc with these lines + + $if mode=emacs + [...] + $endif + +F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on + HP/UX 11.x? + +HP/UX's support for long double is imperfect at best. + +GCC will support it without problems, but the HP C library functions +like strtold(3) and printf(3) don't actually work with long doubles. +HP implemented a `long_double' type as a 4-element array of 32-bit +ints, and that is what the library functions use. The ANSI C +`long double' type is a 128-bit floating point scalar. + +The easiest fix, until HP fixes things up, is to edit the generated +config.h and #undef the HAVE_LONG_DOUBLE line. After doing that, +the compilation should complete successfully. + +Section G: How can I get bash to do certain common things? + +G1) How can I get bash to read and display eight-bit characters? + +This is a process requiring several steps. + +First, you must ensure that the `physical' data path is a full eight +bits. For xterms, for example, the `vt100' resources `eightBitInput' +and `eightBitOutput' should be set to `true'. + +Once you have set up an eight-bit path, you must tell the kernel and +tty driver to leave the eighth bit of characters alone when processing +keyboard input. Use `stty' to do this: + + stty cs8 -istrip -parenb + +For old BSD-style systems, you can use + + stty pass8 + +You may also need + + stty even odd + +Finally, you need to tell readline that you will be inputting and +displaying eight-bit characters. You use readline variables to do +this. These variables can be set in your .inputrc or using the bash +`bind' builtin. Here's an example using `bind': + + bash$ bind 'set convert-meta off' + bash$ bind 'set meta-flag on' + bash$ bind 'set output-meta on' + +The `set' commands between the single quotes may also be placed +in ~/.inputrc. + +G2) How do I write a function `x' to replace builtin command `x', but + still invoke the command from within the function? + +This is why the `command' and `builtin' builtins exist. The +`command' builtin executes the command supplied as its first +argument, skipping over any function defined with that name. The +`builtin' builtin executes the builtin command given as its first +argument directly. + +For example, to write a function to replace `cd' that writes the +hostname and current directory to an xterm title bar, use +something like the following: + + cd() + { + builtin cd "$@" && xtitle "$HOST: $PWD" + } + +This could also be written using `command' instead of `builtin'; +the version above is marginally more efficient. + +G3) How can I find the value of a shell variable whose name is the value + of another shell variable? + +Versions of Bash newer than Bash-2.0 support this directly. You can use + + ${!var} + +For example, the following sequence of commands will echo `z': + + var1=var2 + var2=z + echo ${!var1} + +For sh compatibility, use the `eval' builtin. The important +thing to remember is that `eval' expands the arguments you give +it again, so you need to quote the parts of the arguments that +you want `eval' to act on. + +For example, this expression prints the value of the last positional +parameter: + + eval echo \"\$\{$#\}\" + +The expansion of the quoted portions of this expression will be +deferred until `eval' runs, while the `$#' will be expanded +before `eval' is executed. In versions of bash later than bash-2.0, + + echo ${!#} + +does the same thing. + +This is not the same thing as ksh93 `nameref' variables, though the syntax +is similar. I may add namerefs in a future bash version. + +G4) How can I make the bash `time' reserved word print timing output that + looks like the output from my system's /usr/bin/time? + +The bash command timing code looks for a variable `TIMEFORMAT' and +uses its value as a format string to decide how to display the +timing statistics. + +The value of TIMEFORMAT is a string with `%' escapes expanded in a +fashion similar in spirit to printf(3). The manual page explains +the meanings of the escape sequences in the format string. + +If TIMEFORMAT is not set, bash acts as if the following assignment had +been performed: + + TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS' + +The POSIX.2 default time format (used by `time -p command') is + + TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S' + +The BSD /usr/bin/time format can be emulated with: + + TIMEFORMAT=$'\t%1R real\t%1U user\t%1S sys' + +The System V /usr/bin/time format can be emulated with: + + TIMEFORMAT=$'\nreal\t%1R\nuser\t%1U\nsys\t%1S' + +The ksh format can be emulated with: + + TIMEFORMAT=$'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS' + +G5) How do I get the current directory into my prompt? + +Bash provides a number of backslash-escape sequences which are expanded +when the prompt string (PS1 or PS2) is displayed. The full list is in +the manual page. + +The \w expansion gives the full pathname of the current directory, with +a tilde (`~') substituted for the current value of $HOME. The \W +expansion gives the basename of the current directory. To put the full +pathname of the current directory into the path without any tilde +subsitution, use $PWD. Here are some examples: + + PS1='\w$ ' # current directory with tilde + PS1='\W$ ' # basename of current directory + PS1='$PWD$ ' # full pathname of current directory + +The single quotes are important in the final example to prevent $PWD from +being expanded when the assignment to PS1 is performed. + +G6) How can I rename "*.foo" to "*.bar"? + +Use the pattern removal functionality described in D3. The following `for' +loop will do the trick: + + for f in *.foo; do + mv $f ${f%foo}bar + done + +G7) How can I translate a filename from uppercase to lowercase? + +The script examples/functions/lowercase, originally written by John DuBois, +will do the trick. The converse is left as an exercise. + +G8) How can I write a filename expansion (globbing) pattern that will match + all files in the current directory except "." and ".."? + +You must have set the `extglob' shell option using `shopt -s extglob' to use +this: + + echo .!(.|) * + +A solution that works without extended globbing is given in the Unix Shell +FAQ, posted periodically to comp.unix.shell. + +Section H: Where do I go from here? + +H1) How do I report bugs in bash, and where should I look for fixes and + advice? + +Use the `bashbug' script to report bugs. It is built and +installed at the same time as bash. It provides a standard +template for reporting a problem and automatically includes +information about your configuration and build environment. + +`bashbug' sends its reports to bug-bash@gnu.org, which +is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug. + +Bug fixes, answers to questions, and announcements of new releases +are all posted to gnu.bash.bug. Discussions concerning bash features +and problems also take place there. + +To reach the bash maintainers directly, send mail to +bash-maintainers@gnu.org. + +H2) What kind of bash documentation is there? + +First, look in the doc directory in the bash distribution. It should +contain at least the following files: + +bash.1 an extensive, thorough Unix-style manual page +builtins.1 a manual page covering just bash builtin commands +bashref.texi a reference manual in GNU tex`info format +bashref.info an info version of the reference manual +FAQ this file +article.ms text of an article written for The Linux Journal +readline.3 a man page describing readline + +Postscript, HTML, and ASCII files created from the above source are +available in the documentation distribution. + +There is additional documentation available for anonymous FTP from host +ftp.cwru.edu in the `pub/bash' directory. + +Cameron Newham and Bill Rosenblatt have written a book on bash, published +by O'Reilly and Associates. The book is based on Bill Rosenblatt's Korn +Shell book. The title is ``Learning the Bash Shell'', and the ISBN number +is 1-56592-147-X. Look for it in fine bookstores near you. This book +covers bash-1.14, but has an appendix describing some of the new features +in bash-2.0. + +A second edition of this book is available, published in January, 1998. +The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores +or on the web. + +The GNU Bash Reference Manual has been published as a printed book by +Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Feb 2003). It covers +bash-2.0 and is available from most online bookstores (see +http://www.network-theory.co.uk/bash/manual/ for details). The publisher +will donate $1 to the Free Software Foundation for each copy sold. + +H3) What's coming in future versions? + +These are features I hope to include in a future version of bash. + +a better bash debugger (a minimally-tested version is included with bash-2.05b) +associative arrays +co-processes, but with a new-style syntax that looks like function declaration + +H4) What's on the bash `wish list' for future versions? + +These are features that may or may not appear in a future version of bash. + +breaking some of the shell functionality into embeddable libraries +a module system like zsh's, using dynamic loading like builtins +better internationalization using GNU `gettext' +date-stamped command history +a bash programmer's guide with a chapter on creating loadable builtins +a better loadable interface to perl with access to the shell builtins and + variables (contributions gratefully accepted) +ksh93-like `nameref' variables +ksh93-like `+=' variable assignment operator +ksh93-like `xx.yy' variables (including some of the .sh.* variables) and + associated disipline functions +Some of the new ksh93 pattern matching operators, like backreferencing + +H5) When will the next release appear? + +The next version will appear sometime in 2002. Never make predictions. + + +This document is Copyright 1995-2003 by Chester Ramey. + +Permission is hereby granted, without written agreement and +without license or royalty fees, to use, copy, and distribute +this document for any purpose, provided that the above copyright +notice appears in all copies of this document and that the +contents of this document remain unaltered. diff --git a/doc/bashref.texi b/doc/bashref.texi index 2e7593dbf..c260f89a0 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -8027,7 +8027,7 @@ the following options, but it is processed first, so individual options may be enabled using @samp{enable-@var{feature}}. All of the following options except for @samp{disabled-builtins}, -@samp{directpand-default}, and +@samp{direxpand-default}, and @samp{xpg-echo-default} are enabled by default, unless the operating system does not provide the necessary support. diff --git a/examples/loadables/Makefile.in.save b/examples/loadables/Makefile.in.save new file mode 100644 index 000000000..f6208f5cc --- /dev/null +++ b/examples/loadables/Makefile.in.save @@ -0,0 +1,238 @@ +# +# Simple makefile for the sample loadable builtins +# +# Copyright (C) 1996 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + +# Include some boilerplate Gnu makefile definitions. +prefix = @prefix@ + +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +infodir = @infodir@ +includedir = @includedir@ + +topdir = @top_srcdir@ +BUILD_DIR = @BUILD_DIR@ +srcdir = @srcdir@ +VPATH = .:@srcdir@ + +@SET_MAKE@ +CC = @CC@ +RM = rm -f + +SHELL = @MAKE_SHELL@ + +host_os = @host_os@ +host_cpu = @host_cpu@ +host_vendor = @host_vendor@ + +CFLAGS = @CFLAGS@ +LOCAL_CFLAGS = @LOCAL_CFLAGS@ +DEFS = @DEFS@ +LOCAL_DEFS = @LOCAL_DEFS@ + +CPPFLAGS = @CPPFLAGS@ + +BASHINCDIR = ${topdir}/include + +LIBBUILD = ${BUILD_DIR}/lib + +INTL_LIBSRC = ${topdir}/lib/intl +INTL_BUILDDIR = ${LIBBUILD}/intl +INTL_INC = @INTL_INC@ +LIBINTL_H = @LIBINTL_H@ + +CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) $(CFLAGS) + +# +# These values are generated for configure by ${topdir}/support/shobj-conf. +# If your system is not supported by that script, but includes facilities for +# dynamic loading of shared objects, please update the script and send the +# changes to bash-maintainers@gnu.org. +# +SHOBJ_CC = @SHOBJ_CC@ +SHOBJ_CFLAGS = @SHOBJ_CFLAGS@ +SHOBJ_LD = @SHOBJ_LD@ +SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@ +SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@ +SHOBJ_LIBS = @SHOBJ_LIBS@ +SHOBJ_STATUS = @SHOBJ_STATUS@ + +INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \ + -I$(BASHINCDIR) -I$(BUILD_DIR) -I$(LIBBUILD) \ + -I$(BUILD_DIR)/builtins $(INTL_INC) + +.c.o: + $(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CCFLAGS) $(INC) -c -o $@ $< + + +ALLPROG = print truefalse sleep pushd finfo logname basename dirname \ + tty pathchk tee head mkdir rmdir printenv id whoami \ + uname sync push ln unlink cut realpath getconf strftime +OTHERPROG = necho hello cat + +all: $(SHOBJ_STATUS) + +supported: $(ALLPROG) +others: $(OTHERPROG) + +unsupported: + @echo "Your system (${host_os}) is not supported by the" + @echo "${topdir}/support/shobj-conf script." + @echo "If your operating system provides facilities for dynamic" + @echo "loading of shared objects using the dlopen(3) interface," + @echo "please update the script and re-run configure. + @echo "Please send the changes you made to bash-maintainers@gnu.org" + @echo "for inclusion in future bash releases." + +everything: supported others + +print: print.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ print.o $(SHOBJ_LIBS) + +necho: necho.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ necho.o $(SHOBJ_LIBS) + +getconf: getconf.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ getconf.o $(SHOBJ_LIBS) + +hello: hello.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ hello.o $(SHOBJ_LIBS) + +truefalse: truefalse.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ truefalse.o $(SHOBJ_LIBS) + +sleep: sleep.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ sleep.o $(SHOBJ_LIBS) + +finfo: finfo.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ finfo.o $(SHOBJ_LIBS) + +cat: cat.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ cat.o $(SHOBJ_LIBS) + +logname: logname.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ logname.o $(SHOBJ_LIBS) + +basename: basename.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ basename.o $(SHOBJ_LIBS) + +dirname: dirname.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ dirname.o $(SHOBJ_LIBS) + +tty: tty.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ tty.o $(SHOBJ_LIBS) + +pathchk: pathchk.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ pathchk.o $(SHOBJ_LIBS) + +tee: tee.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ tee.o $(SHOBJ_LIBS) + +mkdir: mkdir.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ mkdir.o $(SHOBJ_LIBS) + +rmdir: rmdir.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ rmdir.o $(SHOBJ_LIBS) + +head: head.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ head.o $(SHOBJ_LIBS) + +printenv: printenv.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ printenv.o $(SHOBJ_LIBS) + +id: id.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ id.o $(SHOBJ_LIBS) + +whoami: whoami.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ whoami.o $(SHOBJ_LIBS) + +uname: uname.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ uname.o $(SHOBJ_LIBS) + +sync: sync.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ sync.o $(SHOBJ_LIBS) + +push: push.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ push.o $(SHOBJ_LIBS) + +ln: ln.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ ln.o $(SHOBJ_LIBS) + +unlink: unlink.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ unlink.o $(SHOBJ_LIBS) + +cut: cut.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ cut.o $(SHOBJ_LIBS) + +realpath: realpath.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ realpath.o $(SHOBJ_LIBS) + +strftime: strftime.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ strftime.o $(SHOBJ_LIBS) + +# pushd is a special case. We use the same source that the builtin version +# uses, with special compilation options. +# +pushd.c: ${topdir}/builtins/pushd.def + $(RM) $@ + ${BUILD_DIR}/builtins/mkbuiltins -D ${topdir}/builtins ${topdir}/builtins/pushd.def + +pushd.o: pushd.c + $(RM) $@ + $(SHOBJ_CC) -DHAVE_CONFIG_H -DPUSHD_AND_POPD -DLOADABLE_BUILTIN $(SHOBJ_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(INC) -c -o $@ $< + +pushd: pushd.o + $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ pushd.o $(SHOBJ_LIBS) + +clean: + $(RM) $(ALLPROG) $(OTHERPROG) *.o + -( cd perl && ${MAKE} ${MFLAGS} $@ ) + +mostlyclean: clean + -( cd perl && ${MAKE} ${MFLAGS} $@ ) + +distclean maintainer-clean: clean + $(RM) Makefile pushd.c + -( cd perl && ${MAKE} ${MFLAGS} $@ ) + +print.o: print.c +truefalse.o: truefalse.c +sleep.o: sleep.c +finfo.o: finfo.c +logname.o: logname.c +basename.o: basename.c +dirname.o: dirname.c +tty.o: tty.c +pathchk.o: pathchk.c +tee.o: tee.c +head.o: head.c +rmdir.o: rmdir.c +necho.o: necho.c +getconf.o: getconf.c +hello.o: hello.c +cat.o: cat.c +printenv.o: printenv.c +id.o: id.c +whoami.o: whoami.c +uname.o: uname.c +sync.o: sync.c +push.o: push.c +mkdir.o: mkdir.c +realpath.o: realpath.c +strftime.o: strftime.c diff --git a/lib/glob/glob.c b/lib/glob/glob.c index 038eb6e98..c6d7c05dc 100644 --- a/lib/glob/glob.c +++ b/lib/glob/glob.c @@ -123,6 +123,8 @@ static char **glob_dir_to_array __P((char *, char **, int)); extern char *glob_patscan __P((char *, char *, int)); extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int)); +extern char *glob_dirscan __P((char *, int)); + /* Compile `glob_loop.c' for single-byte characters. */ #define CHAR unsigned char #define INT int @@ -187,6 +189,9 @@ extglob_skipname (pat, dname, flags) se = pp + strlen (pp) - 1; /* end of string */ pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */ /* we should check for invalid extglob pattern here */ + if (pe == 0) + return 0; + /* if pe != se we have more of the pattern at the end of the extglob pattern. Check the easy case first ( */ if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0) @@ -1015,7 +1020,7 @@ glob_filename (pathname, flags) { char **result; unsigned int result_size; - char *directory_name, *filename, *dname; + char *directory_name, *filename, *dname, *fn; unsigned int directory_len; int free_dirname; /* flag */ int dflags; @@ -1031,6 +1036,18 @@ glob_filename (pathname, flags) /* Find the filename. */ filename = strrchr (pathname, '/'); +#if defined (EXTENDED_GLOB) + if (filename && extended_glob) + { + fn = glob_dirscan (pathname, '/'); +#if DEBUG_MATCHING + if (fn != filename) + fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename); +#endif + filename = fn; + } +#endif + if (filename == NULL) { filename = pathname; diff --git a/lib/glob/gmisc.c b/lib/glob/gmisc.c index 4bd37f640..7e97e70a1 100644 --- a/lib/glob/gmisc.c +++ b/lib/glob/gmisc.c @@ -42,6 +42,8 @@ #define WLPAREN L'(' #define WRPAREN L')' +extern char *glob_patscan __P((char *, char *, int)); + /* Return 1 of the first character of WSTRING could match the first character of pattern WPAT. Wide character version. */ int @@ -375,3 +377,34 @@ bad_bracket: return matlen; } + +/* Skip characters in PAT and return the final occurrence of DIRSEP. This + is only called when extended_glob is set, so we have to skip over extglob + patterns x(...) */ +char * +glob_dirscan (pat, dirsep) + char *pat; + int dirsep; +{ + char *p, *d, *pe, *se; + + d = pe = 0; + for (p = pat; p && *p; p++) + { + if (extglob_pattern_p (p)) + { + if (se == 0) + se = p + strlen (p) - 1; + pe = glob_patscan (p + 2, se, 0); + if (pe == 0) + continue; + else if (*pe == 0) + break; + p = pe - 1; /* will do increment above */ + continue; + } + if (*p == dirsep) + d = p; + } + return d; +} diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c index 7e7f538f5..ab73d76e6 100644 --- a/lib/glob/sm_loop.c +++ b/lib/glob/sm_loop.c @@ -533,7 +533,8 @@ matched: embedded () and []. If DELIM is 0, we scan until a matching `)' because we're scanning a `patlist'. Otherwise, we scan until we see DELIM. In all cases, we never scan past END. The return value is the - first character after the matching DELIM. */ + first character after the matching DELIM or NULL if the pattern is + empty or invalid. */ /*static*/ CHAR * PATSCAN (string, end, delim) CHAR *string, *end; diff --git a/lib/readline/doc/Makefile.old b/lib/readline/doc/Makefile.old new file mode 100644 index 000000000..58d4dd762 --- /dev/null +++ b/lib/readline/doc/Makefile.old @@ -0,0 +1,76 @@ +# This makefile for Readline library documentation is in -*- text -*- mode. +# Emacs likes it that way. +RM = rm -f + +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi +TEXI2HTML = texi2html +QUIETPS = #set this to -q to shut up dvips +DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky + +INSTALL_DATA = cp +infodir = /usr/local/info + +RLSRC = rlman.texinfo rluser.texinfo rltech.texinfo +HISTSRC = hist.texinfo hsuser.texinfo hstech.texinfo + +DVIOBJ = readline.dvi history.dvi +INFOOBJ = readline.info history.info +PSOBJ = readline.ps history.ps +HTMLOBJ = readline.html history.html + +all: info dvi html ps +nodvi: info html + +readline.dvi: $(RLSRC) + $(TEXI2DVI) rlman.texinfo + mv rlman.dvi readline.dvi + +readline.info: $(RLSRC) + $(MAKEINFO) --no-split -o $@ rlman.texinfo + +history.dvi: ${HISTSRC} + $(TEXI2DVI) hist.texinfo + mv hist.dvi history.dvi + +history.info: ${HISTSRC} + $(MAKEINFO) --no-split -o $@ hist.texinfo + +readline.ps: readline.dvi + $(RM) $@ + $(DVIPS) readline.dvi + +history.ps: history.dvi + $(RM) $@ + $(DVIPS) history.dvi + +readline.html: ${RLSRC} + $(TEXI2HTML) rlman.texinfo + sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman.html > readline.html + sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman_toc.html > readline_toc.html + $(RM) rlman.html rlman_toc.html + +history.html: ${HISTSRC} + $(TEXI2HTML) hist.texinfo + sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist.html > history.html + sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist_toc.html > history_toc.html + $(RM) hist.html hist_toc.html + +info: $(INFOOBJ) +dvi: $(DVIOBJ) +ps: $(PSOBJ) +html: $(HTMLOBJ) + +clean: + $(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \ + *.fns *.kys *.tps *.vrs *.o core + +distclean: clean +mostlyclean: clean + +maintainer-clean: clean + $(RM) *.dvi *.info *.info-* *.ps *.html + +install: info + ${INSTALL_DATA} readline.info $(infodir)/readline.info + ${INSTALL_DATA} history.info $(infodir)/history.info diff --git a/make_cmd.c b/make_cmd.c index 3bc540857..828d72e47 100644 --- a/make_cmd.c +++ b/make_cmd.c @@ -261,6 +261,9 @@ make_arith_for_expr (s) return ((WORD_LIST *)NULL); wd = make_word (s); wd->flags |= W_NOGLOB|W_NOSPLIT|W_QUOTED|W_DQUOTE; /* no word splitting or globbing */ +#if defined (PROCESS_SUBSTITUTION) + wd->flags |= W_NOPROCSUB; /* no process substitution */ +#endif result = make_word_list (wd, (WORD_LIST *)NULL); return result; } @@ -292,7 +295,7 @@ make_arith_for_command (exprs, action, lineno) s++; start = s; /* skip to the semicolon or EOS */ - i = skip_to_delim (start, 0, ";", SD_NOJMP); + i = skip_to_delim (start, 0, ";", SD_NOJMP|SD_NOPROCSUB); s = start + i; t = (i > 0) ? substring (start, 0, i) : (char *)NULL; diff --git a/parse.y b/parse.y index fe6af5ab1..174f3d65d 100644 --- a/parse.y +++ b/parse.y @@ -821,7 +821,7 @@ for_command: FOR WORD newline_list DO compound_list DONE arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE { $$ = make_arith_for_command ($2, $6, arith_for_lineno); - if (word_top > 0) word_top--; + if (word_top > 0) word_top--; } | FOR ARITH_FOR_EXPRS list_terminator newline_list '{' compound_list '}' { diff --git a/pcomplete.c b/pcomplete.c index 70cbc98a0..d4b31a66d 100644 --- a/pcomplete.c +++ b/pcomplete.c @@ -1187,8 +1187,8 @@ gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp) /* Build a command string with $0 == cs->command (command to execute for completion list) $1 == command name (command being completed) - $2 = word to be completed (possibly null) - $3 = previous word + $2 == word to be completed (possibly null) + $3 == previous word and run in with command substitution. Parse the results, one word per line, with backslashes allowed to escape newlines. Build a STRINGLIST from the results and return it. */ diff --git a/po/zh_CN.po b/po/zh_CN.po index b0757a678..2319c50e2 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -4,14 +4,15 @@ # Xin Ye , 2010. # Aron Xu , 2011. # Anthony Fok , 2013. +# Wylmer Wang , 2014. # msgid "" msgstr "" -"Project-Id-Version: bash 4.3-pre2\n" +"Project-Id-Version: bash 4.3-rc2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-11 11:19-0500\n" -"PO-Revision-Date: 2013-09-02 05:15+0800\n" -"Last-Translator: Anthony Fok \n" +"POT-Creation-Date: 2014-01-23 16:04-0500\n" +"PO-Revision-Date: 2014-05-01 20:07+0800\n" +"Last-Translator: Wylmer Wang \n" "Language-Team: Chinese (simplified) \n" "Language: zh_CN\n" "MIME-Version: 1.0\n" @@ -48,21 +49,21 @@ msgstr "%s: %s: 为关联数组赋值时必须使用下标" msgid "%s: cannot create: %s" msgstr "%s: 无法创建: %s" -#: bashline.c:3982 +#: bashline.c:3971 msgid "bash_execute_unix_command: cannot find keymap for command" msgstr "bash_execute_unix_command: 无法为命令找到键映射" -#: bashline.c:4069 +#: bashline.c:4058 #, c-format msgid "%s: first non-whitespace character is not `\"'" msgstr "%s: 第一个非空字符不是 `\"'" -#: bashline.c:4098 +#: bashline.c:4087 #, c-format msgid "no closing `%c' in %s" msgstr "%2$s 中没有闭合的 `%1$c'" -#: bashline.c:4132 +#: bashline.c:4121 #, c-format msgid "%s: missing colon separator" msgstr "%s: 缺少冒号分隔符" @@ -70,17 +71,17 @@ msgstr "%s: 缺少冒号分隔符" #: braces.c:321 #, c-format msgid "brace expansion: cannot allocate memory for %s" -msgstr "" +msgstr "花括号扩展:无法为 %s 分配内存" #: braces.c:413 #, c-format msgid "brace expansion: failed to allocate memory for %d elements" -msgstr "" +msgstr "花括号扩展:为 %d 个元素分配内存失败" #: braces.c:452 #, c-format msgid "brace expansion: failed to allocate memory for `%s'" -msgstr "" +msgstr "花括号扩展:为“%s”分配内存失败" #: builtins/alias.def:132 #, c-format @@ -143,7 +144,7 @@ msgstr "" msgid "HOME not set" msgstr "HOME 未设定" -#: builtins/cd.def:327 builtins/common.c:166 test.c:876 +#: builtins/cd.def:327 builtins/common.c:166 test.c:855 msgid "too many arguments" msgstr "参数太多" @@ -191,7 +192,7 @@ msgstr "%s: 无效选项" msgid "%s: invalid option name" msgstr "%s: 无效的选项名" -#: builtins/common.c:228 general.c:235 general.c:240 +#: builtins/common.c:228 general.c:234 general.c:239 #, c-format msgid "`%s': not a valid identifier" msgstr "`%s': 不是有效的标识符" @@ -320,18 +321,18 @@ msgstr "只能在函数中使用" #: builtins/declare.def:315 builtins/declare.def:509 #, c-format msgid "%s: reference variable cannot be an array" -msgstr "" +msgstr "%s:引用变量不能是数组" #: builtins/declare.def:324 #, c-format msgid "%s: nameref variable self references not allowed" -msgstr "" +msgstr "%s:不允许 nameref 变量引用自身" #: builtins/declare.def:398 msgid "cannot use `-f' to make functions" msgstr "无法用 `-f' 生成函数" -#: builtins/declare.def:410 execute_cmd.c:5361 +#: builtins/declare.def:410 execute_cmd.c:5349 #, c-format msgid "%s: readonly function" msgstr "%s: 只读函数" @@ -370,7 +371,7 @@ msgstr "%s: 未以动态方式加载" msgid "%s: cannot delete: %s" msgstr "%s: 无法删除: %s" -#: builtins/evalfile.c:140 builtins/hash.def:171 execute_cmd.c:5208 +#: builtins/evalfile.c:140 builtins/hash.def:171 execute_cmd.c:5196 #: shell.c:1481 #, c-format msgid "%s: is a directory" @@ -469,10 +470,8 @@ msgstr[0] "Shell 命令匹配关键字 `" #: builtins/help.def:182 #, c-format -msgid "" -"no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'." -msgstr "" -"没有与 `%s' 匹配的帮助主题。尝试 `help help' 或 `man -k %s' 或 `info %s'。" +msgid "no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'." +msgstr "没有与 `%s' 匹配的帮助主题。尝试 `help help' 或 `man -k %s' 或 `info %s'。" #: builtins/help.def:199 #, c-format @@ -594,7 +593,7 @@ msgstr "警告: %s: %s" #: builtins/printf.def:768 #, c-format msgid "format parsing problem: %s" -msgstr "" +msgstr "格式解析有问题:%s" #: builtins/printf.def:865 msgid "missing hex digit for \\x" @@ -610,9 +609,9 @@ msgid "no other directory" msgstr "无其他目录" #: builtins/pushd.def:354 -#, fuzzy, c-format +#, c-format msgid "%s: invalid argument" -msgstr "%s: 无效的 limit 参数" +msgstr "%s: 无效的参数" #: builtins/pushd.def:468 msgid "" @@ -641,12 +640,10 @@ msgid "" " \twith its position in the stack\n" " \n" " Arguments:\n" -" +N\tDisplays the Nth entry counting from the left of the list shown " -"by\n" +" +N\tDisplays the Nth entry counting from the left of the list shown by\n" " \tdirs when invoked without options, starting with zero.\n" " \n" -" -N\tDisplays the Nth entry counting from the right of the list shown " -"by\n" +" -N\tDisplays the Nth entry counting from the right of the list shown by\n" "\tdirs when invoked without options, starting with zero." msgstr "" "显示当前记住的目录列表。 目录\n" @@ -942,42 +939,42 @@ msgstr "时间格式: `%c': 无效的格式字符" msgid "pipe error" msgstr "管道错误" -#: execute_cmd.c:4386 +#: execute_cmd.c:4374 #, c-format msgid "%s: maximum function nesting level exceeded (%d)" -msgstr "" +msgstr "%s:超过了最大函数嵌套级别(%d)" -#: execute_cmd.c:4884 +#: execute_cmd.c:4872 #, c-format msgid "%s: restricted: cannot specify `/' in command names" msgstr "%s: 受限的: 无法在命令名中使用 `/'" -#: execute_cmd.c:4973 +#: execute_cmd.c:4961 #, c-format msgid "%s: command not found" msgstr "%s: 未找到命令" -#: execute_cmd.c:5206 +#: execute_cmd.c:5194 #, c-format msgid "%s: %s" msgstr "%s: %s" -#: execute_cmd.c:5243 +#: execute_cmd.c:5231 #, c-format msgid "%s: %s: bad interpreter" msgstr "%s: %s: 解释器错误" -#: execute_cmd.c:5280 -#, fuzzy, c-format +#: execute_cmd.c:5268 +#, c-format msgid "%s: cannot execute binary file: %s" -msgstr "%s: 无法执行二进制文件" +msgstr "%s: 无法执行二进制文件:%s" -#: execute_cmd.c:5352 -#, fuzzy, c-format +#: execute_cmd.c:5340 +#, c-format msgid "`%s': is a special builtin" -msgstr "%s 是 shell 内建\n" +msgstr "“%s”:是特殊内建值" -#: execute_cmd.c:5404 +#: execute_cmd.c:5392 #, c-format msgid "cannot duplicate fd %d to fd %d" msgstr "无法复制文件描述符 %d 到文件描述符 %d" @@ -1048,7 +1045,7 @@ msgstr "数值太大不可为算数进制的基" msgid "%s: expression error\n" msgstr "%s: 表达式错误\n" -#: general.c:62 +#: general.c:61 msgid "getcwd: cannot access parent directories" msgstr "getcwd: 无法访问父目录" @@ -1057,12 +1054,12 @@ msgstr "getcwd: 无法访问父目录" msgid "cannot reset nodelay mode for fd %d" msgstr "无法为文件描述符 %d 重置nodelay模式" -#: input.c:271 +#: input.c:269 #, c-format msgid "cannot allocate new file descriptor for bash input from fd %d" msgstr "无法从文件描述符 %d 为 bash 的输入获取一个新的文件描述符" -#: input.c:279 +#: input.c:277 #, c-format msgid "save_bash_input: buffer already exists for new fd %d" msgstr "save_bash_input: 已经存在新的文件描述符 %d 的缓冲区" @@ -1361,99 +1358,99 @@ msgstr "立即文档在第 %d 行被文件结束符分隔 (需要 `%s')" msgid "make_redirection: redirection instruction `%d' out of range" msgstr "make_redirection: 重定向指令 `%d' 越界" -#: parse.y:3278 parse.y:3561 +#: parse.y:3273 parse.y:3556 #, c-format msgid "unexpected EOF while looking for matching `%c'" msgstr "寻找匹配的 `%c' 是遇到了未预期的文件结束符" -#: parse.y:4170 +#: parse.y:4163 msgid "unexpected EOF while looking for `]]'" msgstr "寻找 `]]' 是遇到了未预期的文件结束符" -#: parse.y:4175 +#: parse.y:4168 #, c-format msgid "syntax error in conditional expression: unexpected token `%s'" msgstr "条件表达式中有语法错误: 未预期的符号 `%s'" -#: parse.y:4179 +#: parse.y:4172 msgid "syntax error in conditional expression" msgstr "条件表达式中有语法错误" -#: parse.y:4257 +#: parse.y:4250 #, c-format msgid "unexpected token `%s', expected `)'" msgstr "未预期的符号 `%s' ,需要 `)'" -#: parse.y:4261 +#: parse.y:4254 msgid "expected `)'" msgstr "需要 `)'" -#: parse.y:4289 +#: parse.y:4282 #, c-format msgid "unexpected argument `%s' to conditional unary operator" msgstr "一元条件运算符使用了未预期的参数 `%s'" -#: parse.y:4293 +#: parse.y:4286 msgid "unexpected argument to conditional unary operator" msgstr "一元条件运算符使用了未预期的参数" -#: parse.y:4339 +#: parse.y:4332 #, c-format msgid "unexpected token `%s', conditional binary operator expected" msgstr "未预期的符号 `%s',需要二元条件运算符" -#: parse.y:4343 +#: parse.y:4336 msgid "conditional binary operator expected" msgstr "需要二元条件运算符" -#: parse.y:4365 +#: parse.y:4358 #, c-format msgid "unexpected argument `%s' to conditional binary operator" msgstr "二元条件运算符使用了未预期的参数 `%s'" -#: parse.y:4369 +#: parse.y:4362 msgid "unexpected argument to conditional binary operator" msgstr "二元条件运算符使用了未预期的参数" -#: parse.y:4380 +#: parse.y:4373 #, c-format msgid "unexpected token `%c' in conditional command" msgstr "条件命令中有未预期的符号 `%c'" -#: parse.y:4383 +#: parse.y:4376 #, c-format msgid "unexpected token `%s' in conditional command" msgstr "条件命令中有未预期的符号 `%s'" -#: parse.y:4387 +#: parse.y:4380 #, c-format msgid "unexpected token %d in conditional command" msgstr "条件命令中有未预期的符号 %d" -#: parse.y:5737 +#: parse.y:5730 #, c-format msgid "syntax error near unexpected token `%s'" msgstr "未预期的符号 `%s' 附近有语法错误" -#: parse.y:5755 +#: parse.y:5748 #, c-format msgid "syntax error near `%s'" msgstr "`%s' 附近有语法错误" -#: parse.y:5765 +#: parse.y:5758 msgid "syntax error: unexpected end of file" msgstr "语法错误: 未预期的文件结尾" -#: parse.y:5765 +#: parse.y:5758 msgid "syntax error" msgstr "语法错误" -#: parse.y:5827 +#: parse.y:5820 #, c-format msgid "Use \"%s\" to leave the shell.\n" msgstr "使用 \"%s\" 退出 shell 。\n" -#: parse.y:5989 +#: parse.y:5982 msgid "unexpected EOF while looking for matching `)'" msgstr "寻找匹配的 `)' 时遇到了未预期的文件结束符" @@ -1568,9 +1565,8 @@ msgid "Shell options:\n" msgstr "Shell 选项:\n" #: shell.c:1835 -#, fuzzy msgid "\t-ilrsD or -c command or -O shopt_option\t\t(invocation only)\n" -msgstr "\t-irsD 或 -c 命令 或 -O shopt选项\t\t(仅适合调用)\n" +msgstr "\t-ilrsD 或 -c 命令 或 -O shopt选项\t\t(仅适合调用)\n" #: shell.c:1850 #, c-format @@ -1702,9 +1698,8 @@ msgid "Alarm (virtual)" msgstr "报警(虚拟)" #: siglist.c:163 -#, fuzzy msgid "Alarm (profile)" -msgstr "报警(总结)" +msgstr "报警(配置)" #: siglist.c:167 msgid "Window changed" @@ -1813,9 +1808,9 @@ msgid "command_substitute: cannot duplicate pipe as fd 1" msgstr "command_substitute: 无法将管道复制为文件描述符1" #: subst.c:5837 subst.c:8050 -#, fuzzy, c-format +#, c-format msgid "%s: invalid variable name for name reference" -msgstr "%s: %s: 追踪文件描述符的值无效" +msgstr "%s: 名称引用的变量名无效" #: subst.c:6048 #, c-format @@ -1838,9 +1833,7 @@ msgid "$%s: cannot assign in this way" msgstr "$%s: 无法这样赋值" #: subst.c:7917 -msgid "" -"future versions of the shell will force evaluation as an arithmetic " -"substitution" +msgid "future versions of the shell will force evaluation as an arithmetic substitution" msgstr "未来版本的 shell 会强制估值为算数替换" #: subst.c:8421 @@ -1871,17 +1864,17 @@ msgstr "需要 `)'" msgid "`)' expected, found %s" msgstr "需要`)',得到 %s" -#: test.c:281 test.c:742 test.c:745 +#: test.c:281 test.c:721 test.c:724 #, c-format msgid "%s: unary operator expected" msgstr "%s: 需要一元表达式" -#: test.c:468 test.c:785 +#: test.c:468 test.c:764 #, c-format msgid "%s: binary operator expected" msgstr "%s: 需要二元表达式" -#: test.c:860 +#: test.c:839 msgid "missing `]'" msgstr "缺少 `]'" @@ -1896,8 +1889,7 @@ msgstr "run_pending_traps: trap_list[%d] 中的错误值: %p" #: trap.c:375 #, c-format -msgid "" -"run_pending_traps: signal handler is SIG_DFL, resending %d (%s) to myself" +msgid "run_pending_traps: signal handler is SIG_DFL, resending %d (%s) to myself" msgstr "run_pending_traps: 信号处理器是 SIG_DFL,重新发送 %d (%s) 给自己" #: trap.c:428 @@ -1916,18 +1908,18 @@ msgid "shell level (%d) too high, resetting to 1" msgstr "shell 层次 (%d) 太高,重置为 1" #: variables.c:1865 -#, fuzzy, c-format +#, c-format msgid "%s: circular name reference" -msgstr "%s: %s: 追踪文件描述符的值无效" +msgstr "%s: 循环名称引用" #: variables.c:2228 msgid "make_local_variable: no function context at current scope" msgstr "make_local_variable: 当前作用域中没有函数上下文" #: variables.c:2247 -#, fuzzy, c-format +#, c-format msgid "%s: variable may not be assigned value" -msgstr "%s: 无法将文件描述符赋值给变量" +msgstr "%s: 变量不可赋值" #: variables.c:3646 msgid "all_local_variables: no function context at current scope" @@ -1971,22 +1963,17 @@ msgid "%s: %s: invalid value for trace file descriptor" msgstr "%s: %s: 追踪文件描述符的值无效" #: variables.c:5307 -#, fuzzy, c-format +#, c-format msgid "%s: %s: compatibility value out of range" -msgstr "%s: %s 越界" +msgstr "%s: %s 兼容性值超出范围" #: version.c:46 -#, fuzzy msgid "Copyright (C) 2013 Free Software Foundation, Inc." -msgstr "版权所有 (C) 2011 自由软件基金会" +msgstr "版权所有 (C) 2013 自由软件基金会" #: version.c:47 version2.c:47 -msgid "" -"License GPLv3+: GNU GPL version 3 or later \n" -msgstr "" -"许可证 GPLv3+: GNU GPL 许可证第三版或者更新版本 \n" +msgid "License GPLv3+: GNU GPL version 3 or later \n" +msgstr "许可证 GPLv3+: GNU GPL 许可证第三版或者更新版本 \n" #: version.c:86 version2.c:86 #, c-format @@ -1994,19 +1981,16 @@ msgid "GNU bash, version %s (%s)\n" msgstr "GNU bash,版本 %s (%s)\n" #: version.c:91 version2.c:91 -#, fuzzy msgid "This is free software; you are free to change and redistribute it." -msgstr "本软件是自由软件,您可以自由地更改和重新发布。\n" +msgstr "本软件是自由软件;您可以自由地更改和重新发布。" #: version.c:92 version2.c:92 -#, fuzzy msgid "There is NO WARRANTY, to the extent permitted by law." -msgstr "在法律许可的情况下特此明示,本软件不提供任何担保。\n" +msgstr "在法律许可的范围内,本软件不提供任何担保。" #: version2.c:46 -#, fuzzy msgid "Copyright (C) 2012 Free Software Foundation, Inc." -msgstr "版权所有 (C) 2011 自由软件基金会" +msgstr "版权所有 (C) 2012 自由软件基金会" #: xmalloc.c:91 #, c-format @@ -2037,13 +2021,8 @@ msgid "unalias [-a] name [name ...]" msgstr "unalias [-a] 名称 [名称 ...]" #: builtins.c:51 -#, fuzzy -msgid "" -"bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-" -"x keyseq:shell-command] [keyseq:readline-function or readline-command]" -msgstr "" -"bind [-lpvsPVS] [-m 键映射] [-f 文件名] [-q 名称] [-u 名称] [-r 键序列] [-x " -"键序列:shell命令] [键序列:行读取函数 或 行读取命令]" +msgid "bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]" +msgstr "bind [-lpsvPSVX] [-m 键映射] [-f 文件名] [-q 名称] [-u 名称] [-r 键序列] [-x 键序列:shell命令] [键序列:行读取函数 或 行读取命令]" #: builtins.c:54 msgid "break [n]" @@ -2062,9 +2041,8 @@ msgid "caller [expr]" msgstr "caller [表达式]" #: builtins.c:64 -#, fuzzy msgid "cd [-L|[-P [-e]] [-@]] [dir]" -msgstr "cd [-L|[-P [-e]]] [目录]" +msgstr "cd [-L|[-P [-e]] [-@]] [目录]" #: builtins.c:66 msgid "pwd [-LP]" @@ -2087,9 +2065,8 @@ msgid "command [-pVv] command [arg ...]" msgstr "command [-pVv] 命令 [参数 ...]" #: builtins.c:76 -#, fuzzy msgid "declare [-aAfFgilnrtux] [-p] [name[=value] ...]" -msgstr "declare [-aAfFgilrtux] [-p] [名称[=值] ...]" +msgstr "declare [-aAfFgilnrtux] [-p] [名称[=值] ...]" #: builtins.c:78 msgid "typeset [-aAfFgilrtux] [-p] name[=value] ..." @@ -2152,12 +2129,8 @@ msgid "help [-dms] [pattern ...]" msgstr "help [-dms] [模式 ...]" #: builtins.c:121 -msgid "" -"history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg " -"[arg...]" -msgstr "" -"history [-c] [-d 偏移量] [n] 或 history -anrw [文件名] 或 history -ps 参数 " -"[参数...]" +msgid "history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]" +msgstr "history [-c] [-d 偏移量] [n] 或 history -anrw [文件名] 或 history -ps 参数 [参数...]" #: builtins.c:125 msgid "jobs [-lnprs] [jobspec ...] or jobs -x command [args]" @@ -2168,24 +2141,16 @@ msgid "disown [-h] [-ar] [jobspec ...]" msgstr "disown [-h] [-ar] [任务声明 ...]" #: builtins.c:132 -msgid "" -"kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l " -"[sigspec]" -msgstr "" -"kill [-s 信号声明 | -n 信号编号 | -信号声明] 进程号 | 任务声明 ... 或 kill -" -"l [信号声明]" +msgid "kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]" +msgstr "kill [-s 信号声明 | -n 信号编号 | -信号声明] 进程号 | 任务声明 ... 或 kill -l [信号声明]" #: builtins.c:134 msgid "let arg [arg ...]" msgstr "let 参数 [参数 ...]" #: builtins.c:136 -msgid "" -"read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p " -"prompt] [-t timeout] [-u fd] [name ...]" -msgstr "" -"read [-ers] [-a 数组] [-d 分隔符] [-i 缓冲区文字] [-n 读取字符数] [-N 读取字" -"符数] [-p 提示符] [-t 超时] [-u 文件描述符] [名称 ...]" +msgid "read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]" +msgstr "read [-ers] [-a 数组] [-d 分隔符] [-i 缓冲区文字] [-n 读取字符数] [-N 读取字符数] [-p 提示符] [-t 超时] [-u 文件描述符] [名称 ...]" #: builtins.c:138 msgid "return [n]" @@ -2196,9 +2161,8 @@ msgid "set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]" msgstr "set [--abefhkmnptuvxBCHP] [-o 选项名] [--] [参数 ...]" #: builtins.c:142 -#, fuzzy msgid "unset [-f] [-v] [-n] [name ...]" -msgstr "unset [-f] [-v] [名称 ...]" +msgstr "unset [-f] [-v] [-n] [名称 ...]" #: builtins.c:144 msgid "export [-fn] [name[=value] ...] or export -p" @@ -2245,23 +2209,20 @@ msgid "type [-afptP] name [name ...]" msgstr "type [-afptP] 名称 [名称 ...]" #: builtins.c:169 -#, fuzzy msgid "ulimit [-SHabcdefilmnpqrstuvxT] [limit]" -msgstr "ulimit [-SHacdefilmnpqrstuvx] [限制]" +msgstr "ulimit [-SHabcdefilmnpqrstuvxT] [限制]" #: builtins.c:172 msgid "umask [-p] [-S] [mode]" msgstr "umask [-p] [-S] [模式]" #: builtins.c:175 -#, fuzzy msgid "wait [-n] [id ...]" -msgstr "wait [编号]" +msgstr "wait [-n] [标识 ...]" #: builtins.c:179 -#, fuzzy msgid "wait [pid ...]" -msgstr "wait [进程号]" +msgstr "wait [pid ...]" #: builtins.c:182 msgid "for NAME [in WORDS ... ] ; do COMMANDS; done" @@ -2284,9 +2245,7 @@ msgid "case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac" msgstr "case 词 in [模式 [| 模式]...) 命令 ;;]... esac" #: builtins.c:192 -msgid "" -"if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else " -"COMMANDS; ] fi" +msgid "if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi" msgstr "if 命令; then 命令; [ elif 命令; then 命令; ]... [ else 命令; ] fi" #: builtins.c:194 @@ -2346,41 +2305,24 @@ msgid "printf [-v var] format [arguments]" msgstr "printf [-v var] 格式 [参数]" #: builtins.c:229 -msgid "" -"complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-" -"W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S " -"suffix] [name ...]" -msgstr "" -"complete [-abcdefgjksuv] [-pr] [-DE] [-o 选项] [-A 动作] [-G 全局模式] [-W 词" -"语列表] [-F 函数] [-C 命令] [-X 过滤模式] [-P 前缀] [-S 后缀] [名称 ...]" +msgid "complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]" +msgstr "complete [-abcdefgjksuv] [-pr] [-DE] [-o 选项] [-A 动作] [-G 全局模式] [-W 词语列表] [-F 函数] [-C 命令] [-X 过滤模式] [-P 前缀] [-S 后缀] [名称 ...]" #: builtins.c:233 -msgid "" -"compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] " -"[-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]" -msgstr "" -"compgen [-abcdefgjksuv] [-o 选项] [-A 动作] [-G 全局模式] [-W 词语列表] [-" -"F 函数] [-C 命令] [-X 过滤模式] [-P 前缀] [-S 后缀] [词语]" +msgid "compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]" +msgstr "compgen [-abcdefgjksuv] [-o 选项] [-A 动作] [-G 全局模式] [-W 词语列表] [-F 函数] [-C 命令] [-X 过滤模式] [-P 前缀] [-S 后缀] [词语]" #: builtins.c:237 msgid "compopt [-o|+o option] [-DE] [name ...]" msgstr "compopt [-o|+o 选项] [-DE] [名称 ...]" #: builtins.c:240 -msgid "" -"mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c " -"quantum] [array]" -msgstr "" -"mapfile [-n 计数] [-O 起始序号] [-s 计数] [-t] [-u fd] [-C 回调] [-c 量子] " -"[数组]" +msgid "mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]" +msgstr "mapfile [-n 计数] [-O 起始序号] [-s 计数] [-t] [-u fd] [-C 回调] [-c 量子] [数组]" #: builtins.c:242 -msgid "" -"readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c " -"quantum] [array]" -msgstr "" -"readarray [-n 计数] [-O 起始序号] [-s 计数] [-t] [-u fd] [-C 回调] [-c 量子] " -"[数组]" +msgid "readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]" +msgstr "readarray [-n 计数] [-O 起始序号] [-s 计数] [-t] [-u fd] [-C 回调] [-c 量子] [数组]" #: builtins.c:254 msgid "" @@ -2397,8 +2339,7 @@ msgid "" " -p\tPrint all defined aliases in a reusable format\n" " \n" " Exit Status:\n" -" alias returns true unless a NAME is supplied for which no alias has " -"been\n" +" alias returns true unless a NAME is supplied for which no alias has been\n" " defined." msgstr "" "定义或显示别名。\n" @@ -2434,7 +2375,6 @@ msgstr "" " 返回成功,除非“名字“不是一个已存在的别名。" #: builtins.c:289 -#, fuzzy msgid "" "Set Readline key bindings and variables.\n" " \n" @@ -2446,24 +2386,20 @@ msgid "" " Options:\n" " -m keymap Use KEYMAP as the keymap for the duration of this\n" " command. Acceptable keymap names are emacs,\n" -" emacs-standard, emacs-meta, emacs-ctlx, vi, vi-" -"move,\n" +" emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,\n" " vi-command, and vi-insert.\n" " -l List names of functions.\n" " -P List function names and bindings.\n" " -p List functions and bindings in a form that can be\n" " reused as input.\n" -" -S List key sequences that invoke macros and their " -"values\n" -" -s List key sequences that invoke macros and their " -"values\n" +" -S List key sequences that invoke macros and their values\n" +" -s List key sequences that invoke macros and their values\n" " in a form that can be reused as input.\n" " -V List variable names and values\n" " -v List variable names and values in a form that can\n" " be reused as input.\n" " -q function-name Query about which keys invoke the named function.\n" -" -u function-name Unbind all keys which are bound to the named " -"function.\n" +" -u function-name Unbind all keys which are bound to the named function.\n" " -r keyseq Remove the binding for KEYSEQ.\n" " -f filename Read key bindings from FILENAME.\n" " -x keyseq:shell-command\tCause SHELL-COMMAND to be executed when\n" @@ -2474,18 +2410,18 @@ msgid "" " Exit Status:\n" " bind returns 0 unless an unrecognized option is given or an error occurs." msgstr "" -"设定行读取键绑定和变量。\n" +"设定 Readline 键绑定和变量。\n" " \n" -" 绑定一个键序列到一个行读取函数或者宏,或者设定一个\n" -" 行读取变量。非选项参数的语法和 ~/.inputrc 文件中的等\n" -" 同,但是必须作为一个参数被传递,\n" -" 例如,bind '\"\\C-x\\C-r\": re-read-init-file'.\n" +" 绑定一个键序列到一个 Readline 函数或者宏,或者设定一个\n" +" Readline 变量。非选项参数的语法和 ~/.inputrc 文件中的等\n" +" 同,但是必须作为单个参数传递:\n" +" 例如,绑定 '\"\\C-x\\C-r\": re-read-init-file'\n" " \n" " 选项:\n" " -m 键映射 在此命令执行过程中使用指定的键映射。\n" " 可以被接受的键映射名字有 emacs、\n" " emacs-standard、emacs-meta、emacs-ctlx、vi、\n" -" vi-move、vi-command、和 vi-insert。\n" +" vi-move、vi-command 和 vi-insert。\n" " -l 列出函数名称。\n" " -P 列出函数名称和绑定。\n" " -p 以可以重新用作输入的格式列出函数名称和\n" @@ -2496,15 +2432,16 @@ msgstr "" " -V 列出变量名成和它们的值\n" " -v 以可以重新用作输入的格式列出变量的名称\n" " 和它们的值\n" -" -q 函数名 查询指定的函数可以由哪些键启动。\n" -" -u 函数名 反绑定所有绑定至指定函数的键。\n" -" -r 键序列 取消指定键序列的绑定。\n" -" -f 文件名 从指定文件中读取键绑定。\n" -" -x 键序列:shell命令\t当指定的键序列被输入时,执行\n" -" \t\t\t\t指定的shell命令\n" +" -q 函数名 查询指定的函数可以由哪些键启动。\n" +" -u 函数名 解绑所有绑定至指定函数的键。\n" +" -r 键序列 解除指定键序列的绑定。\n" +" -f 文件名 从指定文件中读取键绑定。\n" +" -x 键序列:shell命令\t输入键序列时,执行指定的shell命令\n" +" -X 以可重新用作输入的格式列出与 -x 及相\n" +" 关命令绑定的键序列。\n" " \n" " 退出状态:\n" -" 除非使用了无法辨认的选项或者错误发生,否则返回0." +" 除非给定的选项无法辨认或者发生错误,否则返回0。" #: builtins.c:328 msgid "" @@ -2548,8 +2485,7 @@ msgid "" " \n" " Execute SHELL-BUILTIN with arguments ARGs without performing command\n" " lookup. This is useful when you wish to reimplement a shell builtin\n" -" as a shell function, but need to execute the builtin within the " -"function.\n" +" as a shell function, but need to execute the builtin within the function.\n" " \n" " Exit Status:\n" " Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is\n" @@ -2562,8 +2498,7 @@ msgstr "" " 并且希望在函数之内执行该 shell 内建的情况下有用处。\n" " \n" " 退出状态:\n" -" 以 SHELL-BUILTIN 内建的退出状态为准,或者如果 SHELL-BUILTIN不是一个 " -"shell 内建时\n" +" 以 SHELL-BUILTIN 内建的退出状态为准,或者如果 SHELL-BUILTIN不是一个 shell 内建时\n" " 为假。." #: builtins.c:367 @@ -2595,26 +2530,19 @@ msgstr "" " 果为0。" #: builtins.c:385 -#, fuzzy msgid "" "Change the shell working directory.\n" " \n" -" Change the current directory to DIR. The default DIR is the value of " -"the\n" +" Change the current directory to DIR. The default DIR is the value of the\n" " HOME shell variable.\n" " \n" -" The variable CDPATH defines the search path for the directory " -"containing\n" -" DIR. Alternative directory names in CDPATH are separated by a colon " -"(:).\n" -" A null directory name is the same as the current directory. If DIR " -"begins\n" +" The variable CDPATH defines the search path for the directory containing\n" +" DIR. Alternative directory names in CDPATH are separated by a colon (:).\n" +" A null directory name is the same as the current directory. If DIR begins\n" " with a slash (/), then CDPATH is not used.\n" " \n" -" If the directory is not found, and the shell option `cdable_vars' is " -"set,\n" -" the word is assumed to be a variable name. If that variable has a " -"value,\n" +" If the directory is not found, and the shell option `cdable_vars' is set,\n" +" the word is assumed to be a variable name. If that variable has a value,\n" " its value is used for DIR.\n" " \n" " Options:\n" @@ -2625,18 +2553,15 @@ msgid "" " \tof `..'\n" " -e\tif the -P option is supplied, and the current working directory\n" " \tcannot be determined successfully, exit with a non-zero status\n" -" -@ on systems that support it, present a file with extended " -"attributes\n" +" -@ on systems that support it, present a file with extended attributes\n" " as a directory containing the file attributes\n" " \n" " The default is to follow symbolic links, as if `-L' were specified.\n" -" `..' is processed by removing the immediately previous pathname " -"component\n" +" `..' is processed by removing the immediately previous pathname component\n" " back to a slash or the beginning of DIR.\n" " \n" " Exit Status:\n" -" Returns 0 if the directory is changed, and if $PWD is set successfully " -"when\n" +" Returns 0 if the directory is changed, and if $PWD is set successfully when\n" " -P is used; non-zero otherwise." msgstr "" "改变 shell 工作目录。\n" @@ -2654,15 +2579,19 @@ msgstr "" " 被当作 DIR 目录。\n" " \n" " 选项:\n" -" -L\t强制跟随符号链接。\n" -" -P\t使用物理目录结构而不跟随符号链接\n" -" -e\t如果使用了 -P 参数,但不能成功确定当前工作目录时,\n" -" \t返回非零的返回值。 \n" +" -L\t强制跟随符号链接:在处理完“..”实例后解析 DIR 中的 符号链接\n" +" -P\t使用物理目录结构而不跟随符号链接:在处理“..”实例之前解析\n" +" \tDIR 中的符号链接。\n" +" -e\t如果使用了 -P 参数,但不能成功确定当前工作目录,以非零返回值\n" +" \t退出。\n" +" -@ 在支持的系统上,以包含文件属性的文件夹目录的方式展现带扩展\n" +" 属性的文件。\n" " \n" " 默认情况下跟随符号链接,如同指定 `-L'。\n" +" “..”的处理方式是直接移除前面的路径元素,到斜杠或 DIR 的开头。\n" " \n" " 退出状态:\n" -" 如果目录改变,或在使用 -P 选项时 $PWD 修改成功时返回0,否则非零。" +" 如果目录改变,或在使用 -P 选项时 $PWD 修改成功时返回 0,否则非零。" #: builtins.c:422 msgid "" @@ -2737,8 +2666,7 @@ msgid "" "Execute a simple command or display information about commands.\n" " \n" " Runs COMMAND with ARGS suppressing shell function lookup, or display\n" -" information about the specified COMMANDs. Can be used to invoke " -"commands\n" +" information about the specified COMMANDs. Can be used to invoke commands\n" " on disk when a function with the same name exists.\n" " \n" " Options:\n" @@ -2766,7 +2694,6 @@ msgstr "" " 返回 COMMAND 命令的返回状态,或者当找不到 COMMAND 命令时失败。" #: builtins.c:487 -#, fuzzy msgid "" "Set variable values and attributes.\n" " \n" @@ -2797,8 +2724,7 @@ msgid "" " Variables with the integer attribute have arithmetic evaluation (see\n" " the `let' command) performed when the variable is assigned a value.\n" " \n" -" When used in a function, `declare' makes NAMEs local, as with the " -"`local'\n" +" When used in a function, `declare' makes NAMEs local, as with the `local'\n" " command. The `-g' option suppresses this behavior.\n" " \n" " Exit Status:\n" @@ -2812,8 +2738,8 @@ msgstr "" " \n" " 选项:\n" " -f\t限制动作或显示函数名称和定义\n" -" -F\t限制仅显示函数名称(以及行号和调试时\n" -" \t源文件名)\n" +" -F\t限制仅显示函数名称(以及调试时的行号和源文件名)\n" +" -g\t在 shell 函数中使用时创建全局变量,否则忽略\n" " -p\t显示每个 NAME 变量的属性和值\n" " \n" " 设定属性的选项:\n" @@ -2821,6 +2747,7 @@ msgstr "" " -A\t使 NAME 成为关联数组 (如果支持)\n" " -i\t使 NAME 带有 `integer' (整数)属性\n" " -l\t将 NAME 在赋值时转为小写\n" +" -n\t使 NAME 作为对以自身值命令的变量的一个引用\n" " -r\t将 NAME 变为只读\n" " -t\t使 NAME 带有 `trace' (追踪)属性\n" " -u\t将 NAME 在赋值时转为大写\n" @@ -2832,10 +2759,10 @@ msgstr "" " `let' 命令)\n" " \n" " 在函数中使用时,`declare' 使 NAME 成为本地变量,和 `local'\n" -" 命令一致。\n" +" 命令一致。`-g' 选项将阻止此行为。\n" " \n" " 退出状态:\n" -" 返回成功除非使用了无效选项或者发生错误。" +" 返回成功,除非使用了无效选项或者发生错误。" #: builtins.c:527 msgid "" @@ -2848,7 +2775,6 @@ msgstr "" " 废弃。参见 `help declare'。" #: builtins.c:535 -#, fuzzy msgid "" "Define local variables.\n" " \n" @@ -2864,10 +2790,10 @@ msgid "" msgstr "" "定义本地变量。\n" " \n" -" 创建一个以 NAME 为名称的变量,并且将 VALUE 赋值给它。\n" +" 创建一个以 NAME 为名称的局部变量,并且将 VALUE 赋值给它。\n" " OPTION 选项可以是任何能被 `declare' 接受的选项。\n" " \n" -" 本地变量只能在函数内部被使用,它们只能在定义它们的函数内\n" +" 局部变量只能在函数内部被使用,它们只能在声明它们的函数内\n" " 部以及子函数中可见。\n" " \n" " 退出状态:\n" @@ -2875,12 +2801,10 @@ msgstr "" " 执行一个函数。" #: builtins.c:552 -#, fuzzy msgid "" "Write arguments to the standard output.\n" " \n" -" Display the ARGs, separated by a single space character and followed by " -"a\n" +" Display the ARGs, separated by a single space character and followed by a\n" " newline, on the standard output.\n" " \n" " Options:\n" @@ -2910,7 +2834,7 @@ msgid "" msgstr "" "将参数写到标准输出。\n" " \n" -" 在标准输出上显示 ARG 参数后跟一个换行。\n" +" 在标准输出上显示 ARG 参数,以单个空格分隔,后跟一个换行。\n" " \n" " 选项:\n" " -n\t不要追加换行\n" @@ -2922,15 +2846,16 @@ msgstr "" " \\b\t退格\n" " \\c\t抑制更多的输出\n" " \\e\t转义字符\n" -" \\f\t格式提供\n" +" \\E\t转义字符\n" +" \\f\t换页\n" " \\n\t换行\n" " \\r\t回车\n" " \\t\t横向制表符\n" " \\v\t纵向制表符\n" " \\\\\t反斜杠\n" -" \\0nnn\t以 NNN (八进制)为 ASCII 码的字符。 NNN 可以是\n" -" \t0到3个八进制数字\n" -" \\xHH\t以 HH (十六进制)为值的八比特字符。HH可以是\n" +" \\0nnn\t(八进制) ASCII 码为 NNN 的字符。NNN 可以是\n" +" \t0 到 3 个八进制数字\n" +" \\xHH\t值是 HH (十六进制)的 8位 字符。HH可以是\n" " \t一个或两个十六进制数字\n" " \n" " 退出状态:\n" @@ -3012,8 +2937,7 @@ msgstr "" msgid "" "Execute arguments as a shell command.\n" " \n" -" Combine ARGs into a single string, use the result as input to the " -"shell,\n" +" Combine ARGs into a single string, use the result as input to the shell,\n" " and execute the resulting commands.\n" " \n" " Exit Status:\n" @@ -3110,8 +3034,7 @@ msgid "" "Replace the shell with the given command.\n" " \n" " Execute COMMAND, replacing this shell with the specified program.\n" -" ARGUMENTS become the arguments to COMMAND. If COMMAND is not " -"specified,\n" +" ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,\n" " any redirections take effect in the current shell.\n" " \n" " Options:\n" @@ -3119,13 +3042,11 @@ msgid "" " -c\t\texecute COMMAND with an empty environment\n" " -l\t\tplace a dash in the zeroth argument to COMMAND\n" " \n" -" If the command cannot be executed, a non-interactive shell exits, " -"unless\n" +" If the command cannot be executed, a non-interactive shell exits, unless\n" " the shell option `execfail' is set.\n" " \n" " Exit Status:\n" -" Returns success unless COMMAND is not found or a redirection error " -"occurs." +" Returns success unless COMMAND is not found or a redirection error occurs." msgstr "" "使用指定命令替换 shell。\n" " \n" @@ -3160,8 +3081,7 @@ msgstr "" msgid "" "Exit a login shell.\n" " \n" -" Exits a login shell with exit status N. Returns an error if not " -"executed\n" +" Exits a login shell with exit status N. Returns an error if not executed\n" " in a login shell." msgstr "" "退出一个登录 shell.\n" @@ -3173,15 +3093,13 @@ msgstr "" msgid "" "Display or execute commands from the history list.\n" " \n" -" fc is used to list or edit and re-execute commands from the history " -"list.\n" +" fc is used to list or edit and re-execute commands from the history list.\n" " FIRST and LAST can be numbers specifying the range, or FIRST can be a\n" " string, which means the most recent command beginning with that\n" " string.\n" " \n" " Options:\n" -" -e ENAME\tselect which editor to use. Default is FCEDIT, then " -"EDITOR,\n" +" -e ENAME\tselect which editor to use. Default is FCEDIT, then EDITOR,\n" " \t\tthen vi\n" " -l \tlist lines instead of editing\n" " -n\tomit line numbers when listing\n" @@ -3195,8 +3113,7 @@ msgid "" " the last command.\n" " \n" " Exit Status:\n" -" Returns success or status of executed command; non-zero if an error " -"occurs." +" Returns success or status of executed command; non-zero if an error occurs." msgstr "" "从历史列表中显示或者执行命令。\n" " \n" @@ -3246,10 +3163,8 @@ msgstr "" msgid "" "Move jobs to the background.\n" " \n" -" Place the jobs identified by each JOB_SPEC in the background, as if " -"they\n" -" had been started with `&'. If JOB_SPEC is not present, the shell's " -"notion\n" +" Place the jobs identified by each JOB_SPEC in the background, as if they\n" +" had been started with `&'. If JOB_SPEC is not present, the shell's notion\n" " of the current job is used.\n" " \n" " Exit Status:\n" @@ -3265,13 +3180,11 @@ msgstr "" " 返回成功除非任务管理没有启用或者错误发生。" #: builtins.c:784 -#, fuzzy msgid "" "Remember or display program locations.\n" " \n" " Determine and remember the full pathname of each command NAME. If\n" -" no arguments are given, information about remembered commands is " -"displayed.\n" +" no arguments are given, information about remembered commands is displayed.\n" " \n" " Options:\n" " -d\t\tforget the remembered location of each NAME\n" @@ -3326,8 +3239,7 @@ msgid "" " PATTERN\tPattern specifiying a help topic\n" " \n" " Exit Status:\n" -" Returns success unless PATTERN is not found or an invalid option is " -"given." +" Returns success unless PATTERN is not found or an invalid option is given." msgstr "" "显示内建命令的相关信息。\n" " \n" @@ -3374,8 +3286,7 @@ msgid "" " \n" " If the $HISTTIMEFORMAT variable is set and not null, its value is used\n" " as a format string for strftime(3) to print the time stamp associated\n" -" with each displayed history entry. No time stamps are printed " -"otherwise.\n" +" with each displayed history entry. No time stamps are printed otherwise.\n" " \n" " Exit Status:\n" " Returns success unless an invalid option is given or an error occurs." @@ -3411,7 +3322,6 @@ msgstr "" " 返回成功,除非使用了无效的选项或者发生错误。" #: builtins.c:869 -#, fuzzy msgid "" "Display status of jobs.\n" " \n" @@ -3420,7 +3330,7 @@ msgid "" " \n" " Options:\n" " -l\tlists process IDs in addition to the normal information\n" -" -n\tlists only processes that have changed status since the last\n" +" -n\tlist only processes that have changed status since the last\n" " \tnotification\n" " -p\tlists process IDs only\n" " -r\trestrict output to running jobs\n" @@ -3523,15 +3433,13 @@ msgstr "" " 返回成功,除非使用了无效的选项或者有错误发生。" #: builtins.c:938 -#, fuzzy msgid "" "Evaluate arithmetic expressions.\n" " \n" " Evaluate each ARG as an arithmetic expression. Evaluation is done in\n" " fixed-width integers with no check for overflow, though division by 0\n" " is trapped and flagged as an error. The following list of operators is\n" -" grouped into levels of equal-precedence operators. The levels are " -"listed\n" +" grouped into levels of equal-precedence operators. The levels are listed\n" " in order of decreasing precedence.\n" " \n" " \tid++, id--\tvariable post-increment, post-decrement\n" @@ -3569,12 +3477,11 @@ msgid "" msgstr "" "估值算数表达式。\n" " \n" -" 将每个 ARG 参赛作为算数表达式来估值。估值的计算以等宽的整\n" +" 将每个 ARG 参数作为算数表达式来估值。估值的计算以等宽的整\n" " 数完成,不带溢出检测,不过除 0 是被置陷阱的并且会报一个错\n" " 误。下列操作符被按照相同的算数优先级组合。列表的顺序按照\n" " 优先级从高至低。\n" " \n" -" \n" " \tid++, id--\t变量后置加,后置减\n" " \t++id, --id\t变量前置加,前置减\n" " \t-, +\t\t一元减法,一元加法\n" @@ -3585,45 +3492,38 @@ msgstr "" " \t<<, >>\t\t向左和向右比特移位\n" " \t<=, >=, <, >\t比较\n" " \t==, !=\t\t等于,不等于\n" -" \t&\t\t比特与\n" -" \t^\t\t比特异或\n" -" \t|\t\t比特或\n" -" \t&&\t\t逻辑与\n" -" \t||\t\t逻辑或\n" +" \t&\t\t按位 与\n" +" \t^\t\t按位 异或\n" +" \t|\t\t按位 或\n" +" \t&&\t\t逻辑 与\n" +" \t||\t\t逻辑 或\n" " \texpr ? expr : expr\n" " \t\t\t条件操作符\n" " \t=, *=, /=, %=,\n" " \t+=, -=, <<=, >>=,\n" " \t&=, ^=, |=\t赋值\n" " \n" -" Shell 变量允许作为操作数。表达式中的变量的名称会被取代\n" -" 以值(强制转换为等宽的整数)。表达式中的变量不需要打开\n" -" 整数属性。\n" -" \n" +" Shell 变量允许作为操作数。表达式中的变量的名称会用它的值取代\n" +" (强制转换为等宽的整数)。表达式中的变量不需要打开整数属性。\n" " \n" " 操作符按照优先级进行估值。括号中的子表达式将被先估值,\n" " 并有可能重载上述的表达式规则。\n" " \n" -" \n" " 退出状态:\n" " 如果最后一个 ARG 参数估值为0,则 let 返回1; 否则 let 返回0。" #: builtins.c:983 -#, fuzzy msgid "" "Read a line from the standard input and split it into fields.\n" " \n" " Reads a single line from the standard input, or from file descriptor FD\n" -" if the -u option is supplied. The line is split into fields as with " -"word\n" +" if the -u option is supplied. The line is split into fields as with word\n" " splitting, and the first word is assigned to the first NAME, the second\n" " word to the second NAME, and so on, with any leftover words assigned to\n" -" the last NAME. Only the characters found in $IFS are recognized as " -"word\n" +" the last NAME. Only the characters found in $IFS are recognized as word\n" " delimiters.\n" " \n" -" If no NAMEs are supplied, the line read is stored in the REPLY " -"variable.\n" +" If no NAMEs are supplied, the line read is stored in the REPLY variable.\n" " \n" " Options:\n" " -a array\tassign the words read to sequential indices of the array\n" @@ -3635,15 +3535,13 @@ msgid "" " -n nchars\treturn after reading NCHARS characters rather than waiting\n" " \t\tfor a newline, but honor a delimiter if fewer than NCHARS\n" " \t\tcharacters are read before the delimiter\n" -" -N nchars\treturn only after reading exactly NCHARS characters, " -"unless\n" +" -N nchars\treturn only after reading exactly NCHARS characters, unless\n" " \t\tEOF is encountered or read times out, ignoring any delimiter\n" " -p prompt\toutput the string PROMPT without a trailing newline before\n" " \t\tattempting to read\n" " -r\t\tdo not allow backslashes to escape any characters\n" " -s\t\tdo not echo input coming from a terminal\n" -" -t timeout\ttime out and return failure if a complete line of input " -"is\n" +" -t timeout\ttime out and return failure if a complete line of input is\n" " \t\tnot read within TIMEOUT seconds. The value of the TMOUT\n" " \t\tvariable is the default timeout. TIMEOUT may be a\n" " \t\tfractional number. If TIMEOUT is 0, read returns immediately,\n" @@ -3653,10 +3551,8 @@ msgid "" " -u fd\t\tread from file descriptor FD instead of the standard input\n" " \n" " Exit Status:\n" -" The return code is zero, unless end-of-file is encountered, read times " -"out\n" -" (in which case it's greater than 128), a variable assignment error " -"occurs,\n" +" The return code is zero, unless end-of-file is encountered, read times out\n" +" (in which case it's greater than 128), a variable assignment error occurs,\n" " or an invalid file descriptor is supplied as the argument to -u." msgstr "" "从标准输入读取一行并将其分为不同的域。\n" @@ -3693,8 +3589,8 @@ msgstr "" " -u fd\t\t从文件描述符 FD 中读取,而不是标准输入\n" " \n" " 退出状态:\n" -" 返回码为零,除非遇到了文件结束符,读超时,或者无效的文\n" -" 件描述符作为参数传递给了 -u 选项。" +" 返回码为零,除非遇到了文件结束符,读超时(值将大于128),变量赋值出错\n" +" 或者将无效的文件描述符作为参数传递给了 -u 选项。" #: builtins.c:1028 msgid "" @@ -3717,7 +3613,6 @@ msgstr "" " 返回 N,或者如果 shell 不在执行一个函数或引用脚本时,失败。" #: builtins.c:1041 -#, fuzzy msgid "" "Set or unset values of shell options and positional parameters.\n" " \n" @@ -3760,8 +3655,7 @@ msgid "" " physical same as -P\n" " pipefail the return value of a pipeline is the status of\n" " the last command to exit with a non-zero status,\n" -" or zero if no command exited with a non-zero " -"status\n" +" or zero if no command exited with a non-zero status\n" " posix change the behavior of bash where the default\n" " operation differs from the Posix standard to\n" " match the standard\n" @@ -3865,6 +3759,8 @@ msgstr "" " -P 设定之后类似 cd 的会改变当前目录的命令不\n" " 追踪符号链接。\n" " -T 设定之后 DEBUG 陷阱会被 shell 函数继承。\n" +" -- 将剩余的参数都分配给位置参数。\n" +" 如果没有剩下的参数,取消认定位置参数。\n" " - 任何剩余的参数会被赋值给位置参数。\n" " -x 和 -v 选项已关闭。\n" " \n" @@ -3875,10 +3771,9 @@ msgstr "" " 参数,则打印所有的 shell 变量。\n" " \n" " 退出状态:\n" -" 返回成功除非使用了无效的参数。" +" 返回成功,除非使用了无效的参数。" #: builtins.c:1126 -#, fuzzy msgid "" "Unset values and attributes of shell variables and functions.\n" " \n" @@ -3890,8 +3785,7 @@ msgid "" " -n\ttreat each NAME as a name reference and unset the variable itself\n" " \trather than the variable it references\n" " \n" -" Without options, unset first tries to unset a variable, and if that " -"fails,\n" +" Without options, unset first tries to unset a variable, and if that fails,\n" " tries to unset a function.\n" " \n" " Some variables cannot be unset; also see `readonly'.\n" @@ -3906,11 +3800,12 @@ msgstr "" " 选项:\n" " -f\t将每个 NAME 名称当作函数对待\n" " -v\t将每个 NAME 名称当作变量对待\n" +" -n\t将每个 NAME 当作名称引用,取消认定变量自身,而不是它引用的变量\n" " \n" " 不带选项时,unset 首先尝试取消设定一个变量,如果\n" " 失败,再尝试取消设定一个函数。\n" " \n" -" 某些变量不可以被取消设定;请查看 `readonly'。\n" +" 某些变量不可以被取消设定;另请查看 `readonly'。\n" " \n" " 退出状态:\n" " 返回成功,除非使用了无效的选项或者 NAME 名称为只读。" @@ -3920,8 +3815,7 @@ msgid "" "Set export attribute for shell variables.\n" " \n" " Marks each NAME for automatic export to the environment of subsequently\n" -" executed commands. If VALUE is supplied, assign VALUE before " -"exporting.\n" +" executed commands. If VALUE is supplied, assign VALUE before exporting.\n" " \n" " Options:\n" " -f\trefer to shell functions\n" @@ -3949,7 +3843,6 @@ msgstr "" " 返回成功,除非使用了无效的选项或者 NAME 名称。" #: builtins.c:1167 -#, fuzzy msgid "" "Mark shell variables as unchangeable.\n" " \n" @@ -3961,8 +3854,7 @@ msgid "" " -a\trefer to indexed array variables\n" " -A\trefer to associative array variables\n" " -f\trefer to shell functions\n" -" -p\tdisplay a list of all readonly variables or functions, depending " -"on\n" +" -p\tdisplay a list of all readonly variables or functions, depending on\n" " whether or not the -f option is given\n" " \n" " An argument of `--' disables further option processing.\n" @@ -3979,9 +3871,9 @@ msgstr "" " -a\t指下标数组变量\n" " -A\t指关联数组标量\n" " -f\t指 shell 函数\n" -" -p\t显示只读变量和函数列表\n" +" -p\t视是否给出 -f 选项,显示只读变量和函数列表\n" " \n" -" `--' 的参数禁用进一步的选项处理。\n" +" `--' 的参数将禁用进一步的选项处理。\n" " \n" " 退出状态:\n" " 返回成功,除非使用了无效的选项或者 NAME 名称。" @@ -4051,7 +3943,6 @@ msgstr "" " 返回成功,除非没有启用任务控制或者有错误发生。" #: builtins.c:1248 -#, fuzzy msgid "" "Evaluate conditional expression.\n" " \n" @@ -4085,8 +3976,7 @@ msgid "" " -x FILE True if the file is executable by you.\n" " -O FILE True if the file is effectively owned by you.\n" " -G FILE True if the file is effectively owned by your group.\n" -" -N FILE True if the file has been modified since it was last " -"read.\n" +" -N FILE True if the file has been modified since it was last read.\n" " \n" " FILE1 -nt FILE2 True if file1 is newer than file2 (according to\n" " modification date).\n" @@ -4107,8 +3997,7 @@ msgid "" " STRING1 != STRING2\n" " True if the strings are not equal.\n" " STRING1 < STRING2\n" -" True if STRING1 sorts before STRING2 " -"lexicographically.\n" +" True if STRING1 sorts before STRING2 lexicographically.\n" " STRING1 > STRING2\n" " True if STRING1 sorts after STRING2 lexicographically.\n" " \n" @@ -4116,8 +4005,7 @@ msgid "" " \n" " -o OPTION True if the shell option OPTION is enabled.\n" " -v VAR\t True if the shell variable VAR is set\n" -" -R VAR\t True if the shell variable VAR is set and is a name " -"reference.\n" +" -R VAR\t True if the shell variable VAR is set and is a name reference.\n" " ! EXPR True if expr is false.\n" " EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.\n" " EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.\n" @@ -4135,10 +4023,13 @@ msgid "" msgstr "" "对条件表达式进行估值。\n" " \n" -" 根据 EXPR 表达式的估值以状态0(真)或1(伪)退出。\n" +" 根据 EXPR 表达式的估值以状态0(true)或1(false)退出。\n" " 表达式可以是一元或者二元的。一元表达式通常用于检测\n" " 文件状态。同时还有字符串操作符和数字比较操作符。\n" " \n" +" 测试的行为取决于参数的数量。请阅读 bash 手册了解\n" +" 的规定。\n" +" \n" " 文件操作符:\n" " \n" " -a 文件 如果文件存在则为真。\n" @@ -4189,11 +4080,13 @@ msgstr "" " 其他操作符:\n" " \n" " -o 选项 如果指定 shell 选项启用则为真。\n" +" -v VAR\t 如果 shell 变量 VAR 设置了则为真。\n" +" -R VAR\t 如果 shell 变量 VAR 设置了且为名称引用则为真。\n" " ! EXPR 如果表达式 expr 为假则为真。\n" " EXPR1 -a EXPR2 如果 expr1 和 expr2 都为真则为真。\n" " EXPR1 -o EXPR2 如果 expr1 和 expr2 有一个为真则为真。\n" " \n" -" arg1 OP arg2 算数测试。OP操作符可以是 -eq、-ne、\n" +" arg1 OP arg2 算术测试。OP 操作符可以是 -eq、-ne、\n" " -lt、-le、-gt、或 -ge 中的一个。\n" " \n" " 二元算数操作返回真,如果 ARG1 参数等于、不等于、\n" @@ -4219,8 +4112,7 @@ msgstr "" msgid "" "Display process times.\n" " \n" -" Prints the accumulated user and system times for the shell and all of " -"its\n" +" Prints the accumulated user and system times for the shell and all of its\n" " child processes.\n" " \n" " Exit Status:\n" @@ -4235,12 +4127,10 @@ msgstr "" " 总是成功。" #: builtins.c:1350 -#, fuzzy msgid "" "Trap signals and other events.\n" " \n" -" Defines and activates handlers to be run when the shell receives " -"signals\n" +" Defines and activates handlers to be run when the shell receives signals\n" " or other conditions.\n" " \n" " ARG is a command to be read and executed when the shell receives the\n" @@ -4249,50 +4139,43 @@ msgid "" " value. If ARG is the null string each SIGNAL_SPEC is ignored by the\n" " shell and by the commands it invokes.\n" " \n" -" If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. " -"If\n" -" a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command. " -"If\n" -" a SIGNAL_SPEC is RETURN, ARG is executed each time a shell function or " -"a\n" -" script run by the . or source builtins finishes executing. A " -"SIGNAL_SPEC\n" -" of ERR means to execute ARG each time a command's failure would cause " -"the\n" +" If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. If\n" +" a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command. If\n" +" a SIGNAL_SPEC is RETURN, ARG is executed each time a shell function or a\n" +" script run by the . or source builtins finishes executing. A SIGNAL_SPEC\n" +" of ERR means to execute ARG each time a command's failure would cause the\n" " shell to exit when the -e option is enabled.\n" " \n" -" If no arguments are supplied, trap prints the list of commands " -"associated\n" +" If no arguments are supplied, trap prints the list of commands associated\n" " with each signal.\n" " \n" " Options:\n" " -l\tprint a list of signal names and their corresponding numbers\n" " -p\tdisplay the trap commands associated with each SIGNAL_SPEC\n" " \n" -" Each SIGNAL_SPEC is either a signal name in or a signal " -"number.\n" +" Each SIGNAL_SPEC is either a signal name in or a signal number.\n" " Signal names are case insensitive and the SIG prefix is optional. A\n" " signal may be sent to the shell with \"kill -signal $$\".\n" " \n" " Exit Status:\n" -" Returns success unless a SIGSPEC is invalid or an invalid option is " -"given." +" Returns success unless a SIGSPEC is invalid or an invalid option is given." msgstr "" "对信号和其他事件设陷阱。\n" " \n" -" 定义一个处理器,在 shell 接收到信号和其他条件下执行。\n" +" 定义并激活一个处理器,在 shell 接收到信号和其他条件下执行。\n" " \n" " ARG 参数是当 shell 接收到 SIGNAL_SPEC 信号时读取和执行的命令。\n" " 如果没有指定 ARG 参数(并且只给出一个 SIGNAL_SPEC 信号)或者\n" " 或者 ARG 参数为 `-',每一个指定的参数会被重置为原始值。如果 ARG 参数\n" " 是一个空串,则每一个 SIGNAL_SPEC 信号会被 shell 和它启动的命令忽略。\n" " \n" -" 如果一个 SIGNAL_SPEC 信号是“退出” (0) ,则 ARG 命令会在 shell 退出时被\n" -" 执行。如果一个 SIGNAL_SPEC 信号是“调试“,则 ARG命令会在每一个简单命\n" -" 令之前执行。\n" +" 如果一个 SIGNAL_SPEC 信号是 EXIT (0) ,则 ARG 命令会在 shell 退出时被\n" +" 执行。如果一个 SIGNAL_SPEC 信号是 DEBUG,则 ARG命令会在每一个简单命\n" +" 令之前执行。如果一个 SIGNAL_SPEC 是 RETURN,ARG 会在每次 shell 函数\n" +" 或 脚本被 . 执行,或源 builtins 执行完成时执行。SIGNAL_SPEC 为 ERR \n" +" 表示 ARG 会在启用了 -e 选项、每次命令失败会导致 shell 退出时执行。\n" " \n" -" 如果不提供参数,trap 打印列表显示每一个与每一个信号相关联的\n" -" 命令。\n" +" 如果不提供参数,trap 打印列表显示与每一个信号相关联的命令。\n" " \n" " 选项:\n" " -l\t打印一个信号名称和它们对应的编号的列表\n" @@ -4331,8 +4214,7 @@ msgid "" " NAME\tCommand name to be interpreted.\n" " \n" " Exit Status:\n" -" Returns success if all of the NAMEs are found; fails if any are not " -"found." +" Returns success if all of the NAMEs are found; fails if any are not found." msgstr "" "显示命令类型的信息。\n" " \n" @@ -4358,12 +4240,10 @@ msgstr "" " 如果所有的 NAME 命令都找到则返回成功;任何找不到则失败。" #: builtins.c:1417 -#, fuzzy msgid "" "Modify shell resource limits.\n" " \n" -" Provides control over the resources available to the shell and " -"processes\n" +" Provides control over the resources available to the shell and processes\n" " it creates, on systems that allow such control.\n" " \n" " Options:\n" @@ -4406,7 +4286,7 @@ msgid "" msgstr "" "修改 shell 资源限制。\n" " \n" -" 在允许此类控制的系统上,提供对于 shell 及其创建的进程所可用的\n" +" 在允许此类控制的系统上,提供 shell 及其创建的进程可用的\n" " 资源的控制。\n" " \n" " 选项:\n" @@ -4430,8 +4310,11 @@ msgstr "" " -u\t最大用户进程数\n" " -v\t虚拟内存尺寸\n" " -x\t最大的锁数量\n" +" -T 最大线程数\n" +" \n" +" 注意不是有些选项在某些平台是不可用的。\n" " \n" -" 如果提供了 LIMIT 变量,则它为指定资源的新的值;特别的 LIMIT 值为\n" +" 如果提供了 LIMIT 变量,则它为指定资源的新值;LIMIT 的特定值\n" " `soft'、`hard'和`unlimited',分别表示当前的软限制,硬限制和无限制。\n" " 否则打印指定资源的当前限制值,不带选项则假定为 -f\n" " \n" @@ -4474,16 +4357,13 @@ msgstr "" " 返回成功,除非使用了无效的 MODE 模式或者选项。" #: builtins.c:1485 -#, fuzzy msgid "" "Wait for job completion and return exit status.\n" " \n" -" Waits for each process identified by an ID, which may be a process ID or " -"a\n" +" Waits for each process identified by an ID, which may be a process ID or a\n" " job specification, and reports its termination status. If ID is not\n" " given, waits for all currently active child processes, and the return\n" -" status is zero. If ID is a a job specification, waits for all " -"processes\n" +" status is zero. If ID is a a job specification, waits for all processes\n" " in that job's pipeline.\n" " \n" " If the -n option is supplied, waits for the next job to terminate and\n" @@ -4495,38 +4375,37 @@ msgid "" msgstr "" "等待任务完成并返回退出状态。\n" " \n" -" 等待以 ID 编号识别的进程,其中ID 可以是进程编号或者任务声明,\n" +" 等待以 ID 识别的进程,其中 ID 可以是进程 ID 或者任务声明,\n" " 并报告它的终止状态。如果 ID 没有给出,则等待所有的当前活跃子\n" " 进程,并且返回状态为零。如果 ID 是任务声明,等待任务管道中的\n" " 所有进程。\n" " \n" +" 如果提供了 -n 选项,等待下一任务中止并返回其退出状态。\n" +" \n" " 退出状态:\n" " 返回 ID 进程的状态;如果使用了无效的 ID 或者选项则失败。" #: builtins.c:1506 -#, fuzzy msgid "" "Wait for process completion and return exit status.\n" " \n" -" Waits for each process specified by a PID and reports its termination " -"status.\n" +" Waits for each process specified by a PID and reports its termination status.\n" " If PID is not given, waits for all currently active child processes,\n" " and the return status is zero. PID must be a process ID.\n" " \n" " Exit Status:\n" -" Returns the status of the last PID; fails if PID is invalid or an " -"invalid\n" +" Returns the status of the last PID; fails if PID is invalid or an invalid\n" " option is given." msgstr "" "等待进程完成并且返回退出状态。\n" " \n" " 等待指定进程并报告它的终止状态。如果\n" -" 没有提供PID,则当前所有的活跃子进程都会被等待,\n" -" 并且返回码为零。PID必须为进程号。\n" +" 没有提供 PID,则会等待当前所有的活跃子进程,\n" +" 并且返回状态为零。PID 必须为进程 ID。\n" " \n" " 退出状态:\n" -" 返回进程ID的状态;如果ID是无效的进程号或者指定了无效\n" -" 的选项则失败。" +" 返回最后一个 PID 的状态;如果 PID 是无效的或者指定了无效的选项\n" +" 则失败。" #: builtins.c:1521 msgid "" @@ -4662,17 +4541,12 @@ msgstr "" msgid "" "Execute commands based on conditional.\n" " \n" -" The `if COMMANDS' list is executed. If its exit status is zero, then " -"the\n" -" `then COMMANDS' list is executed. Otherwise, each `elif COMMANDS' list " -"is\n" +" The `if COMMANDS' list is executed. If its exit status is zero, then the\n" +" `then COMMANDS' list is executed. Otherwise, each `elif COMMANDS' list is\n" " executed in turn, and if its exit status is zero, the corresponding\n" -" `then COMMANDS' list is executed and the if command completes. " -"Otherwise,\n" -" the `else COMMANDS' list is executed, if present. The exit status of " -"the\n" -" entire construct is the exit status of the last command executed, or " -"zero\n" +" `then COMMANDS' list is executed and the if command completes. Otherwise,\n" +" the `else COMMANDS' list is executed, if present. The exit status of the\n" +" entire construct is the exit status of the last command executed, or zero\n" " if no condition tested true.\n" " \n" " Exit Status:\n" @@ -4752,8 +4626,7 @@ msgid "" "Define shell function.\n" " \n" " Create a shell function named NAME. When invoked as a simple command,\n" -" NAME runs COMMANDs in the calling shell's context. When NAME is " -"invoked,\n" +" NAME runs COMMANDs in the calling shell's context. When NAME is invoked,\n" " the arguments are passed to the function as $1...$n, and the function's\n" " name is in $FUNCNAME.\n" " \n" @@ -4834,12 +4707,9 @@ msgstr "" msgid "" "Execute conditional command.\n" " \n" -" Returns a status of 0 or 1 depending on the evaluation of the " -"conditional\n" -" expression EXPRESSION. Expressions are composed of the same primaries " -"used\n" -" by the `test' builtin, and may be combined using the following " -"operators:\n" +" Returns a status of 0 or 1 depending on the evaluation of the conditional\n" +" expression EXPRESSION. Expressions are composed of the same primaries used\n" +" by the `test' builtin, and may be combined using the following operators:\n" " \n" " ( EXPRESSION )\tReturns the value of EXPRESSION\n" " ! EXPRESSION\t\tTrue if EXPRESSION is false; else false\n" @@ -4865,8 +4735,7 @@ msgstr "" " ( EXPRESSION )\t返回 EXPRESSION 表达式的值\n" " ! EXPRESSION\t\t如果 EXPRESSION表达式为假则为真,否则为假\n" " EXPR1 && EXPR2\t如果 EXPR1 和 EXPR2 表达式均为真则为真,否则为假\n" -" EXPR1 || EXPR2\t如果 EXPR1 和 EXPR2 表达式中有一个为真则为真,否则为" -"假\n" +" EXPR1 || EXPR2\t如果 EXPR1 和 EXPR2 表达式中有一个为真则为真,否则为假\n" " \n" " 当使用 `==' 和 `!=' 操作符时,操作符右边的字符串被用作模式并且执行一个\n" " 匹配。当使用 `=~' 操作符时,操作符右边的字符串被当作正则表达式来进行\n" @@ -5090,12 +4959,10 @@ msgid "" " \twith its position in the stack\n" " \n" " Arguments:\n" -" +N\tDisplays the Nth entry counting from the left of the list shown " -"by\n" +" +N\tDisplays the Nth entry counting from the left of the list shown by\n" " \tdirs when invoked without options, starting with zero.\n" " \n" -" -N\tDisplays the Nth entry counting from the right of the list shown " -"by\n" +" -N\tDisplays the Nth entry counting from the right of the list shown by\n" " \tdirs when invoked without options, starting with zero.\n" " \n" " Exit Status:\n" @@ -5127,8 +4994,7 @@ msgid "" "Set and unset shell options.\n" " \n" " Change the setting of each shell option OPTNAME. Without any option\n" -" arguments, list all shell options with an indication of whether or not " -"each\n" +" arguments, list all shell options with an indication of whether or not each\n" " is set.\n" " \n" " Options:\n" @@ -5160,7 +5026,6 @@ msgstr "" " 无效的选项或OPTNAME 被禁用则失败。" #: builtins.c:1908 -#, fuzzy msgid "" "Formats and prints ARGUMENTS under control of the FORMAT.\n" " \n" @@ -5168,34 +5033,27 @@ msgid "" " -v var\tassign the output to shell variable VAR rather than\n" " \t\tdisplay it on the standard output\n" " \n" -" FORMAT is a character string which contains three types of objects: " -"plain\n" -" characters, which are simply copied to standard output; character " -"escape\n" +" FORMAT is a character string which contains three types of objects: plain\n" +" characters, which are simply copied to standard output; character escape\n" " sequences, which are converted and copied to the standard output; and\n" -" format specifications, each of which causes printing of the next " -"successive\n" +" format specifications, each of which causes printing of the next successive\n" " argument.\n" " \n" -" In addition to the standard format specifications described in " -"printf(1),\n" +" In addition to the standard format specifications described in printf(1),\n" " printf interprets:\n" " \n" " %b\texpand backslash escape sequences in the corresponding argument\n" " %q\tquote the argument in a way that can be reused as shell input\n" -" %(fmt)T output the date-time string resulting from using FMT as a " -"format\n" +" %(fmt)T output the date-time string resulting from using FMT as a format\n" " string for strftime(3)\n" " \n" " The format is re-used as necessary to consume all of the arguments. If\n" " there are fewer arguments than the format requires, extra format\n" -" specifications behave as if a zero value or null string, as " -"appropriate,\n" +" specifications behave as if a zero value or null string, as appropriate,\n" " had been supplied.\n" " \n" " Exit Status:\n" -" Returns success unless an invalid option is given or a write or " -"assignment\n" +" Returns success unless an invalid option is given or a write or assignment\n" " error occurs." msgstr "" "在 FORMAT 变量的控制下格式化并打印 ARGUMENTS 参数。\n" @@ -5204,13 +5062,17 @@ msgstr "" " -v var\t将输出赋值给 shell 变量 VAR 而不显示在标准输出上\n" " \n" " FORMAT 变量是包含三种对象的字符串:简单地被拷贝到标准输出的普通字符;\n" -" 被变换之后拷贝到标准输入的转义字符;以及每个都会影响到下个参数的打印" -"的 格式化声明。\n" +" 变换之后拷贝到标准输入的转义字符;以及每个都会影响到下个参数的打印的\n" +" 格式化声明。\n" +" \n" +" 在 printf(1)、printf(3) 中描述的标准控制声明之外,printf 解析:\n" " \n" -" 在 printf(1)、printf(3) 中描述的标准控制声明之外,printf解析:\n" -"、 \n" " %b\t扩展对应参数中的反斜杠转义序列\n" " %q\t以可作为 shell 输入的格式引用参数\n" +" %(fmt)T 输入以 FMT 作为格式化字符串从 strftime(3) 得到的日期-时间字符串\n" +" \n" +" 如有必要,在处理(consume)所有参数时会重用该格式。如果参数比格式要求的少,\n" +" 额外的格式规定(如果合适)会假定提供了一个零值或空字符串。\n" " \n" " 退出状态:\n" " 返回成功,除非使用了无效的选项或者写或赋值错误发生。" @@ -5219,10 +5081,8 @@ msgstr "" msgid "" "Specify how arguments are to be completed by Readline.\n" " \n" -" For each NAME, specify how arguments are to be completed. If no " -"options\n" -" are supplied, existing completion specifications are printed in a way " -"that\n" +" For each NAME, specify how arguments are to be completed. If no options\n" +" are supplied, existing completion specifications are printed in a way that\n" " allows them to be reused as input.\n" " \n" " Options:\n" @@ -5264,8 +5124,7 @@ msgid "" "Display possible completions depending on the options.\n" " \n" " Intended to be used from within a shell function generating possible\n" -" completions. If the optional WORD argument is supplied, matches " -"against\n" +" completions. If the optional WORD argument is supplied, matches against\n" " WORD are generated.\n" " \n" " Exit Status:\n" @@ -5281,16 +5140,12 @@ msgstr "" " 除非使用了无效选项或者错误发生,否则返回成功。" #: builtins.c:1985 -#, fuzzy msgid "" "Modify or display completion options.\n" " \n" -" Modify the completion options for each NAME, or, if no NAMEs are " -"supplied,\n" -" the completion currently being executed. If no OPTIONs are given, " -"print\n" -" the completion options for each NAME or the current completion " -"specification.\n" +" Modify the completion options for each NAME, or, if no NAMEs are supplied,\n" +" the completion currently being executed. If no OPTIONs are given, print\n" +" the completion options for each NAME or the current completion specification.\n" " \n" " Options:\n" " \t-o option\tSet completion option OPTION for each NAME\n" @@ -5334,28 +5189,21 @@ msgstr "" " 返回成功,除非使用了无效的选项或者 NAME 名称没有定义补完声明。" #: builtins.c:2015 -#, fuzzy msgid "" "Read lines from the standard input into an indexed array variable.\n" " \n" -" Read lines from the standard input into the indexed array variable " -"ARRAY, or\n" -" from file descriptor FD if the -u option is supplied. The variable " -"MAPFILE\n" +" Read lines from the standard input into the indexed array variable ARRAY, or\n" +" from file descriptor FD if the -u option is supplied. The variable MAPFILE\n" " is the default ARRAY.\n" " \n" " Options:\n" -" -n count\tCopy at most COUNT lines. If COUNT is 0, all lines are " -"copied.\n" -" -O origin\tBegin assigning to ARRAY at index ORIGIN. The default " -"index is 0.\n" +" -n count\tCopy at most COUNT lines. If COUNT is 0, all lines are copied.\n" +" -O origin\tBegin assigning to ARRAY at index ORIGIN. The default index is 0.\n" " -s count \tDiscard the first COUNT lines read.\n" " -t\t\tRemove a trailing newline from each line read.\n" -" -u fd\t\tRead lines from file descriptor FD instead of the standard " -"input.\n" +" -u fd\t\tRead lines from file descriptor FD instead of the standard input.\n" " -C callback\tEvaluate CALLBACK each time QUANTUM lines are read.\n" -" -c quantum\tSpecify the number of lines read between each call to " -"CALLBACK.\n" +" -c quantum\tSpecify the number of lines read between each call to CALLBACK.\n" " \n" " Arguments:\n" " ARRAY\t\tArray variable name to use for file data.\n" @@ -5365,19 +5213,17 @@ msgid "" " element to be assigned and the line to be assigned to that element\n" " as additional arguments.\n" " \n" -" If not supplied with an explicit origin, mapfile will clear ARRAY " -"before\n" +" If not supplied with an explicit origin, mapfile will clear ARRAY before\n" " assigning to it.\n" " \n" " Exit Status:\n" -" Returns success unless an invalid option is given or ARRAY is readonly " -"or\n" +" Returns success unless an invalid option is given or ARRAY is readonly or\n" " not an indexed array." msgstr "" -"从标准输入读取行到下表数组变量中。\n" +"从标准输入读取行到索引的数组变量。\n" " \n" -" 从标准输入读取行到下表数组变量 ARRAY 中,或者如果使用了 -u 选项,\n" -" 从文件描述符 FD 中读取。MAPFILE 变量是默认的 ARRAY 变量。\n" +" 从标准输入读取行到索引的数组变量 ARRAY 中,或者如果使用了 -u 选项,\n" +" 从文件描述符 FD 中读取。MAPFILE 变量是默认的 ARRAY 数组。\n" " \n" " 选项:\n" " -n count\t最多拷贝 COUNT 行,如果 COUNT 为0,则拷贝所有行。\n" @@ -5391,13 +5237,13 @@ msgstr "" " 参数:\n" " ARRAY\t\t存储数据使用的数组变量\n" " \n" -" 如果使用了-C而没有-c,默认的量子是5000。当对 CALLBACK 估值时,\n" +" 如果使用了 -C 而没有 -c,默认的量子是5000。当对 CALLBACK 估值时,\n" " 下一个将被赋值的数组元素的下标作为额外参数被传递。\n" " \n" -" 如果没有显式指定起始下标,mapfile将在赋值前清空 ARRAY 变量。\n" +" 如果没有显式指定起始,mapfile 将在赋值前清空 ARRAY 数组。\n" " \n" " 退出状态:\n" -" 返回成功,除非使用了无效的选项,或者 ARRAY 变量是只读或者不是下标数组。" +" 返回成功,除非使用了无效的选项,或者 ARRAY 变量是只读或者不是索引的数组。" #: builtins.c:2049 msgid "" @@ -5412,12 +5258,8 @@ msgstr "" #~ msgid "Copyright (C) 2009 Free Software Foundation, Inc.\n" #~ msgstr "版权所有 (C) 2009 自由软件基金会\n" -#~ msgid "" -#~ "License GPLv2+: GNU GPL version 2 or later \n" -#~ msgstr "" -#~ "许可证 GPLv2+: GNU GPL 许可证第二版或者更新版本 \n" +#~ msgid "License GPLv2+: GNU GPL version 2 or later \n" +#~ msgstr "许可证 GPLv2+: GNU GPL 许可证第二版或者更新版本 \n" #~ msgid "" #~ ". With EXPR, returns\n" @@ -5430,8 +5272,7 @@ msgstr "" #~ "; this extra information can be used to\n" #~ " provide a stack trace.\n" #~ " \n" -#~ " The value of EXPR indicates how many call frames to go back before " -#~ "the\n" +#~ " The value of EXPR indicates how many call frames to go back before the\n" #~ " current one; the top frame is frame 0." #~ msgstr "" #~ "; 这个额外信息可被用于\n" diff --git a/subst.c b/subst.c index ca9bfef11..ac0dc8c77 100644 --- a/subst.c +++ b/subst.c @@ -1708,7 +1708,7 @@ skip_to_delim (string, start, delims, flags) char *delims; int flags; { - int i, pass_next, backq, si, c, invert, skipquote, skipcmd; + int i, pass_next, backq, si, c, invert, skipquote, skipcmd, noprocsub; size_t slen; char *temp, open[3]; DECLARE_MBSTATE; @@ -1718,6 +1718,7 @@ skip_to_delim (string, start, delims, flags) no_longjmp_on_fatal_error = 1; invert = (flags & SD_INVERT); skipcmd = (flags & SD_NOSKIPCMD) == 0; + noprocsub = (flags & SD_NOPROCSUB); i = start; pass_next = backq = 0; @@ -1780,7 +1781,7 @@ skip_to_delim (string, start, delims, flags) continue; } #if defined (PROCESS_SUBSTITUTION) - else if (skipcmd && (c == '<' || c == '>') && string[i+1] == LPAREN) + else if (skipcmd && noprocsub == 0 && (c == '<' || c == '>') && string[i+1] == LPAREN) { si = i + 2; if (string[si] == '\0') @@ -3012,7 +3013,7 @@ pos_params (string, start, end, quoted) return ((char *)NULL); save = params = list_rest_of_args (); - if (save == 0) + if (save == 0 && start > 0) return ((char *)NULL); if (start == 0) /* handle ${@:0[:x]} specially */ @@ -5918,14 +5919,6 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c } t = parameter_brace_find_indir (name, var_is_special, quoted, 0); - if (t == 0 || *t == 0) - { - report_error (_("%s: invalid indirect expansion"), name); - w = alloc_word_desc (); - w->word = &expand_param_error; - w->flags = 0; - return w; - } chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at); if (t == 0) @@ -6552,7 +6545,7 @@ parameter_brace_substring (varname, value, ind, substr, quoted, flags) char *temp, *val, *tt, *oname; SHELL_VAR *v; - if (value == 0) + if (value == 0 && ((varname[0] != '@' && varname[0] != '*') || varname[1])) return ((char *)NULL); oname = this_command_name; @@ -8279,6 +8272,9 @@ add_string: case '<': case '>': { + /* bash-4.4/bash-5.0 + XXX - technically this should only be expanded at the start + of a word */ if (string[++sindex] != LPAREN || (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (word->flags & (W_DQUOTE|W_NOPROCSUB)) || posixly_correct) { sindex--; /* add_character: label increments sindex */ diff --git a/subst.h b/subst.h index d123fccfd..9cca4e066 100644 --- a/subst.h +++ b/subst.h @@ -280,10 +280,11 @@ extern char *cond_expand_word __P((WORD_DESC *, int)); #define SD_NOJMP 0x01 /* don't longjmp on fatal error. */ #define SD_INVERT 0x02 /* look for chars NOT in passed set */ #define SD_NOQUOTEDELIM 0x04 /* don't let single or double quotes act as delimiters */ -#define SD_NOSKIPCMD 0x08 /* don't skip over $(, <(, or >( command/process substitution */ +#define SD_NOSKIPCMD 0x08 /* don't skip over $(, <(, or >( command/process substitution; parse them as commands */ #define SD_EXTGLOB 0x10 /* skip over extended globbing patterns if appropriate */ #define SD_IGNOREQUOTE 0x20 /* single and double quotes are not special */ #define SD_GLOB 0x40 /* skip over glob patterns like bracket expressions */ +#define SD_NOPROCSUB 0x80 /* don't parse process substitutions as commands */ extern int skip_to_delim __P((char *, int, char *, int)); diff --git a/tests/misc/regress/log.orig b/tests/misc/regress/log.orig new file mode 100644 index 000000000..c1f1e1991 --- /dev/null +++ b/tests/misc/regress/log.orig @@ -0,0 +1,50 @@ +:; ./shx + +sh: +<&$fd ok +nlbq Mon Aug 3 02:45:00 EDT 1992 +bang geoff +quote 712824302 +setbq defmsgid=<1992Aug3.024502.6176@host> +bgwait sleep done... wait 6187 + + +bash: +<&$fd ok +nlbq Mon Aug 3 02:45:09 EDT 1992 +bang geoff +quote 712824311 +setbq defmsgid=<1992Aug3.024512.6212@host> +bgwait sleep done... wait 6223 + + +ash: +<&$fd shx1: 4: Syntax error: Bad fd number +nlbq Mon Aug 3 02:45:19 EDT 1992 +bang geoff +quote getdate: `"now"' not a valid date + +setbq defmsgid=<1992Aug3.` echo 024521 +bgwait sleep done... wait 6241 + + +ksh: +<&$fd ok +nlbq ./shx: 6248 Memory fault - core dumped +bang geoff +quote getdate: `"now"' not a valid date + +setbq defmsgid=<1992Aug3.024530.6257@host> +bgwait no such job: 6265 +wait 6265 +sleep done... + +zsh: +<&$fd ok +nlbq Mon Aug 3 02:45:36 EDT 1992 +bang shx3: event not found: /s/ [4] +quote 712824337 +setbq defmsgid=<..6290@host> +bgwait shx7: unmatched " [9] +sleep done... +:; diff --git a/tests/misc/regress/shx.orig b/tests/misc/regress/shx.orig new file mode 100644 index 000000000..4b3bf2b82 --- /dev/null +++ b/tests/misc/regress/shx.orig @@ -0,0 +1,10 @@ +#! /bin/sh +for cmd in sh bash ash ksh zsh +do + echo + echo $cmd: + for demo in shx? + do + $cmd $demo + done +done