winbash-checkins Mailing List for winbash - bash for win32 (Page 4)
Brought to you by:
enricobrunetta,
xks
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
(119) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Enrico B. <enr...@us...> - 2002-03-11 01:57:57
|
Update of /cvsroot/winbash/winbash/CWRU In directory usw-pr-cvs1:/tmp/cvs-serv26460 Added Files: sh-redir-hack Log Message: Added from 1.14.5 GNU bash --- NEW FILE: sh-redir-hack --- Add to `subshell' production in parse.y and recompile -DREDIRECTION_HACK to get `< xx (command)' sh compatibility. | redirections '(' list ')' { #if defined (REDIRECTION_HACK) /* XXX - C News sh compatibility hack - XXX */ $3->redirects = $1; $3->flags |= CMD_WANT_SUBSHELL; $$ = $3; #else yyerror (); YYABORT; #endif } |
From: Enrico B. <enr...@us...> - 2002-03-11 01:51:32
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv25106 Added Files: FAQ texi2dvi Log Message: Added from GNU bash 1.14.5 --- NEW FILE: FAQ --- 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 the document should be set to ch...@po.... Contents: 1) What is it? 2) What's the latest version? 3) Where can I get it? 4) What's the `Posix 1003.2 standard'? 5) On what machines will bash run? 6) How does bash differ from sh, the Bourne shell? 7) How does bash differ from the Korn shell? 8) What is the bash `posix mode'? 9) How can I build bash with gcc? 10) Why does bash run a different version of `command' than `which command' says it will? 11) How can I make my csh aliases work when I convert to bash? 12) Now that I've converted from ksh to bash, are there equivalents to ksh features like autoloaded functions and the `whence' command? 13) Why is the bash builtin `test' slightly different from /bin/test? 14) Why does bash sometimes say `Broken pipe'? 15) How can I get bash to read and display eight-bit characters? 16) Why can't I use command line editing in my `cmdtool'? 17) How do I write a function `x' to replace builtin command `x', but still invoke the command from within the function? 18) When I have terminal escape sequences in my prompt, why does bash wrap lines at the wrong column? 19) I built bash on Solaris 2. Why do globbing expansions chop off the first few characters of each filename? 20) Why doesn't bash treat brace expansions exactly like csh? 21) Why does bash dump core after I interrupt username completion? 22) I'm running SVR4.2. Why is the line erased every time I type `@'? 23) How can I find the value of a shell variable whose name is the value of another shell variable? 24) 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? 25) I just changed my shell to bash, and now I can't FTP into my machine. Why not? 26) 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? 27) Why doesn't bash have csh variable modifiers? 28) How do I report bugs in bash, and where should I look for fixes and advice? 29) What kind of bash documentation is there? 30) What's coming in future versions? 31) What's on the bash `wish list'? 32) When will the next release appear? 1) 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. 2) What's the latest version? The latest version is 1.14.4, first made available on April 21, 1995. 3) Where can I get it? Bash is the GNU project's shell, and so is available from the master GNU archive site, prep.ai.mit.edu, and its mirrors. The latest version is also available for FTP from slc2.ins.cwru.edu, the maintainer's machine. The following URLs tell how to get version 1.14.4: ftp://prep.ai.mit.edu/pub/gnu/bash-1.14.4.tar.gz ftp://slc2.ins.cwru.edu/pub/dist/bash-1.14.4.tar.gz 4) 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. 5) 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 `make'. The build process will attempt to discover the version of UNIX you have and tailor itself accordingly, using a combination of saved definitions in the file `machines.h' and a file `sysdefs.h' created by inspecting the environment for various things. More information appears in the file `INSTALL' in the distribution. 6) How does bash differ from sh, the Bourne shell? This is a non-comprehensive list of features that differentiate bash from the SVR4 shell. The bash manual page explains these completely. Things bash has that sh does not: long invocation options `!' reserved word to invert pipeline return value the select compound command the $(...) form of command substitution the ${#param} parameter value length operator expansions to perform substring removal (${p%[%]w}, ${p#[#]w}) variables: BASH, BASH_VERSION, UID, EUID, REPLY, PPID, PWD, OLDPWD, SHLVL, RANDOM, SECONDS, LINENO, HISTCMD, HOSTTYPE, OSTYPE, ENV, MAIL_WARNING, PS3, PS4, HISTSIZE, HISTFILE, HISTFILESIZE, PROMPT_COMMAND, FCEDIT, FIGNORE, IGNOREEOF, INPUTRC, HISTCONTROL, command_oriented_history, allow_null_glob_expansion, glob_dot_filenames, histchars, nolinks, auto_resume, HOSTFILE, noclobber, TMOUT, no_exit_on_failed_exec, cdable_vars redirections: <>, &>, >| prompt string special char translation and variable expansion auto-export of modified values of variables in initial environment command search finds functions before builtins bash return builtin will exit a file sourced with `.' builtins: cd -, exec -, echo -e/-E, export -n/-f/-p/name=value, pwd -P, read -r, readonly -f, trap -l, ulimit -n/-p/-u, set -b/-m/-o option/-p/-l/-d/-C/-H/-P, unset -f/-v, umask -S, type -all/-path/-type, suspend -f, kill -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 and `let' builtin process substitution aliases and alias/unalias builtins local variables in functions and `local' builtin readline and command-line editing history and history/fc builtins csh-like history expansion other new bash builtins: bind, command, builtin, declare/typeset, dirs, enable, fc, help, history, logout, popd, pushd exported functions filename generation when using output redirection (command >a*) 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' ulimit attempts to set both soft & hard limits if -S/-H not given New things in the SVR4.2 sh: internationalization: $LANG, $LC_CTYPE, $LC_MESSAGES, setlocale, etc. $TIMEOUT (like bash $TMOUT) new builtins: mldmode, priv `read' builtin has -r cannot trap SIGALRM or SIGCHLD kill -s is present 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 sh does not allow MAILCHECK to be unset (?) 7) How does bash differ from the Korn shell? Things bash has or uses that ksh does not: long invocation options `!' reserved word 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 variables: BASH, BASH_VERSION, UID, EUID, SHLVL, HISTCMD, HOSTTYPE, OSTYPE, MAIL_WARNING, HISTFILESIZE, OPTERR, PROMPT_COMMAND, IGNOREEOF, FIGNORE, INPUTRC, HISTCONTROL, notify, command_oriented_history, glob_dot_filenames, allow_null_glob_expansion, histchars, nolinks, HOSTFILE, noclobber, auto_resume, no_exit_on_failed_exec, cdable_vars prompt expansion with backslash escapes and command substitution redirection: &> (stdout and stderr) more extensive and extensible editing and completion builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable, exec -, fc -s, export -n/-f/-p, hash, help, history, jobs -x, kill -s, local, logout, popd, pushd, readonly -n/-f/-p, set -o braceexpand/-o histexpand/ -o interactive-comments/-o notify/-o physical/-o posix/ -l/-d/-C/-b/-H/-P, suspend, trap -l, type, ulimit -u, umask -S $[...] synonym for $((...)) `!' csh-style history expansion Things ksh has or uses that bash does not: new version of test: [[...]] ((...)) equivalent to let "..." time keyword to let pipelines be timed tracked aliases $(<file) one-dimensional arrays and appropriate expansions variables: ERRNO, FPATH, COLUMNS, LINES, EDITOR, VISUAL extended pattern matching with egrep-style pattern lists 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/u/var?prompt, set -A/-o gmacs/-o keyword/ -o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s, typeset -H/-L/-R/-A/-ft/-fu/-fx/-l/-u/-t, whence Implementation differences: ksh runs last command of a pipeline in parent shell context ksh ulimit sets hard and soft limits by default bash has brace expansion by default bash has fixed startup file for all interactive shells; ksh reads $ENV bash has exported functions bash command search finds functions before builtins 8) 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 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 CWRU/POSIX.NOTES in the bash distribution. 9) How can I build bash with gcc? Type make CC=gcc CPPNAME='$(CC) -E' 10) Why does bash run a different version of `command' than `which command' says it will? `which' is actually a csh script that assumes you're running csh. It 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. 11) 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/alias-conv.sh. Here is how you use it: Start csh in the normal way for you. (e.g., `csh') Pipe the output of `alias' through `alias-conv.sh', saving the results into `bash_aliases': alias | alias-conv.sh >bash_aliases Edit `bash_aliases', carefully reading through any created functions. You will need to change the names of csh specific variables (like $cwd) to the bash equivalents (like $PWD). You will also need to remove recursive references to commands which are defined as functions. For example, the csh alias: alias cd 'cd \!*;echo $cwd' is converted to the bash function: cd () { cd $*; echo $cwd } This function contains a self-pointing reference to `cd', which should be changed to use the `builtin' version. It also uses the csh variable `$cwd' which has an equivalent in bash. Precede the recursive reference with the word `builtin', and change the name of the variable: cd () { builtin cd $*; echo $PWD; } Merge the edited file into your ~/.bashrc. 12) 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 that do not have direct bash equivalents. Most, however, can be emulated with very little trouble. ksh-88 feature Bash equivalent -------------- --------------- [[...]] can usually use [...]; minor differences compiled-in aliases set up aliases in .bashrc; some ksh aliases are bash builtins (hash, history, type) $(<file) $(cat file) arrays no good subsitute yet ((...)) let "..." time use external command; GNU time is particularly useful use time bash -c '...' for complicated constructs extended patterns no good substitute coprocesses named pipe pairs (one for read, one for write) typeset +f declare -f | sed -n 's:^declare -[a-z]* \([^ ]*\).*$:\1:p' cd, print, whence function subsitutes in examples/functions/kshenv autoloaded functions examples/functions/autoload is the same as typeset -fu read var?prompt [ -t 0 ] && echo -n prompt; read var 13) 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 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. 14) Why does bash sometimes say `Broken pipe'? If a sequence of commands appear 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. 15) 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 eigth 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. 16) 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. 17) How do I write a function `x' to replace builtin command `x', but still invoke the command from within the function? This is what the `command' and `builtin' builtins are for. 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. 18) When I have terminal escape sequences in my prompt, why does bash wrap lines at the wrong column? Bash 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. 19) I built bash on Solaris 2. Why do globbing expansions 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 strutures 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 /bin ahead of /usr/ucb in your $PATH when building bash. This will ensure that you use /bin/cc or acc instead of /usr/ucb/cc and that you link with libc before libucb. 20) 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 on 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. 21) Why does bash dump core after I interrupt username completion 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 probably stop it by adding an #undef USE_GNU_MALLOC to the appropriate machine description in machines.h. 22) 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. 23) How can I find the value of a shell variable whose name is the value of another shell variable? 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. 24) 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. 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 into 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. 25) I just changed my 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. Many versions of ftpd use this file to prohibit `special' users such as `uucp' and `news' from using FTP. 26) 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 modelled after the 9th Edition Research Unix version of `echo'. It does not interpret backslash-escaped characters in its argument strings by default, but 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 compile-time option that will make bash behave like the System V echo and interpret things like \t by default. Change config.h so that DEFAULT_ECHO_TO_USG is defined, remove builtins/libbuiltins.a and builtins/echo.o, and rebuild. 27) Why doesn't bash have csh variable modifiers? Posix has specified a more powerful, albeit somewhat more confusing, 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 28) 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...@pr..., 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 bas...@pr.... 29) What kind of bash documentation is there? First, look in the documentation directory in the bash distribution. It should contain the following files: bash.1 an extensive, thorough Unix-style manual page builtins.1 a manual page covering just bash builtin commands features.texi a Gnu-style info file overview FAQ this file article.ms text of an article written for The Linux Journal readline.3 a man page describing readline Postscript files created from the above source are also present in the distribution. There is additional documentation available for anonymous FTP from host slc2.ins.cwru.edu in the `pub/bash' directory. Cameron Newham is in the midst of writing a book on bash, to be published by O'Reilly and Associates. Look for it sometime this year. 30) What's coming in future versions? There will be no new features in future releases of version 1.14. The next major release, bash-2.0, will contain extensive changes and new features. Here's a short list: one-dimensional arrays with a new compound assignment statement, appropriate expansion constructs and modifications to some of the builtins (read, declare, etc.) to use them new expansions to do ANSI-C string expansion, substring extraction, pattern replacement, and indirect variable expansion new builtins: `disown' and `shopt' new variables: HISTIGNORE, SHELLOPTS, PIPESTATUS, DIRSTACK special handling of many unused or redundant variables removed dynamic loading of new builtin commands; many loadable examples provided new prompt expansions: \e, \n, \H, \T new readline variables: enable-keypad, mark-directories, input-meta new readline commands to manipulate the mark and operate on the region new readline emacs mode commands and bindings for ksh-88 compatibility updated and extended builtins new DEBUG trap expanded (and now documented) restricted shell mode implementation stuff: autoconf-based configuration nearly all of the bugs reported since version 1.14 have been fixed most builtins converted to use builtin `getopt' for consistency most builtins use -p option to display output in a reusable form (for consistency) grammar tighter and smaller (66 reduce-reduce conflicts gone) lots of code now smaller and faster test suite greatly expanded 31) What's on the bash `wish list'? internationalization with a variable expansion to translate a string according to a particular message catalog Programmable completion a la zsh menu completion a la tcsh the ksh egrep-style extended pattern matching operators associative arrays (not really all that hard) breaking some of the shell functionality into embeddable libraries a bash debugger Much of this will not be in bash-2.0. 32) When will the next release appear? There will probably be a 1.14.5 release to coincide with the next GNU source CD. That will be the last release for version 1.14. The next version will appear sometime in 1995. Never make predictions. --- NEW FILE: texi2dvi --- #!/bin/sh # texi2dvi -- smartly produce DVI files from texinfo sources # # Copyright (C) 1992, 1993 Free Software Foundation. # # 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, you can either send email to this # program's author (see below) or write to: # # Free Software Foundation, Inc. # 675 Mass Ave. # Cambridge, MA 02139, USA. # # Please send bug reports, etc. to bug...@pr... # If possible, please send a copy of the output of the script called with # the `--debug' option when making a bug report. # # Version 0.4 # Last modified 26-Mar-93 # # Please note that in the interest of general portability, some common # bourne shell constructs were avoided because they weren't guaranteed to # be available in some earlier implementations. I've tried to make this as # portable as possible. # # Among the more interesting lossages I noticed with some bourne shells # are: # 1) Some don't have an `unset' builtin # 2) In some implementations the `shift' builtin can't take a # numerical argument. progname=`basename $0` usage="Usage: ${progname} {-D} {-h} [file1] {file2} {...} {--debug} {--help} Options in braces are optional. Those in brackets are required. " if test $# -eq 0 ; then echo "${usage}" 1>&2; exit 1 fi backup_extension=".bak" texindex="texindex" tex="tex" bq="\`" # To prevent hairy quoting and escaping later. eq="'" orig_pwd="`pwd`" if test "z${TEXINDEX}" != "z" ; then texindex="${TEXINDEX}" fi if test "z${TEX}" != "z" ; then tex="${TEX}" fi # Save this so we can construct a new TEXINPUTS path for each file to be # processed. TEXINPUTS_orig="${TEXINPUTS}" export TEXINPUTS # Parse command line options # "unset" option variables to make sure they weren't accidentally # exported debug="" # If you add new commands be sure to change the wildcards below to make # sure they are unambiguous (i.e. only match one possible long option) # Be sure to show at least one instance of the full long option name to # document what the long option is canonically called. while test $# -gt 0 ; do case z$1 in z-D | z--debug | z--d* ) debug="t" shift ;; z-h | z--help | z--h* ) echo "${usage}" 1>&2 exit 1 ;; z-- ) shift break ;; z-* ) echo "${progname}: ${bq}${1}${eq} is not a valid option." 1>&2 echo "" 1>&2 echo "${usage}" 1>&2 exit 1 ;; * ) break ;; esac done # See if there are any command line args left (which will be interpreted as # filename arguments) if test $# -eq 0 ; then echo "${progname}: at least one file name is required as an argument." 1>&2 echo "" 1>&2 echo "${usage}" 1>&2 exit 1 fi test "z${debug}" = "zt" && set -x # Texify files for command_line_filename in ${1+"$@"} ; do # Roughly equivalent to `dirname ...`, but more portable directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`" filename_texi="`basename ${command_line_filename}`" # Strip off the last extension part (probably .texinfo or .texi) filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`" # If directory and file are the same, then it's probably because there's # no pathname component. Set dirname to `.', the current directory. if test "z${directory}" = "z${command_line_filename}" ; then directory="." fi # Source file might @include additional texinfo sources. Put `.' and # directory where source file(s) reside in TEXINPUTS before anything # else. `.' goes first to ensure that any old .aux, .cps, etc. files in # ${directory} don't get used in preference to fresher files in `.'. TEXINPUTS=".:${directory}:${TEXINPUTS_orig}" # "Unset" variables that might have values from previous iterations and # which won't be completely reset later. definite_index_files="" # See if file exists here. If it doesn't we're in trouble since, even # though the user may be able to reenter a valid filename at the tex # prompt (assuming they're attending the terminal), this script won't be # able to find the right index files and so forth. if test ! -r "${command_line_filename}" ; then echo "${progname}: ${command_line_filename}: No such file or permission denied." 1>&2 continue; fi # Find all files having root filename with a two-letter extension, # determine whether they're really index files, and save them. Foo.aux # is actually the cross-references file, but we need to keep track of # that too. possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" for this_file in ${possible_index_files} ; do # If file is empty, forget it. if test ! -s "${this_file}" ; then continue; fi # Examine first character of file. If it's not a backslash or # single quote, then it's definitely not an index or xref file. first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then definite_index_files="${definite_index_files} ${this_file}" fi done orig_index_files="${definite_index_files}" orig_index_files_sans_aux="`echo ${definite_index_files} \ | sed 's/'${filename_noext}'\.aux//; s/^[ ]*//;s/[ ]*$//;'`" # Now save copies of original index files so we have some means of # comparison later. for index_file_to_save in ${orig_index_files} ; do cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}" done # Run texindex on current index files. If they already exist, and # after running TeX a first time the index files don't change, then # there's no reason to run TeX again. But we won't know that if the # index files are out of date or nonexistent. if test "${orig_index_files_sans_aux}" ; then ${texindex} ${orig_index_files_sans_aux} fi if ${tex} ${command_line_filename} ; then # TeX run first time definite_index_files="" # Get list of new index files possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" for this_file in ${possible_index_files} ; do # If file is empty, forget it. if test ! -s ${this_file} ; then continue; fi # Examine first character of file. If it's not a backslash or # single quote, then it's definitely not an index or xref file. first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then definite_index_files="${definite_index_files} ${this_file}" fi done new_index_files="${definite_index_files}" new_index_files_sans_aux="`echo ${definite_index_files} \ | sed 's/'${filename_noext}'\.aux//; s/^[ ]*//;s/[ ]*$//;'`" # If old and new list don't at least have the same file list, then one # file or another has definitely changed. if test "${orig_index_files}" != "${new_index_files}" ; then index_files_changed_p=t else # File list is the same. We must compare each file until we find a # difference. index_files_changed_p="" for this_file in ${new_index_files} ; do # cmp -s will return nonzero exit status if files differ. cmp -s "${this_file}" "${this_file}${backup_extension}" if test $? -ne 0 ; then # We only need to keep comparing until we find *one* that # differs, because we'll have to run texindex & tex no # matter what. index_files_changed_p=t break fi done fi # If index files have changed since TeX has been run, or if the aux # file wasn't present originally, run texindex and TeX again. if test "${index_files_changed_p}" ; then retval=0 if test "${new_index_files_sans_aux}" ; then ${texindex} ${new_index_files_sans_aux} retval=$? fi if test ${retval} -eq 0 ; then ${tex} "${command_line_filename}" fi fi fi # Generate list of files to delete, then call rm once with the entire # list. This is significantly faster than multiple executions of rm. file_list="" for file in ${orig_index_files} ; do file_list="${file_list} ${file}${backup_extension}" done if test "${file_list}" ; then rm -f ${file_list} fi done # # eof # |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash/tests In directory usw-pr-cvs1:/tmp/cvs-serv23905/tests Modified Files: glob-test run-all x xx Log Message: Applied GNU bash 1.14.5 diffs Index: glob-test =================================================================== RCS file: /cvsroot/winbash/winbash/tests/glob-test,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- glob-test 9 Mar 2002 16:05:45 -0000 1.3 +++ glob-test 11 Mar 2002 01:47:05 -0000 1.4 @@ -9,7 +9,7 @@ TESTDIR=/tmp/glob-test rm -rf $TESTDIR mkdir $TESTDIR -cd $TESTDIR +builtin cd $TESTDIR touch a b c d abc abd abe bb bcd ca cb dd de mkdir bdir @@ -174,6 +174,6 @@ ;; esac -cd / -/bin/rm -rf $TESTDIR +builtin cd / +rm -rf $TESTDIR exit 0 Index: run-all =================================================================== RCS file: /cvsroot/winbash/winbash/tests/run-all,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- run-all 9 Mar 2002 04:43:17 -0000 1.2 +++ run-all 11 Mar 2002 01:47:05 -0000 1.3 @@ -1,7 +1,8 @@ #! /bin/sh -PATH=$PATH:. +PATH=.:$PATH # just to get the right version of printenv export PATH +unset ENV echo Any output from any test indicates an anomaly worth investigating for x in run-* Index: x =================================================================== RCS file: /cvsroot/winbash/winbash/tests/x,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- x 9 Mar 2002 04:43:17 -0000 1.2 +++ x 11 Mar 2002 01:47:05 -0000 1.3 @@ -1,2 +1,2 @@ -./dollar-star.sh: recho: command not found -./dollar-at.sh: recho: command not found +./dollar-star.sh: recho: command not found +./dollar-at.sh: recho: command not found Index: xx =================================================================== RCS file: /cvsroot/winbash/winbash/tests/xx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- xx 9 Mar 2002 04:43:17 -0000 1.2 +++ xx 11 Mar 2002 01:47:05 -0000 1.3 @@ -1,12 +1,5 @@ -3 4 -5 6 7 8 9 -7 8 9 -/usr/chet -/usr/chet -/a/b/c -/usr/chet 7 -/a/b/c 9 /a/b/c -/a/b/c 9 /a/b/c -/a/b/c /a/b/c -1 2 -1 1 +`Say' echos its argument. Its return value is of no interest. +`Truth' echos its argument and returns a TRUE result. +`False' echos its argument and returns a FALSE result. + + Truth 1 && Truth 2 || Say 3 output= \ No newline at end of file |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash/lib/readline In directory usw-pr-cvs1:/tmp/cvs-serv23905/lib/readline Modified Files: complete.c display.c readline.c vi_mode.c Log Message: Applied GNU bash 1.14.5 diffs Index: complete.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/complete.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- complete.c 9 Mar 2002 16:05:43 -0000 1.2 +++ complete.c 11 Mar 2002 01:47:04 -0000 1.3 @@ -491,7 +491,7 @@ } } - if (rl_point == end) + if (rl_point == end && found_quote == 0) { int quoted = 0; /* We didn't find an unclosed quoted substring upon which to do @@ -691,7 +691,7 @@ not be checked, add !matches[1] to the if clause. */ should_quote = rl_strpbrk (matches[0], rl_completer_word_break_characters) != 0; #if defined (SHELL) - should_quote = should_quote || rl_strpbrk (matches[0], "#$`?*[") != 0; + should_quote = should_quote || rl_strpbrk (matches[0], "#$`?*[!") != 0; #endif if (should_quote) Index: display.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- display.c 9 Mar 2002 16:05:43 -0000 1.2 +++ display.c 11 Mar 2002 01:47:05 -0000 1.3 @@ -185,7 +185,7 @@ return r; } - l = strlen (pmt); + l = pmt ? strlen (pmt) : 0; r = ret = xmalloc (l + 1); for (rl = ignoring = 0, p = pmt; p && *p; p++) @@ -754,7 +754,7 @@ escape sequences (like drawing the `unbold' sequence without a corresponding `bold') that manifests itself on certain terminals. */ - lendiff = strlen (local_prompt); + lendiff = local_prompt ? strlen (local_prompt) : 0; if (current_line == 0 && !_rl_horizontal_scroll_mode && lendiff > visible_length && _rl_last_c_pos > 0 && (ofd - old) >= lendiff && term_cr) Index: readline.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/readline.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- readline.c 9 Mar 2002 16:05:43 -0000 1.2 +++ readline.c 11 Mar 2002 01:47:05 -0000 1.3 @@ -994,7 +994,8 @@ /* Check for LC_CTYPE and use its value to decide the defaults for 8-bit character input and output. */ t = getenv ("LC_CTYPE"); - if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0)) + if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0 || + strcmp (t, "ISO-8859-1") == 0)) { _rl_meta_flag = 1; _rl_convert_meta_chars_to_ascii = 0; @@ -3165,7 +3166,7 @@ return (rl_backward_kill_line (1)); else { - rl_end_of_line (); + rl_end_of_line (1, ignore); if (orig_point != rl_point) rl_kill_text (orig_point, rl_point); rl_point = orig_point; @@ -3188,7 +3189,7 @@ ding (); else { - rl_beg_of_line (); + rl_beg_of_line (1, ignore); rl_kill_text (orig_point, rl_point); } } @@ -3212,7 +3213,7 @@ { if (!rl_kill_ring) { - rl_abort (); + rl_abort (count, ignore); return -1; } @@ -3233,7 +3234,7 @@ if (((rl_last_func != rl_yank_pop) && (rl_last_func != rl_yank)) || !rl_kill_ring) { - rl_abort (); + rl_abort (1, key); return -1; } @@ -3252,7 +3253,7 @@ } else { - rl_abort (); + rl_abort (1, key); return -1; } } Index: vi_mode.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/vi_mode.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vi_mode.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ vi_mode.c 11 Mar 2002 01:47:05 -0000 1.2 @@ -275,7 +275,7 @@ if (key == '*' || key == '\\') { _rl_vi_set_last (key, 1, rl_arg_sign); - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); } return (0); } @@ -286,7 +286,7 @@ { rl_tilde_expand (0, key); _rl_vi_set_last (key, 1, rl_arg_sign); /* XXX */ - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); return (0); } @@ -507,8 +507,8 @@ rl_vi_insert_beg (count, key) int count, key; { - rl_beg_of_line (); - rl_vi_insertion_mode (); + rl_beg_of_line (1, key); + rl_vi_insertion_mode (1, key); return (0); } @@ -517,15 +517,15 @@ { if (rl_point < rl_end) rl_point++; - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); return (0); } rl_vi_append_eol (count, key) int count, key; { - rl_end_of_line (); - rl_vi_append_mode (); + rl_end_of_line (1, key); + rl_vi_append_mode (1, key); return (0); } @@ -836,7 +836,7 @@ rl_begin_undo_group (); _rl_vi_doing_insert = 1; _rl_vi_set_last (key, count, rl_arg_sign); - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); return (0); } @@ -1157,7 +1157,7 @@ rl_begin_undo_group (); _rl_vi_doing_insert = 1; - rl_vi_insertion_mode (); + rl_vi_insertion_mode (1, key); return (0); } |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash/support In directory usw-pr-cvs1:/tmp/cvs-serv23905/support Modified Files: bashbug.sh getcppsyms.c mksysdefs Log Message: Applied GNU bash 1.14.5 diffs Index: bashbug.sh =================================================================== RCS file: /cvsroot/winbash/winbash/support/bashbug.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bashbug.sh 9 Mar 2002 16:05:44 -0000 1.3 +++ bashbug.sh 11 Mar 2002 01:47:05 -0000 1.4 @@ -75,7 +75,10 @@ exit fi - ${RMAIL} $BUGADDR < $TEMP || cat $TEMP >> $HOME/dead.bashbug + ${RMAIL} $BUGADDR < $TEMP || { + cat $TEMP >> $HOME/dead.bashbug + echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2 + } fi exit 0 Index: getcppsyms.c =================================================================== RCS file: /cvsroot/winbash/winbash/support/getcppsyms.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- getcppsyms.c 9 Mar 2002 04:43:16 -0000 1.2 +++ getcppsyms.c 11 Mar 2002 01:47:05 -0000 1.3 @@ -332,6 +332,9 @@ #if defined (n16) printf (" -Dn16"); #endif /* n16 */ +#if defined __nonstopux + printf (" -D__nonstopux"); +#endif #if defined (ns32000) printf (" -Dns32000"); #endif /* ns32000 */ Index: mksysdefs =================================================================== RCS file: /cvsroot/winbash/winbash/support/mksysdefs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mksysdefs 9 Mar 2002 16:05:44 -0000 1.3 +++ mksysdefs 11 Mar 2002 01:47:05 -0000 1.4 @@ -80,6 +80,11 @@ UNAME=UNIX_SV fi +# (sound of teeth grinding...) +if [ "$UNAME" = "UNIX_SV" ] && [ "$UNAME_R" != "4.2" ] && [ "$RELEASE"."$LEVEL" = "4.2" ]; then + UNAME_R="4.2" +fi + # another check for SVR4 on 386 or 486 machines case "${UNAME_M}:${UNAME}:${UNAME_R}" in i[34]86:UNIX_SV:4.*) SYSDEF=USGr4 ;; @@ -239,6 +244,12 @@ ESA) SYSDEF=AIXESA ;; XD88*) SYSDEF=XD88 ;; M88100) SYSDEF=M88100 ;; # Motorola Delta 88K + esac +fi + +if [ "$SYSDEF" = "" ]; then + case "$UNAME_V" in + V[0-9]*L[0-9]*) SYSDEF=UXP ;; # Fujitsu DS/90 esac fi |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash/documentation In directory usw-pr-cvs1:/tmp/cvs-serv23905/documentation Modified Files: bash.1 readline.3 Log Message: Applied GNU bash 1.14.5 diffs Index: bash.1 =================================================================== RCS file: /cvsroot/winbash/winbash/documentation/bash.1,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bash.1 9 Mar 2002 16:05:42 -0000 1.3 +++ bash.1 11 Mar 2002 01:47:04 -0000 1.4 @@ -6,11 +6,11 @@ .\" Case Western Reserve University .\" ch...@in... .\" -.\" Last Change: Tue Dec 6 12:15:11 EST 1994 +.\" Last Change: Fri May 5 10:44:39 EDT 1995 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ -.TH BASH 1 "1994 Dec 6" GNU +! .TH BASH 1 "1995 May 5" GNU .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -1942,7 +1942,7 @@ are restored to the values they had prior to function execution. .PP -Function names may be listed with the +Function names and definitions may be listed with the .B \-f option to the .B declare @@ -3145,13 +3145,6 @@ .B display\-shell\-version (C\-x C\-v) Display version information about the current instance of .BR bash . -.TP -.B emacs\-editing\-mode (C\-e) -When in -.B vi -editing mode, this causes a switch to -.B emacs -editing mode. .PD .SH HISTORY When interactive, the shell provides access to the \fIcommand history\fP, @@ -5334,10 +5327,12 @@ .B bash that you have. .PP -Once you have determined that a bug actually exists, mail a -bug report to \fIbash\-maintainers\fP@\fIprep.ai.MIT.Edu\fP. +Once you have determined that a bug actually exists, use the +.I bashbug +command to submit a bug report. If you have a fix, you are welcome to mail that -as well! Suggestions and `philosophical' bug reports may be mailed +as well! +Suggestions and `philosophical' bug reports may be mailed to \fPbug-bash\fP@\fIprep.ai.MIT.Edu\fP or posted to the Usenet newsgroup .BR gnu.bash.bug . @@ -5356,6 +5351,10 @@ .TP A short script or `recipe' which exercises the bug .PD +.PP +.I bashbug +inserts the first three items automatically into the template +it provides for filing a bug report. .PP Comments and bug reports concerning this manual page should be directed to Index: readline.3 =================================================================== RCS file: /cvsroot/winbash/winbash/documentation/readline.3,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- readline.3 9 Mar 2002 04:43:15 -0000 1.2 +++ readline.3 11 Mar 2002 01:47:04 -0000 1.3 @@ -95,8 +95,6 @@ .fi .LP .nf -.LP -.nf .ft B int rl_parse_and_bind (line) char *line; @@ -744,7 +742,7 @@ yank\-last\-arg (M\-.\^, M\-_\^) Insert the last argument to the previous command (the last word on the previous line). With an argument, -behave exactly like @code{yank-nth-arg}. +behave exactly like \fByank-nth-arg\fP. .PD .SS Commands for Changing Text .PP |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash/builtins In directory usw-pr-cvs1:/tmp/cvs-serv23905/builtins Modified Files: declare.def fc.def getopt.c getopt.h getopts.def kill.def read.def Log Message: Applied GNU bash 1.14.5 diffs Index: declare.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/declare.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- declare.def 10 Mar 2002 21:45:14 -0000 1.3 +++ declare.def 11 Mar 2002 01:47:04 -0000 1.4 @@ -219,13 +219,29 @@ else { SHELL_VAR *find_function (), *funvar; + funvar = find_function (name); if (funvar) { - char *result = named_function_string - (name, (COMMAND *)function_cell (funvar), 1); - printf ("%s\n", result); + if (readonly_p (funvar) && (flags_off & att_readonly)) + { + builtin_error ("%s: readonly function", name); + any_failed++; + NEXT_VARIABLE (); + } + + if (flags_on == att_function && flags_off == 0) + { + char *result = named_function_string + (name, (COMMAND *)function_cell (funvar), 1); + printf ("%s\n", result); + } + else + { + funvar->attributes |= flags_on; + funvar->attributes &= ~flags_off; + } } else any_failed++; @@ -241,13 +257,7 @@ if (!var) var = bind_variable (name, ""); - /* We are not allowed to rebind readonly variables that - already are readonly unless we are turning off the - readonly bit. */ - if (flags_off & att_readonly) - flags_on &= ~att_readonly; - - if (value && readonly_p (var) && (!(flags_off & att_readonly))) + if (readonly_p (var) && (flags_off & att_readonly)) { builtin_error ("%s: readonly variable", name); any_failed++; Index: fc.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/fc.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- fc.def 10 Mar 2002 15:54:11 -0000 1.3 +++ fc.def 11 Mar 2002 01:47:04 -0000 1.4 @@ -299,6 +299,8 @@ { histend = last_hist; histbeg = histend - 16; + if (histbeg < 0) + histbeg = 0; } else { Index: getopt.c =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/getopt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- getopt.c 9 Mar 2002 04:20:36 -0000 1.2 +++ getopt.c 11 Mar 2002 01:47:04 -0000 1.3 @@ -1,9 +1,6 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to ro...@gn... - before changing it! +/* getopt for BASH. - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 + Copyright (C) 1993, 1994 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it @@ -18,119 +15,44 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* NOTE!!! AIX requires this to be the first thing in the file. - Do not put ANYTHING before it! */ -#if !defined (__GNUC__) && defined (_AIX) && !defined (IBMESA) - #pragma alloca -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* not __GNUC__ */ -#if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__)))) -#if defined (IBMESA) -#include <malloc.h> -#else -#include <alloca.h> -#endif /* !IBMESA */ -#else -#ifndef _AIX -char *alloca (); -#endif -#endif /* alloca.h */ -#endif /* not __GNUC__ */ - -#if !__STDC__ && !defined(const) && IN_GCC -#define const -#endif + Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ -#ifdef __NT_VC__ -#include <malloc.h> -#include "../nt_types.h" -#endif +#include <config.h> -/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. */ -#ifndef _NO_PROTO -#define _NO_PROTO +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include <sys/types.h> +# endif +# include <unistd.h> #endif #include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#undef alloca -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -#include <stdlib.h> -#else /* Not GNU C library. */ -#define __alloca alloca -#endif /* GNU C library. */ - -#if !defined (__STDC__) && !defined (const) -# define const -#endif - -/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a - long-named option. Because this is not POSIX.2 compliant, it is - being phased out. */ -/* #define GETOPT_COMPAT */ - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - +#include "memalloc.h" +#include "../shell.h" #include "getopt.h" -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = 0; +/* For communication from `sh_getopt' to the caller. + When `sh_getopt' finds an option that takes an argument, + the argument value is returned here. */ +char *sh_optarg = 0; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller - and for communication between successive calls to `getopt'. + and for communication between successive calls to `sh_getopt'. - On entry to `getopt', zero means this is the first call; initialize. + On entry to `sh_getopt', zero means this is the first call; initialize. - When `getopt' returns EOF, this is the index of the first of the + When `sh_getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. - Otherwise, `optind' communicates from one call to the next + Otherwise, `sh_optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* XXX 1003.2 says this must be 1 before any call. */ -int optind = 0; +int sh_optind = 0; + +/* Index of the current argument. */ +static int sh_curopt; /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -140,217 +62,65 @@ by advancing to the next ARGV-element. */ static char *nextchar; +static int sh_charindex; /* Callers store zero here to inhibit the error message for unrecognized options. */ -int opterr = 1; +int sh_opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering, default_ordering = PERMUTE; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -#include <string.h> -#define my_index strchr -#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) -#else - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -char *getenv (); - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -static void -my_bcopy (from, to, size) - const char *from; - char *to; - int size; -{ - int i; - for (i = 0; i < size; i++) - to[i] = from[i]; -} -#endif /* GNU C library. */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -static void -exchange (argv) - char **argv; -{ - int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); - char **temp = (char **) __alloca (nonopts_size); - - /* Interchange the two blocks of data in ARGV. */ - - my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size); - my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt], - (optind - last_nonopt) * sizeof (char *)); - my_bcopy ((char *) temp, - (char *) &argv[first_nonopt + optind - last_nonopt], - nonopts_size); +int sh_optopt = '?'; - /* Update records for the slots the non-options now occupy. */ +/* Set to 1 when we see an illegal option; public so getopts can reset it. */ +int sh_badopt = 0; - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' + (aside from the initial '-') are option characters. If `sh_getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can + If `sh_getopt' finds another option character, it returns that character, + updating `sh_optind' and `nextchar' so that the next call to `sh_getopt' can resume the scan with the following option character or ARGV-element. - If there are no more option characters, `getopt' returns `EOF'. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) + If there are no more option characters, `sh_getopt' returns `EOF'. + Then `sh_optind' is the index in ARGV of the first ARGV-element + that is not an option. OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to + return '?' after printing an error message. If you set `sh_opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. + ARGV-element, is returned in `sh_optarg'. */ - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ +/* 1003.2 specifies the format of this message. */ +#define BADOPT(c) fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c) +#define NEEDARG(c) fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c) -/* Call this function with an argument of 1 to set the default option - ordering to that required by Posix. The normal default is PERMUTE. */ -void -getopt_set_posix_option_order (on_or_off) - int on_or_off; -{ - if (on_or_off == 1) - default_ordering = REQUIRE_ORDER; - else - default_ordering = PERMUTE; -} - int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) +sh_getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; - const struct option *longopts; - int *longind; - int long_only; { - int option_index; + char c, *temp; - optarg = 0; + sh_optarg = 0; - if (optind > argc || optind < 0) + if (sh_optind >= argc || sh_optind < 0) /* XXX was sh_optind > argc */ { - optind = argc; + sh_optind = argc; return (EOF); } @@ -359,374 +129,126 @@ is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ - if (optind == 0) + if (sh_optind == 0) { - first_nonopt = last_nonopt = optind = 1; - - nextchar = NULL; - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (getenv ("POSIXLY_CORRECT") != NULL) - ordering = REQUIRE_ORDER; - else - ordering = default_ordering; + sh_optind = 1; + nextchar = (char *)NULL; } - if (nextchar == NULL || *nextchar == '\0') + /* Do the increment of `sh_optind' we deferred because the last option + was illegal. */ + if (sh_badopt && (nextchar == 0 || *nextchar == '\0')) { - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; + sh_badopt = 0; + sh_optind++; + nextchar = (char *)NULL; + } - /* Now skip any additional non-options - and extend the range of non-options previously skipped. */ + if (nextchar == 0 || *nextchar == '\0') + { + /* If we have done all the ARGV-elements, stop the scan. */ + if (sh_optind >= argc) + return EOF; - while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - optind++; - last_nonopt = optind; - } + temp = argv[sh_optind]; /* Special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) + Skip it like a null option, and return EOF. */ + if (temp[0] == '-' && temp[1] == '-' && temp[2] == '\0') { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; + sh_optind++; return EOF; } - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if ((argv[optind][0] != '-' || argv[optind][1] == '\0') -#ifdef GETOPT_COMPAT - && (longopts == NULL - || argv[optind][0] != '+' || argv[optind][1] == '\0') -#endif /* GETOPT_COMPAT */ - ) - { - if (ordering == REQUIRE_ORDER) - return EOF; - optarg = argv[optind++]; - return 1; - } + /* If we have come to a non-option, either stop the scan or describe + it to the caller and pass it by. This makes the pseudo-option + `-' mean the end of options, but does not skip over it. */ + if (temp[0] != '-' || temp[1] == '\0') + return EOF; /* We have found another option-ARGV-element. Start decoding its characters. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); + nextchar = argv[sh_curopt = sh_optind] + 1; + sh_charindex = 1; } - if (longopts != NULL - && ((argv[optind][0] == '-' - && (argv[optind][1] == '-' || long_only)) -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - )) + /* Look at and handle the next option-character. */ + + c = *nextchar++; sh_charindex++; + temp = strchr (optstring, c); + + sh_optopt = c; + + /* If the option is illegal, return an error, but defer updating sh_optind + until the next call so $OPTIND is correct. */ + if (sh_badopt = (temp == NULL || c == ':')) { - const struct option *p; - char *s = nextchar; - int exact = 0; - int ambig = 0; - const struct option *pfound = NULL; - int indfound; + if (sh_opterr) + BADOPT (c); - while (*s && *s != '=') - s++; + return '?'; + } - /* Test all options for either exact match or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; - p++, option_index++) - if (!strncmp (p->name, nextchar, s - nextchar)) - { - if (s - nextchar == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second nonexact match found. */ - ambig = 1; - } + /* Increment `sh_optind' when we start to process its last character. */ + if (nextchar == 0 || *nextchar == '\0') + { + sh_optind++; + nextchar = (char *)NULL; + } - if (ambig && !exact) + if (temp[1] == ':') + { + if (nextchar && *nextchar) { - if (opterr) - { - fprintf (stderr, "%s: option `%s' is ambiguous\n", - argv[0], argv[optind]); - fflush (stderr); - } - - nextchar = ""; - optind++; - return '?'; + /* This is an option that requires an argument. */ + sh_optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + sh_optind++; } - - if (pfound != NULL) + else if (sh_optind == argc) { - option_index = indfound; - optind++; - if (*s) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = s + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - { - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - fflush (stderr); - } - else - { - /* +option or -option */ - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - fflush (stderr); - } - } + if (sh_opterr) + NEEDARG (c); - nextchar = ""; - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - { - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); - fflush (stderr); - } - nextchar = ""; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar = ""; - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' -#ifdef GETOPT_COMPAT - || argv[optind][0] == '+' -#endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - { - /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", - argv[0], nextchar); - fflush (stderr); - } - else - { - /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", - argv[0], argv[optind][0], nextchar); - fflush (stderr); - } - } - nextchar = (char *) ""; - optind++; - return '?'; + sh_optopt = c; + sh_optarg = ""; /* Needed by getopts. */ + c = (optstring[0] == ':') ? ':' : '?'; } + else + /* We already incremented `sh_optind' once; + increment it again when taking next ARGV-elt as argument. */ + sh_optarg = argv[sh_optind++]; + nextchar = (char *)NULL; } - - /* Look at and handle the next option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (nextchar == NULL || *nextchar == '\0') - { - ++optind; - nextchar = (char *)NULL; - } - - optopt = c; - - if (temp == NULL || c == ':') - { - if (opterr) - { -#if 0 - if (c < 040 || c >= 0177) - { - fprintf (stderr, "%s: unrecognized option, character code 0%o\n", - argv[0], c); - fflush (stderr); - } - else - { - fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); - fflush (stderr); - } -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); - fflush (stderr); -#endif - } - optopt = c; - return '?'; - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (nextchar && *nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = 0; - nextchar = (char *)NULL; - } - else - { - /* This is an option that requires an argument. */ - if (nextchar && *nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { -#if 0 - fprintf (stderr, "%s: option `-%c' requires an argument\n", - argv[0], c); - fflush (stderr); -#else - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: option requires an argument -- %c\n", - argv[0], c); - fflush (stderr); -#endif - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } + return c; } -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; +void +sh_getopt_restore_state (argv) + char **argv; { - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); + if (nextchar) + nextchar = argv[sh_curopt] + sh_charindex; } -#endif /* _LIBC or not __GNU_LIBRARY__. */ - +#if 0 +void +sh_getopt_debug_restore_state (argv) + char **argv; +{ + if (nextchar && nextchar != argv[sh_curopt] + sh_charindex) + { + itrace("sh_getopt_debug_restore_state: resetting nextchar"); + nextchar = argv[sh_curopt] + sh_charindex; + } +} +#endif + #ifdef TEST /* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ + the above definition of `sh_getopt'. */ int main (argc, argv) @@ -734,13 +256,13 @@ char **argv; { int c; - int digit_optind = 0; + int digit_sh_optind = 0; while (1) { - int this_option_optind = optind ? optind : 1; + int this_option_sh_optind = sh_optind ? sh_optind : 1; - c = getopt (argc, argv, "abc:d:0123456789"); + c = sh_getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; @@ -756,9 +278,9 @@ case '7': case '8': case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) + if (digit_sh_optind != 0 && digit_sh_optind != this_option_sh_optind) printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; + digit_sh_optind = this_option_sh_optind; printf ("option %c\n", c); break; @@ -771,22 +293,22 @@ break; case 'c': - printf ("option c with value `%s'\n", optarg); + printf ("option c with value `%s'\n", sh_optarg); break; case '?': break; default: - printf ("?? getopt returned character code 0%o ??\n", c); + printf ("?? sh_getopt returned character code 0%o ??\n", c); } } - if (optind < argc) + if (sh_optind < argc) { printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); + while (sh_optind < argc) + printf ("%s ", argv[sh_optind++]); printf ("\n"); } Index: getopt.h =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/getopt.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- getopt.h 9 Mar 2002 04:20:36 -0000 1.2 +++ getopt.h 11 Mar 2002 01:47:04 -0000 1.3 @@ -15,20 +15,18 @@ along with this program; if not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */ + #ifndef _GETOPT_H #define _GETOPT_H 1 -#ifdef __cplusplus -extern "C" { -#endif - /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -extern char *optarg; +extern char *sh_optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -39,19 +37,22 @@ When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. - Otherwise, `optind' communicates from one call to the next + Otherwise, `sh_optind' communicates from one call to the next how much of ARGV has been scanned so far. */ -extern int optind; +extern int sh_optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ -extern int opterr; +extern int sh_opterr; /* Set to an option character which was unrecognized. */ -extern int optopt; +extern int sh_optopt; + +extern int sh_getopt (); +extern void sh_getopt_restore_state (); /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector Index: getopts.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/getopts.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- getopts.def 10 Mar 2002 21:45:14 -0000 1.3 +++ getopts.def 11 Mar 2002 01:47:04 -0000 1.4 @@ -91,7 +91,7 @@ getopts_reset (newind) int newind; { - optind = newind; + sh_optind = newind; } /* Error handling is now performed as specified by Posix.2, draft 11 @@ -149,16 +149,16 @@ if (special_error) { - old_opterr = opterr; + old_opterr = sh_opterr; optstr++; - opterr = 0; /* suppress diagnostic messages */ + sh_opterr = 0; /* suppress diagnostic messages */ } if (argc > 1) { t = argv[0]; argv[0] = dollar_vars[0]; - ret = getopt (argc, argv, optstr); + ret = sh_getopt (argc, argv, optstr); argv[0] = t; } else if (rest_of_args == (WORD_LIST *)NULL) @@ -166,7 +166,7 @@ register int i; for (i = 0; dollar_vars[i]; i++); - ret = getopt (i, dollar_vars, optstr); + ret = sh_getopt (i, dollar_vars, optstr); } else { @@ -182,24 +182,24 @@ for (words = rest_of_args; words; words = words->next, i++) v[i] = words->word->word; v[i] = (char *)NULL; - ret = getopt (i, v, optstr); + ret = sh_getopt (i, v, optstr); free (v); } if (special_error) - opterr = old_opterr; + sh_opterr = old_opterr; /* Set the OPTIND variable in any case, to handle "--" skipping. */ - if (optind < 10) + if (sh_optind < 10) { - numval[14] = optind + '0'; + numval[14] = sh_optind + '0'; numval[15] = '\0'; i = 14; } else { numval[i = 15] = '\0'; - n = optind; + n = sh_optind; do { numval[--i] = (n % 10) + '0'; @@ -210,14 +210,14 @@ /* If an error occurred, decide which one it is and set the return code appropriately. In all cases, the option character in error - is in OPTOPT. If an illegal option was encountered, OPTARG is + is in SH_OPTOPT. If an illegal option was encountered, OPTARG is NULL. If a required option argument was missing, OPTARG points to a NULL string (that is, optarg[0] == 0). */ if (ret == '?') { - if (optarg == NULL) + if (sh_optarg == NULL) ret = G_ILLEGAL_OPT; - else if (optarg[0] == '\0') + else if (sh_optarg[0] == '\0') ret = G_ARG_MISSING; } @@ -236,7 +236,7 @@ if (special_error) { - strval[0] = (char) optopt; + strval[0] = (char) sh_optopt; strval[1] = '\0'; bind_variable ("OPTARG", strval); } @@ -254,7 +254,7 @@ strval[1] = '\0'; bind_variable (name, strval); - strval[0] = (char) optopt; + strval[0] = (char) sh_optopt; strval[1] = '\0'; bind_variable ("OPTARG", strval); } @@ -268,7 +268,7 @@ return (EXECUTION_SUCCESS); } - bind_variable ("OPTARG", optarg); + bind_variable ("OPTARG", sh_optarg); strval[0] = (char) ret; strval[1] = '\0'; Index: kill.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/kill.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- kill.def 9 Mar 2002 04:20:36 -0000 1.2 +++ kill.def 11 Mar 2002 01:47:04 -0000 1.3 @@ -39,6 +39,7 @@ extern int errno; #endif /* !errno */ +#include "../bashtypes.h" #include "../shell.h" #include "../trap.h" #include "../jobs.h" Index: read.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/read.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- read.def 9 Mar 2002 16:05:42 -0000 1.3 +++ read.def 11 Mar 2002 01:47:04 -0000 1.4 @@ -262,6 +262,13 @@ free (orig_input_string); return (EXECUTION_FAILURE); } + + /* This has to be done this way rather than using string_list + and list_string because Posix.2 says that the last variable gets the + remaining words and their intervening separators. */ + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, + saw_escape); + if (saw_escape) { t = dequote_string (input_string); |
From: Enrico B. <enr...@us...> - 2002-03-11 01:47:09
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv23905 Modified Files: .build .machine .patchlevel INSTALL README cpp-Makefile execute_cmd.c expr.c general.c jobs.c machines.h subst.c subst.h version.h Log Message: Applied GNU bash 1.14.5 diffs Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- .build 10 Mar 2002 23:25:30 -0000 1.6 +++ .build 11 Mar 2002 01:47:03 -0000 1.7 @@ -1 +1 @@ -3 +5 Index: .machine =================================================================== RCS file: /cvsroot/winbash/winbash/.machine,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .machine 9 Mar 2002 16:58:09 -0000 1.3 +++ .machine 11 Mar 2002 01:47:04 -0000 1.4 @@ -1,2 +1 @@ - - last made for a i386 running Windows_NT \ No newline at end of file + last made for a i386 running Windows_NT Index: .patchlevel =================================================================== RCS file: /cvsroot/winbash/winbash/.patchlevel,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .patchlevel 10 Mar 2002 23:25:31 -0000 1.3 +++ .patchlevel 11 Mar 2002 01:47:04 -0000 1.4 @@ -1 +1 @@ -4 +5 Index: INSTALL =================================================================== RCS file: /cvsroot/winbash/winbash/INSTALL,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- INSTALL 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ INSTALL 11 Mar 2002 01:47:04 -0000 1.2 @@ -23,8 +23,11 @@ 3. Type `./bash' to see if the compile worked. - 4. Type `make install bindir=/usr/gnu/bin' (or wherever you - keep GNU binaries) to copy bash to your binaries directory. + 4. Type `make install prefix=/usr/gnu/' (or the appropriate root + of your local GNU software installation tree) to copy bash to + your binaries directory, assumed to be ${prefix}/bin. This will + also attempt to install the manual pages under ${prefix}/man + and the info file under ${prefix}/info. * Menu: Index: README =================================================================== RCS file: /cvsroot/winbash/winbash/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- README 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ README 11 Mar 2002 01:47:04 -0000 1.2 @@ -1,5 +1,6 @@ This is the source for the version of bash for win32 that we use here at Motive. I believe this version of bash was originally ported by our very own +FAQ - a set of frequently-asked questions about Bash with answers Jerry Frain during his banner days at Tivoli. Since then, another Tivoli alumni and motive superstar, Enrico Brunetta, has also added functionality and fixed bugs in this source. Who knows who else has had their hands in this.... Index: cpp-Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/cpp-Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cpp-Makefile 10 Mar 2002 23:25:31 -0000 1.2 +++ cpp-Makefile 11 Mar 2002 01:47:04 -0000 1.3 @@ -66,8 +66,6 @@ /* Include some boilerplate Gnu makefile definitions. */ prefix = /usr/local -/**/#prefix = @prefix@ - exec_prefix = $(prefix) bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib @@ -84,12 +82,9 @@ infodir = $(prefix)/info srcdir = . -/**/#srcdir = @srcdir@ VPATH = .:$(srcdir) -/**/#incdir = @incdir@ - /* If you have purify, and want to use it, uncomment this definition or run the make as `make -f bash-Makefile bash PURIFY=purify'. */ PURIFY = # purify @@ -155,8 +150,9 @@ RM = rm -f AR = ar -INSTALL_PROGRAM = install -c -INSTALL_DATA = install -c -m 644 +INSTALL = $(SUPPORT_SRC)install.sh +INSTALL_PROGRAM = $(INSTALL) -c +INSTALL_DATA = $(INSTALL) -c -m 644 COMPRESS = gzip COMPRESS_EXT = .gz @@ -721,39 +717,39 @@ /**/# Rules for cleaning the readline and termcap sources. #if defined (HAVE_READLINE_SOURCE) -CLEAN_READLINE = (cd $(RL_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_READLINE = (cd $(RL_LIBDIR); $(MAKE) $(MFLAGS) $@) #else CLEAN_READLINE = : #endif /* !HAVE_READLINE_SOURCE */ #if defined (HAVE_HISTORY_SOURCE) # if !defined (READLINE) -CLEAN_HISTORY = (cd $(HIST_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_HISTORY = (cd $(HIST_LIBDIR); $(MAKE) $(MFLAGS) $@) # else CLEAN_HISTORY = : # endif /* READLINE */ #endif /* !HAVE_HISTORY_SOURCE */ #if defined (HAVE_TERMCAP_SOURCE) -CLEAN_TERMCAP = (cd $(TERM_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_TERMCAP = (cd $(TERM_LIBDIR); $(MAKE) $(MFLAGS) $@) #else CLEAN_TERMCAP = : #endif /* !HAVE_TERMCAP_SOURCE */ #if defined (USE_GLOB_LIBRARY) -CLEAN_GLOB = (cd $(GLOB_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_GLOB = (cd $(GLOB_LIBDIR); $(MAKE) $(MFLAGS) $@) #else CLEAN_GLOB = : #endif /* !USE_GLOB_LIBRARY */ #if defined (HAVE_TILDE_SOURCE) -CLEAN_TILDE = (cd $(TILDE_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_TILDE = (cd $(TILDE_LIBDIR); $(MAKE) $(MFLAGS) $@) #else CLEAN_TILDE = : #endif /* !HAVE_TILDE_SOURCE */ #if defined (USE_GNU_MALLOC_LIBRARY) -CLEAN_MALLOC = (cd $(MALLOC_LIBDIR); $(MAKE) $(MFLAGS) clean) +CLEAN_MALLOC = (cd $(MALLOC_LIBDIR); $(MAKE) $(MFLAGS) $@) #else CLEAN_MALLOC = : #endif /* !USE_GNU_MALLOC_LIBRARY */ @@ -918,11 +914,6 @@ unwind_prot.o $(VPRINT_OBJ) input.o $(HIST_SUPPORT_OBJ) \ $(SIGLIST) $(GETCWD) version.o $(RL_SUPPORT_OBJ) $(BUILTINS_LIB) -#if defined (LOAD_BUILTIN) -LOAD_DEF = $(DEFDIR)load.def -LOAD_OBJ = $(DEFDIR)load.o -#endif /* LOAD_BUILTIN */ - /**/# Where the source code of the shell builtins resides. BUILTIN_SRCDIR=$(srcdir)/builtins/ /**/# The trailing slash was left off this definition on purpose @@ -1002,7 +993,7 @@ TEST_SUITE_SUPPORT = $(TEST_SUITE)[a-zA-Z0-9]* $(SUPPORT_SRC)recho.c CREATED_SUPPORT = $(ENDIAN_OUTPUT) $(SIGNAMES_OUTPUT) sysdefs.h \ - $(SDIR)getcppsyms recho tests/recho + $(SDIR)getcppsyms recho tests/recho tests/printenv SUPPORT = configure $(ENDIAN_SUPPORT) $(SIGNAMES_SUPPORT) $(SCRIPTS_SUPPORT) \ $(BUILTIN_SUPPORT) COPYING Makefile cpp-Makefile ChangeLog \ @@ -1439,21 +1430,23 @@ clone: $(THINGS_TO_TAR) @$(MKTARFILE) +notar $(Machine) $(OS) $(THINGS_TO_TAR) -install: .made - -if [ -f $(bindir)/$(Program) ]; \ - then mv $(bindir)/$(Program) $(bindir)/$(Program).old; \ +installdirs: + @${SHELL} $(SUPPORT_SRC)mkdirs $(bindir) + @${SHELL} $(SUPPORT_SRC)mkdirs $(mandir) $(man3dir) + @${SHELL} $(SUPPORT_SRC)mkdirs $(infodir) + +install: .made installdirs documentation + -if [ -f $(bindir)/$(Program) ]; then \ + rm -f $(bindir)/$(Program).old ;\ + ln $(bindir)/$(Program) $(bindir)/$(Program).old; \ fi $(INSTALL_PROGRAM) $(Program) $(bindir)/$(Program) -if [ -f $(bindir)/bashbug ]; \ then mv $(bindir)/bashbug $(bindir)/bashbug.old; \ fi $(INSTALL_PROGRAM) bashbug $(bindir)/bashbug - $(RM) installed-$(Program) - -ln -s $(bindir)/$(Program) installed-$(Program) ( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) mandir=$(mandir) \ - man3dir=$(man3dir) infodir=$(infodir) \ - INSTALL_PROGRAM="${INSTALL_PROGRAM}" \ - INSTALL_DATA="${INSTALL_DATA}" $@ ) + man3dir=$(man3dir) infodir=$(infodir) $@ ) uninstall: .made $(RM) $(bindir)/$(Program) installed-$(Program) $(bindir)/bashbug @@ -1482,11 +1475,8 @@ mv -f newversion.h version.h $(MAKE) -f $(srcdir)/Makefile $(MFLAGS) srcdir=$(srcdir) -texindex: force - build_lib_in_dir($(LIBPATH)doc-support, texindex, $${topdir}/lib/doc-support, $${topdir}/lib/doc-support/Makefile) - -documentation: force texindex - (cd $(DOCDIR); $(MAKE) $(MFLAGS) CFLAGS='$(CCFLAGS)') +documentation: force + (cd $(DOCDIR); $(MAKE) $(MFLAGS)) force: @@ -1496,13 +1486,18 @@ TAGS: $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) ctags -x $(SOURCES) $(BUILTIN_C_SRC) $(LIBRARY_SOURCE) > $@ -clean: +basic-clean: $(RM) $(OBJECTS) $(Program) bashbug ansi-Makefile *.aux $(RM) .build .made .machine version.h - $(RM) $(CREATED_SUPPORT) bash-Makefile + $(RM) $(CREATED_SUPPORT) $(RM) tags TAGS - (cd $(DOCDIR); $(MAKE) $(MFLAGS) clean) - (cd builtins; $(MAKE) $(MFLAGS) clean) + +mostlyclean: + $(RM) $(OBJECTS) $(Program) bashbug + $(RM) .build .made .machine version.h + $(RM) tags TAGS + (cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) + (cd builtins && $(MAKE) $(MFLAGS) $@ ) $(CLEAN_READLINE) ; $(CLEAN_HISTORY) ; $(CLEAN_TERMCAP) ; @@ -1510,16 +1505,33 @@ $(CLEAN_TILDE) ; $(CLEAN_MALLOC) ; -distclean: clean - $(RM) installed-bash +distclean clean: basic-clean + (cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) + (cd builtins && $(MAKE) $(MFLAGS) $@ ) + $(CLEAN_READLINE) ; + $(CLEAN_HISTORY) ; + $(CLEAN_TERMCAP) ; + $(CLEAN_GLOB) ; + $(CLEAN_TILDE) ; + $(CLEAN_MALLOC) ; + $(RM) bash-Makefile -realclean: clean - $(RM) y.tab.c y.tab.h parser-built installed-bash +realclean maintainer-clean: basic-clean + $(RM) y.tab.c y.tab.h parser-built + (cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) + (cd builtins && $(MAKE) $(MFLAGS) $@ ) + $(CLEAN_READLINE) ; + $(CLEAN_HISTORY) ; + $(CLEAN_TERMCAP) ; + $(CLEAN_GLOB) ; + $(CLEAN_TILDE) ; + $(CLEAN_MALLOC) ; + $(RM) bash-Makefile recho: $(SUPPORT_SRC)recho.c @$(CC) -o $@ $(SUPPORT_SRC)recho.c -tests: force $(Program) recho +tests check: force $(Program) recho @cp recho tests ( cd tests ; sh run-all ) Index: execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- execute_cmd.c 10 Mar 2002 23:25:31 -0000 1.4 +++ execute_cmd.c 11 Mar 2002 01:47:04 -0000 1.5 @@ -1447,16 +1447,16 @@ if (select_command->flags & CMD_IGNORE_RETURN) select_command->action->flags |= CMD_IGNORE_RETURN; - ps3_prompt = get_string_value ("PS3"); - if (!ps3_prompt) - ps3_prompt = "#? "; - unwind_protect_int (return_catch_flag); unwind_protect_jmp_buf (return_catch); return_catch_flag++; while (1) { + ps3_prompt = get_string_value ("PS3"); + if (!ps3_prompt) + ps3_prompt = "#? "; + QUIT; selection = select_query (list, list_len, ps3_prompt); QUIT; @@ -2046,10 +2046,12 @@ add_unwind_protect (dispose_builtin_env, (char *) NULL); dispose_used_env_vars (); } +#if 0 else builtin_env = (char **) NULL; +#endif } - + result = ((*builtin) (words->next)); if (subshell == 0 && builtin == source_builtin) @@ -2113,9 +2115,11 @@ add_unwind_protect (dispose_function_env, (char *) NULL); dispose_used_env_vars (); } +#if 0 else function_env = (char **) NULL; - +#endif + /* Note the second argument of "1", meaning that we discard the current value of "$*"! This is apparently the right thing. */ remember_args (words->next, 1); Index: expr.c =================================================================== RCS file: /cvsroot/winbash/winbash/expr.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- expr.c 9 Mar 2002 16:05:41 -0000 1.2 +++ expr.c 11 Mar 2002 01:47:04 -0000 1.3 @@ -768,7 +768,7 @@ name = get_name_for_error (); for (t = expression; whitespace (*t); t++) ; - fprintf (stderr, "%s: %s%s: %s (remainder of expression is \"%s\")", + fprintf (stderr, "%s: %s: %s (remainder of expression is \"%s\")\n", name, t, msg, (lasttp && *lasttp) ? lasttp : ""); LONGJMP (evalbuf, 1); Index: general.c =================================================================== RCS file: /cvsroot/winbash/winbash/general.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- general.c 10 Mar 2002 23:25:31 -0000 1.3 +++ general.c 11 Mar 2002 01:47:04 -0000 1.4 @@ -633,9 +633,11 @@ i = start + 1; } - /* Handle backquoted `/'. */ +#if 0 + /* Handle backslash-quoted `/'. */ if (start > 0 && result[start - 1] == '\\') continue; +#endif /* Check for trailing `/'. */ if (start && !result[i]) Index: jobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/jobs.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- jobs.c 10 Mar 2002 23:25:31 -0000 1.4 +++ jobs.c 11 Mar 2002 01:47:04 -0000 1.5 @@ -1464,7 +1464,17 @@ if (!child) { give_terminal_to (shell_pgrp); - UNBLOCK_CHILD (oset); + struct sigaction act, oact; + sigset_t nullset, chldset; + + sigemptyset (&nullset); + sigemptyset (&chldset); + sigprocmask (SIG_SETMASK, &nullset, &chldset); + act.sa_handler = SIG_DFL; + sigemptyset (&act.sa_mask); + sigemptyset (&oact.sa_mask); + act.sa_flags = 0; + sigaction (SIGCHLD, &act, &oact); programming_error ("wait_for: No record of pid %d", pid); } @@ -1510,7 +1520,8 @@ waitchld (0); waiting_for_job = 0; # if defined (MUST_UNBLOCK_CHILD) - BLOCK_CHILD (set, oset); + sigaction (SIGCHLD, &oact, (struct sigaction *)NULL); + sigprocmask (SIG_SETMASK, &chldset, (sigset_t *)NULL); # endif #endif /* !WAITPID_BROKEN */ goto wait_loop; @@ -1581,8 +1592,19 @@ WIFSIGNALED (child->status) && WTERMSIG (child->status) == SIGINT) { - putchar ('\n'); - fflush (stdout); + /* If SIGINT is not trapped, set the interrupt state if in a + loop so the loop will be broken. If not in a loop, print + the newline that the kernel does not. */ + if (signal_is_trapped (SIGINT) == 0) + { + if (loop_level) + interrupt_state++; + else + { + putchar ('\n'); + fflush (stdout); + } + } } notify_and_cleanup (); @@ -1814,6 +1836,13 @@ BLOCK_CHILD (set, oset); already_running = (JOBSTATE (job) == JRUNNING); + + if (JOBSTATE (job) == JDEAD) + { + report_error ("%s: job has terminated", this_command_name); + UNBLOCK_CHILD (oset); + return (-1); + } if (JOBSTATE (job) == JDEAD) { Index: machines.h =================================================================== RCS file: /cvsroot/winbash/winbash/machines.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- machines.h 10 Mar 2002 23:25:31 -0000 1.3 +++ machines.h 11 Mar 2002 01:47:04 -0000 1.4 @@ -471,7 +471,7 @@ * Place /bsd43/bin in your PATH before /bin. * Use `$(CC) -E' instead of `/lib/cpp' in Makefile. */ -#if defined (mips) && (!defined (M_MACHINE) || defined (RiscOS)) +#if defined (mips) && ((!defined (M_MACHINE) && !defined (__nonstopux)) || defined (RiscOS)) # if defined (MIPSEB) # define M_MACHINE "MIPSEB" @@ -2039,9 +2039,17 @@ /* ************************ */ /* */ -/* Tandem running SVR3 */ +/* Tandem */ /* */ /* ************************ */ +/* I don't know what this is supposed to be (Greg Lehey, LEMIS, 29 May 1995). + * Tandem had two very different machines which ran SVR3: the LXN, based on + * a Motorola 68000, and the S2, based on a MIPS R3000. Both are obsolete + * (well, S2s should now be running NonStop UX version B, which is a flavour + * of SVR4). I'm leaving this here and will test for NonStop UX B with the + * preprocessor variable __nonstopux, which is set by the native compiler and + * should also be set by any other compiler, such as gcc (caveat portor: you'$ + * need to fix gcc config to to get this). */ #if defined (tandem) && !defined (M_MACHINE) # define M_MACHINE "tandem" # define M_OS "USG" @@ -2055,13 +2063,58 @@ # undef HAVE_GETWD #endif /* Tandem running SVR3 */ +/* This is for NonStop UX Bxx, which is SVR4, but there's a very good + * chance it will trigger on NonStop UX Axx (SVR3). If this happens, + * fix it or upgrade your OS. */ +#if defined (mips) && defined (__nonstopux) /* Integrity, NonStop UX */ +# define M_MACHINE "Integrity" +# define M_OS "NonStop_UX" +# undef HAVE_GETWD +# define HAVE_DIRENT +# define HAVE_STRERROR +# define HAVE_VFPRINTF +# define VOID_SIGHANDLER +# define HAVE_SYS_SIGLIST +# define HAVE_SETLINEBUF +# define HAVE_GETGROUPS +# undef HAVE_ALLOCA +#endif + +/* ****************** */ +/* */ +/* Fujitsu UXP/M */ +/* */ +/* ****************** */ + +#if defined (__uxpm__) +# define M_MACHINE "VP" +# define M_OS "USG" +# define VOID_SIGHANDLER +# define HAVE_POSIX_SIGNALS +# define HAVE_VFPRINTF +# define HAVE_DIRENT +# define HAVE_SETVBUF +# define HAVE_STRCHR +# define HAVE_STRERROR +# define HAVE_GETGROUPS +# define HAVE_DUP2 +# undef HAVE_ALLOCA +# undef HAVE_GETWD +# define HAVE_GETCWD +# define HAVE_SYS_SIGLIST +# define NO_SBRK_DECL +# define SYSDEP_CFLAGS -DHAVE_UID_T -Dsys_siglist=_sys_siglist -DUSGr4 +# define EXTRA_LIB_SEARCH_PATH /usr/ucblib +# define REQUIRED_LIBRARIES -lc -lucb +#endif + /* ****************** */ /* */ /* Amdahl UTS */ /* */ /* ****************** */ -#if defined (UTS) +#if defined (UTS) && !defined (M_MACHINE) # define M_MACHINE "uts" # define M_OS "systemV" # define SYSDEP_CFLAGS -DUSG -DMEMMOVE_MISSING Index: subst.c =================================================================== RCS file: /cvsroot/winbash/winbash/subst.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- subst.c 10 Mar 2002 23:25:31 -0000 1.4 +++ subst.c 11 Mar 2002 01:47:04 -0000 1.5 @@ -50,6 +50,7 @@ #else #include <tilde/tilde.h> #endif +#include "builtins/getopt.h" #if defined (HISTORY) #include "bashhist.h" @@ -86,7 +87,6 @@ extern int dollar_dollar_pid, no_brace_expansion; extern int posixly_correct; -extern int opterr, optind; extern int eof_encountered, eof_encountered_limit, ignoreeof; extern char *this_command_name; extern jmp_buf top_level; @@ -1116,6 +1116,26 @@ return (current_word); } +/* Remove IFS white space at the end of STRING. Start at the end + of the string and walk backwards until the beginning of the string + or we find a character that's not IFS white space and not CTLESC. + Only let CTLESC escape a white space character if SAW_ESCAPE is + non-zero. */ +char * +strip_trailing_ifs_whitespace (string, separators, saw_escape) + char *string, *separators; + int saw_escape; +{ + char *s; + + s = string + STRLEN (string) - 1; + while (s > string && ((spctabnl (*s) && issep (*s)) || + (saw_escape && *s == CTLESC && spctabnl (s[1])))) + s--; + *++s = '\0'; + return string; +} + #if defined (PROCESS_SUBSTITUTION) #define EXP_CHAR(s) (s == '$' || s == '`' || s == '<' || s == '>' || s == CTLESC) #else @@ -1391,6 +1411,25 @@ return (value); } +/* This does not perform word splitting or dequote the WORD_LIST + it returns. */ +static WORD_LIST * +expand_string_for_rhs (string, quoted, dollar_at_p, has_dollar_at) + char *string; + int quoted, *dollar_at_p, *has_dollar_at; +{ + WORD_DESC td; + WORD_LIST *tresult; + + if (string == 0 || *string == '\0') + return (WORD_LIST *)NULL; + + bzero (&td, sizeof (td)); + td.word = string; + tresult = call_expand_word_internal (&td, quoted, dollar_at_p, has_dollar_at); + return (tresult); +} + /* Expand STRING just as if you were expanding a word, but do not dequote the resultant WORD_LIST. This is called only from within this file, and is used to correctly preserve quoted characters when expanding @@ -1470,9 +1509,17 @@ char *temp; temp = xmalloc (3); - temp[0] = CTLESC; - temp[1] = c; - temp[2] = '\0'; + if (c == 0) + { + temp[0] = CTLNUL; + temp[1] = '\0'; + } + else + { + temp[0] = CTLESC; + temp[1] = c; + temp[2] = '\0'; + } return (temp); } @@ -2438,7 +2485,8 @@ SHELL_VAR *var = find_variable (name); if (var && !invisible_p (var) && (temp = value_cell (var))) - temp = quote_escapes (temp); + temp = quoted && temp && *temp ? quote_string (temp) + : quote_escapes (temp); } return (temp); } @@ -2453,7 +2501,7 @@ { WORD_LIST *l; char *t, *t1, *temp; - int i; + int i, lquote, hasdol; if (value[0] == '~' || (strchr (value, '~') && unquoted_substring ("=~", value))) @@ -2462,15 +2510,24 @@ temp = savestring (value); /* This is a hack. A better fix is coming later. */ - if (*temp == '"') + lquote = 0; + if (*temp == '"' && temp[strlen (temp) - 1] == '"') { i = 1; t = string_extract_double_quoted (temp, &i); /* XXX */ free (temp); temp = t; + lquote = 1; /* XXX */ } - l = *temp ? expand_string_internal (temp, quoted) : (WORD_LIST *)NULL; + hasdol = 0; + /* XXX was quoted not lquote */ + l = *temp ? expand_string_for_rhs (temp, quoted||lquote, &hasdol, (int *)NULL) + : (WORD_LIST *)NULL; free (temp); + /* expand_string_for_rhs does not dequote the word list it returns, but + there are a few cases in which we need to add quotes. */ + if (lquote && quoted == 0 && hasdol == 0 && l && l->word->quoted == 0) + quote_list (l); if (l) { @@ -2814,6 +2871,12 @@ *expanded_something = 0; break; } + if (quoted && temp && *temp == '\0' /* && istring_index > 0 */) + { + free (temp); + temp = (char *)NULL; + } + goto add_number; /* The only difference between this and $@ is when the @@ -2998,6 +3061,16 @@ scheme. */ value = extract_dollar_brace_string (string, &sindex); + /* XXX - this is a hack. A better fix is + coming later. */ + if ((value[0] == '$' && value[1] == '@') || + (value[0] == '"' && value[1] == '$' && value[2] == '@')) + { + if (quoted) + quoted_dollar_at++; + if (contains_dollar_at) + *contains_dollar_at = 1; + } if (string[sindex] == '}') sindex++; else @@ -3047,7 +3120,13 @@ { char *t; if (!value || !*value || !temp || !*temp) - break; + break; + if (quoted) + { + t = dequote_string (temp); + free (temp); + temp = t; + } t = parameter_brace_remove_pattern (value, temp, c); free (temp); free (value); @@ -3197,13 +3276,13 @@ default: { /* Find the variable in VARIABLE_LIST. */ - int old_index = sindex; + int old_index; char *name; SHELL_VAR *var; temp = (char *) NULL; - for (; + for (old_index = sindex; (c = string[sindex]) && (isletter (c) || digit (c) || c == '_'); sindex++); @@ -3224,7 +3303,9 @@ if (var && !invisible_p (var) && value_cell (var)) { - temp = quote_escapes (value_cell (var)); + temp = value_cell (var); + temp = quoted && temp && *temp ? quote_string (temp) + : quote_escapes (temp); free (name); goto add_string; } @@ -3559,7 +3640,14 @@ /* According to Posix.2, "$@" expands to a single word if IFS="" and the positional parameters are not empty. */ if (quoted_dollar_at && ifs_chars && *ifs_chars) - temp_list = list_string (istring, " ", 1); + { + temp_list = list_string (istring, " ", 1); +#if 0 + /* This turns quoted null strings back into CTLNULs */ + dequote_list (temp_list); + quote_list (temp_list); +#endif + } else { WORD_DESC *tword; @@ -4790,7 +4878,7 @@ if (tt && *tt) s = atoi (tt); - opterr = s; + sh_opterr = s; } #endif /* GETOPTS_BUILTIN */ Index: subst.h =================================================================== RCS file: /cvsroot/winbash/winbash/subst.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- subst.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ subst.h 11 Mar 2002 01:47:04 -0000 1.2 @@ -74,6 +74,7 @@ extern WORD_LIST *list_string __P((char *, char *, int)); extern char *get_word_from_string __P((char **, char *, char **)); +extern char *strip_trailing_ifs_whitespace __P((char *, char *, int)); /* Given STRING, an assignment string, get the value of the right side of the `=', and bind it to the left side. If EXPAND is true, then Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- version.h 10 Mar 2002 23:25:31 -0000 1.5 +++ version.h 11 Mar 2002 01:47:04 -0000 1.6 @@ -5,12 +5,12 @@ #define DISTVERSION "1.14" /* The patch level of this version of the shell. */ -#define PATCHLEVEL 4 +#define PATCHLEVEL 5 /* The last built version of this shell. */ -#define BUILDVERSION 3 +#define BUILDVERSION 5 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.4(3) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.5(5) GNU" |
From: Enrico B. <enr...@us...> - 2002-03-11 00:22:43
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv8137 Modified Files: Makefile Log Message: Added newversion to clean target Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile 10 Mar 2002 23:25:31 -0000 1.6 +++ Makefile 11 Mar 2002 00:22:40 -0000 1.7 @@ -192,8 +192,8 @@ $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $@ $< clean: - $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb \ - builtins.pdb newversion.pdb newversion.ilk \ + $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb builtins.pdb \ + newversion.obj newversion.exe newversion.pdb newversion.ilk \ TAGS cd builtins ; $(MAKE) clean |
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv28243 Modified Files: .build .patchlevel Makefile bashhist.c config.h config.h.mini cpp-Makefile execute_cmd.c externs.h flags.c flags.h general.c general.h jobs.c machines.h mailcheck.c nojobs.c parse.y print_cmd.c shell.c siglist.h stdc.h subst.c trap.c variables.c version.h Log Message: Applied 1.14.4 GNU diffs Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- .build 10 Mar 2002 20:33:03 -0000 1.5 +++ .build 10 Mar 2002 23:25:30 -0000 1.6 @@ -1 +1 @@ -2 +3 Index: .patchlevel =================================================================== RCS file: /cvsroot/winbash/winbash/.patchlevel,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- .patchlevel 9 Mar 2002 16:05:41 -0000 1.2 +++ .patchlevel 10 Mar 2002 23:25:31 -0000 1.3 @@ -1 +1 @@ -3 +4 Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Makefile 10 Mar 2002 21:42:16 -0000 1.5 +++ Makefile 10 Mar 2002 23:25:31 -0000 1.6 @@ -193,7 +193,7 @@ clean: $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb \ - newversion.pdb newversion.ilk \ + builtins.pdb newversion.pdb newversion.ilk \ TAGS cd builtins ; $(MAKE) clean Index: bashhist.c =================================================================== RCS file: /cvsroot/winbash/winbash/bashhist.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bashhist.c 10 Mar 2002 21:45:13 -0000 1.2 +++ bashhist.c 10 Mar 2002 23:25:31 -0000 1.3 @@ -150,7 +150,7 @@ { int result = 0; - if (interactive && history_lines_this_session) + if (history_lines_this_session) { char *hf = get_string_value ("HISTFILE"); Index: config.h =================================================================== RCS file: /cvsroot/winbash/winbash/config.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- config.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ config.h 10 Mar 2002 23:25:31 -0000 1.2 @@ -84,9 +84,13 @@ # define HISTORY #endif /* BANG_HISTORY && !HISTORY */ +#if defined (READLINE) && !defined (HISTORY) +# define HISTORY +#endif + #ifndef __NT_VC__ #define DEFAULT_PATH_VALUE \ - ":/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/etc:/usr/etc" + "/bin:/usr/bin:/usr/ucb:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib" #else #define DEFAULT_PATH_VALUE \ ";c:/usr/gnu/bin;c:/usr/local/bin;c:/dos;c:/winnt35/system32;c:/win32" @@ -97,7 +101,20 @@ /* The value for PATH when invoking `command -p'. This is only used when the Posix.2 confstr () function, or CS_PATH define are not present. */ #define STANDARD_UTILS_PATH \ - "/bin:/usr/bin:/usr/ucb:/usr/sbin:/etc:/usr/etc" + "/bin:/usr/bin:/usr/ucb:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib" + +/* Put system-specific default mail directories here. */ +#if defined (__bsdi__) || defined (__FreeBSD__) || defined (__NetBSD__) +# define DEFAULT_MAIL_PATH "/var/mail/" +#endif + +#if !defined (DEFAULT_MAIL_PATH) +#if defined (USG) +# define DEFAULT_MAIL_PATH "/usr/mail/" +#else +# define DEFAULT_MAIL_PATH "/usr/spool/mail/" +#endif +#endif /* Define V9_ECHO if you want to give the echo builtin backslash-escape interpretation using the -e option, in the style of the Bell Labs 9th Index: config.h.mini =================================================================== RCS file: /cvsroot/winbash/winbash/config.h.mini,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- config.h.mini 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ config.h.mini 10 Mar 2002 23:25:31 -0000 1.2 @@ -92,14 +92,31 @@ # define HISTORY #endif /* BANG_HISTORY && !HISTORY */ +#if defined (READLINE) && !defined (HISTORY) +# define HISTORY +#endif + /* The default value of the PATH variable. */ #define DEFAULT_PATH_VALUE \ - ":/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/etc:/usr/etc" + "/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:." /* The value for PATH when invoking `command -p'. This is only used when the Posix.2 confstr () function, or CS_PATH define are not present. */ #define STANDARD_UTILS_PATH \ - "/bin:/usr/bin:/usr/ucb:/usr/sbin:/etc:/usr/etc" + "/bin:/usr/bin:/usr/ucb:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib" + +/* Put system-specific default mail directories here. */ +#if defined (__bsdi__) || defined (__FreeBSD__) || defined (__NetBSD__) +# define DEFAULT_MAIL_PATH "/var/mail/" +#endif + +#if !defined (DEFAULT_MAIL_PATH) +#if defined (USG) +# define DEFAULT_MAIL_PATH "/usr/mail/" +#else +# define DEFAULT_MAIL_PATH "/usr/spool/mail/" +#endif +#endif /* Define V9_ECHO if you want to give the echo builtin backslash-escape interpretation using the -e option, in the style of the Bell Labs 9th Index: cpp-Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/cpp-Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cpp-Makefile 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ cpp-Makefile 10 Mar 2002 23:25:31 -0000 1.2 @@ -312,8 +312,8 @@ $(VARARGSH) $(STRCHR) $(STRCASE) $(DEVFD) \ -D$(Machine) -D$(OS) LDFLAGS = $(NOSHARE) $(SYSDEP_LD) $(EXTRA_LD_PATH) $(PROFILE_FLAGS) $(CFLAGS) -CCFLAGS = $(PROFILE_FLAGS) $(CFLAGS) $(SYSTEM_FLAGS) -DSHELL $(ALLOCA_CFLAGS) \ - $(MALLOC_CFLAGS) +CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) -DSHELL $(ALLOCA_CFLAGS) \ + $(MALLOC_CFLAGS) $(CFLAGS) CPPFLAGS= -I. -I$(srcdir) -I$(LIBSRC) GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wwrite-strings -Werror -Wstrict-prototypes \ @@ -385,11 +385,9 @@ /**/# The type of machine and OS Bash is being compiled on. HOSTTYPE_DECL = -DHOSTTYPE='$(SYSTEM_NAME)' -DOSTYPE='$(OS_NAME)' -MAINTAIN_DEFINE = -DMAINTAINER='"bug...@pr..."' - /**/# The group of configuration flags. These are for shell.c -CFG_FLAGS = -DOS_NAME='$(OS_NAME)' -DProgram=$(Program) \ - -DSYSTEM_NAME='$(SYSTEM_NAME)' $(SIGLIST_FLAG) $(MAINTAIN_DEFINE) +CFG_FLAGS = -DOS_NAME='$(OS_NAME)' -DSYSTEM_NAME='$(SYSTEM_NAME)' \ + $(SIGLIST_FLAG) /* **************************************************************** */ /* */ Index: execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- execute_cmd.c 10 Mar 2002 21:45:13 -0000 1.3 +++ execute_cmd.c 10 Mar 2002 23:25:31 -0000 1.4 @@ -3511,7 +3511,7 @@ /* We have to use access(2) to determine access because AFS does not support Unix file system semantics. This may produce wrong answers for non-AFS files when ruid != euid. I hate AFS. */ - if (access (name, X_OK)) + if (access (name, X_OK) == 0) return (FS_EXISTS | FS_EXECABLE); else return (FS_EXISTS); Index: externs.h =================================================================== RCS file: /cvsroot/winbash/winbash/externs.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- externs.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ externs.h 10 Mar 2002 23:25:31 -0000 1.2 @@ -57,6 +57,7 @@ extern void reset_mail_timer __P((void)); extern void reset_mail_files __P((void)); extern void free_mail_files __P((void)); +extern char *make_default_mailpath __P((void)); extern void remember_mail_dates __P((void)); extern void check_mail __P((void)); Index: flags.c =================================================================== RCS file: /cvsroot/winbash/winbash/flags.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- flags.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ flags.c 10 Mar 2002 23:25:31 -0000 1.2 @@ -113,11 +113,11 @@ /* Non-zero means don't look up or remember command names in a hash table, */ int hashing_disabled = 0; -#if defined (HISTORY) +#if defined (BANG_HISTORY) /* Non-zero means that we are doing history expansion. The default. This means !22 gets the 22nd line of history. */ int history_expansion = 1; -#endif /* HISTORY */ +#endif /* BANG_HISTORY */ /* Non-zero means that we allow comments to appear in interactive commands. */ #if defined (INTERACTIVE_COMMENTS) @@ -179,10 +179,10 @@ { 'P', &no_symbolic_links }, -#if defined (HISTORY) +#if defined (BANG_HISTORY) /* Once again, we don't have the right mnemonic. */ { 'H', &history_expansion }, -#endif /* HISTORY */ +#endif /* BANG_HISTORY */ {0, (int *)NULL} }; Index: flags.h =================================================================== RCS file: /cvsroot/winbash/winbash/flags.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- flags.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ flags.h 10 Mar 2002 23:25:31 -0000 1.2 @@ -47,9 +47,9 @@ hashing_disabled, forced_interactive, privileged_mode, asynchronous_notification, interactive_comments, no_symbolic_links; -#if defined (HISTORY) +#if defined (BANG_HISTORY) extern int history_expansion; -#endif /* HISTORY */ +#endif /* BANG_HISTORY */ #if defined (RESTRICTED_SHELL) extern int restricted; Index: general.c =================================================================== RCS file: /cvsroot/winbash/winbash/general.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- general.c 9 Mar 2002 16:05:41 -0000 1.2 +++ general.c 10 Mar 2002 23:25:31 -0000 1.3 @@ -661,7 +661,7 @@ if (result[i + 1] == '/') { strcpy (result + i, result + i + 1); - i = start; + i = (start < 0) ? 0 : start; continue; } @@ -679,7 +679,7 @@ #endif while (--start > -1 && result[start] != '/'); strcpy (result + start + 1, result + i + 2); - i = start; + i = (start < 0) ? 0 : start; continue; } } Index: general.h =================================================================== RCS file: /cvsroot/winbash/winbash/general.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- general.h 9 Mar 2002 16:05:41 -0000 1.2 +++ general.h 10 Mar 2002 23:25:31 -0000 1.3 @@ -23,6 +23,17 @@ #include "stdc.h" +/* just to make sure */ +#if defined (HAVE_UNISTD_H) +# ifdef CRAY +# define word __word +# endif +# include <unistd.h> +# ifdef CRAY +# undef word +# endif +#endif + #if !defined (NULL) # if defined (__STDC__) # define NULL ((void *) 0) Index: jobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/jobs.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- jobs.c 10 Mar 2002 21:45:13 -0000 1.3 +++ jobs.c 10 Mar 2002 23:25:31 -0000 1.4 @@ -1496,31 +1496,23 @@ } } - /* XXX - the linux people say to check for JOBSTATE (job) == JSTOPPED */ if (child->running || ((job != NO_JOB) && (JOBSTATE (job) == JRUNNING))) { -#if defined (_POSIX_VERSION) - struct sigaction act, oact; - - act.sa_handler = SIG_DFL; - sigemptyset (&act.sa_mask); - act.sa_flags = 0; - - sigaction (SIGCHLD, &act, &oact); -#else - SigHandler *ihandler; - - ihandler = set_signal_handler (SIGCHLD, SIG_DFL); -#endif /* !_POSIX_VERSION */ - - flush_child (0); - -#if defined (_POSIX_VERSION) - sigaction (SIGCHLD, &oact, (struct sigaction *)NULL); -#else - set_signal_handler (SIGCHLD, ihandler); -#endif /* !_POSIX_VERSION */ - +#if defined (WAITPID_BROKEN) /* SCOv4 */ + sigset_t suspend_set; + sigemptyset (&suspend_set); + sigsuspend (&suspend_set); +#else /* !WAITPID_BROKEN */ +# if defined (MUST_UNBLOCK_CHILD) /* SCO */ +UNBLOCK_CHILD (oset); +# endif + waiting_for_job = 1; + waitchld (0); + waiting_for_job = 0; +# if defined (MUST_UNBLOCK_CHILD) + BLOCK_CHILD (set, oset); +# endif +#endif /* !WAITPID_BROKEN */ goto wait_loop; } @@ -2043,7 +2035,6 @@ { WAIT status; PROCESS *child; - int any_tstped = 0; pid_t pid; int call_set_current = 0, last_stopped_job = NO_JOB; int children_exited = 0, flag; @@ -2052,7 +2043,7 @@ { flag = WUNTRACED; if (sigchld || s) - flag |= WNOHANG; + flag |= WNOHANG; pid = WAITPID (-1, &status, flag); if (sigchld && (flag & WNOHANG)) sigchld--; @@ -2177,7 +2168,7 @@ children_exited++; } } - while (sig && pid > (pid_t)0); + while ((s || sigchld) && pid > (pid_t)0); /* If a job was running and became stopped, then set the current job. Otherwise, don't change a thing. */ Index: machines.h =================================================================== RCS file: /cvsroot/winbash/winbash/machines.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- machines.h 9 Mar 2002 16:05:42 -0000 1.2 +++ machines.h 10 Mar 2002 23:25:31 -0000 1.3 @@ -280,6 +280,13 @@ # define MACHINE_CFLAGS -Wf,-XNl3072 # endif # endif /* Irix5 */ +# if defined (Irix6) +# define M_OS "Irix6" +# if !defined (HAVE_GCC) +# undef MACHINE_CFLAGS +# define MACHINE_CFLAGS -mips2 +# endif /* !HAVE_GCC */ +# endif /* Irix6 */ # define M_MACHINE "sgi" # define HAVE_GETGROUPS # define VOID_SIGHANDLER @@ -293,7 +300,7 @@ # else # define ANSIC # endif /* !__EXTENSIONS__ || __STDC__ */ -# if defined (Irix5) +# if defined (Irix5) || defined (Irix6) # define SGI_CFLAGS -DUSG -DPGRP_PIPE -DHAVE_BCOPY -DHAVE_GETPW_DECLS \ -DHAVE_SOCKETS -DNO_SBRK_DECL # else @@ -667,7 +674,7 @@ # define SYSDEP_LDFLAGS -Xp # define ISC_POSIX -Xp # endif -# define ISC_SYSDEPS -DUSGr3 -DPGRP_PIPE -DHAVE_GETPW_DECLS -D_POSIX_SOURCE -DOPENDIR_NOT_ROBUST -DMEMMOVE_MISSING +# define ISC_SYSDEPS -DUSGr3 -DPGRP_PIPE -DHAVE_GETPW_DECLS -D_POSIX_SOURCE -DOPENDIR_NOT_ROBUST -DMEMMOVE_MISSING -DWAITPID_BROKEN # if defined (__STDC__) # if defined (HAVE_GCC) # define ISC_EXTRA -DO_NDELAY=O_NONBLOCK @@ -725,9 +732,9 @@ # define M_OS "SCO" # define SCO_CFLAGS -DUSG -DUSGr3 -DPGRP_PIPE # if defined (SCOv4) -# define SYSDEP_CFLAGS SCO_CFLAGS +# define SYSDEP_CFLAGS SCO_CFLAGS -DWAITPID_BROKEN # else /* !SCOv4 */ -# define SYSDEP_CFLAGS SCO_CFLAGS -DOPENDIR_NOT_ROBUST +# define SYSDEP_CFLAGS SCO_CFLAGS -DOPENDIR_NOT_ROBUST -DMUST_UNBLOCK_CHILD # endif /* !SCOv4 */ # define HAVE_VFPRINTF # define VOID_SIGHANDLER @@ -758,12 +765,17 @@ # define REQUIRED_LIBRARIES -lbsd # endif /* OSF/1 */ -/* BSDI BSD/386 running on a 386 or 486. */ +/* BSDI BSD/OS running on a 386 or 486. */ # if !defined (done386) && defined (__bsdi__) # define done386 # define M_MACHINE "i386" -# define M_OS "BSD386" -# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# if defined (BSDI2) +# define M_OS "BSD_OS" +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DRLIMTYPE=quad_t +# else +# define M_OS "BSD386" +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# endif # define HAVE_SYS_SIGLIST # define HAVE_SETLINEBUF # define HAVE_GETGROUPS @@ -854,7 +866,7 @@ # define done386 # define M_MACHINE "i386" # define M_OS "Linux" -# define SYSDEP_CFLAGS -DUSG -DUSGr3 -DHAVE_GETDTABLESIZE -DHAVE_BCOPY \ +# define SYSDEP_CFLAGS -DHAVE_GETDTABLESIZE -DHAVE_BCOPY \ -DHAVE_GETPW_DECLS -DHAVE_GETHOSTNAME # define REQUIRED_LIBRARIES # define HAVE_GETGROUPS @@ -966,7 +978,7 @@ #if defined (m68k) && defined (sysV68) # define M_MACHINE "Delta" # define M_OS "USG" -# define SYSDEP_CFLAGS -DUSGr3 +# define SYSDEP_CFLAGS -DUSGr3 -DMEMMOVE_MISSING # define VOID_SIGHANDLER # define HAVE_VFPRINTF # define REQUIRED_LIBRARIES -lm881 @@ -1821,7 +1833,7 @@ # if defined (USGr4) # define SYSDEP_CFLAGS -DUSGr4 -D_POSIX_JOB_CONTROL # else -# define SYSDEP_CFLAGS -D_POSIX_JOB_CONTROL +# define SYSDEP_CFLAGS -D_POSIX_JOB_CONTROL -DWAITPID_BROKEN # endif # define HAVE_DIRENT # define HAVE_VFPRINTF @@ -2042,6 +2054,56 @@ # endif /* !HAVE_GCC */ # undef HAVE_GETWD #endif /* Tandem running SVR3 */ + +/* ****************** */ +/* */ +/* Amdahl UTS */ +/* */ +/* ****************** */ + +#if defined (UTS) +# define M_MACHINE "uts" +# define M_OS "systemV" +# define SYSDEP_CFLAGS -DUSG -DMEMMOVE_MISSING +# define REQUIRED_LIBRARIES +# undef HAVE_SYS_SIGLIST +# undef HAVE_GETWD +# undef HAVE_ALLOCA +# define HAVE_VFPRINTF +# define HAVE_DIRENT +# undef HAVE_RESOURCE +#endif /* UTS */ + +/* ************************ */ +/* */ +/* Stratus i860 running FTX (jon...@sy... (Jonathan Stockley)) */ +/* */ +/* ************************ */ +/* Use 'make CPP_DEFINES=-D_FTX' to build as /usr/ccs/lib/cpp doesn't set + anything other than i860 which may be set on other i860 machines. + The C compiler, cc, sets _FTX & i860 but, unfortunately it barfs at stuff + in cpp-Makefile that has a # in it (it has it's own builtin cpp). +*/ +#if defined(_FTX) && defined (i860) && !defined (M_MACHINE) +#define M_MACHINE "Stratus_i860" +#define M_OS "FTX" +#define VOID_SIGHANDLER +#define HAVE_POSIX_SIGNALS +#define HAVE_VFPRINTF +#define HAVE_SETVBUF +#define REVERSED_SETVBUF_ARGS +#define HAVE_STRCHR +#define HAVE_STRERROR +#define HAVE_GETGROUPS +#define HAVE_DUP2 +#undef HAVE_ALLOCA +#undef HAVE_GETWD +#define HAVE_GETCWD +#define HAVE_SYS_SIGLIST +#define SYSDEP_CFLAGS -DHAVE_UID_T -Dsys_siglist=_sys_siglist -DUSGr4 +#define EXTRA_LIB_SEARCH_PATH /usr/ucblib +#define REQUIRED_LIBRARIES -lc -lucb +#endif /* _FTX */ /* ************************ */ /* */ Index: mailcheck.c =================================================================== RCS file: /cvsroot/winbash/winbash/mailcheck.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mailcheck.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ mailcheck.c 10 Mar 2002 23:25:31 -0000 1.2 @@ -229,13 +229,16 @@ return ((stat (file, &finfo) == 0) && (finfo.st_size > size)); } -#if defined (USG) -# define DEFAULT_MAIL_PATH "/usr/mail/" -# define DEFAULT_PATH_LEN 10 -#else -# define DEFAULT_MAIL_PATH "/usr/spool/mail/" -# define DEFAULT_PATH_LEN 16 -#endif +char * +make_default_mailpath () +{ + char *mp; + + mp = xmalloc (1 + sizeof (DEFAULT_MAIL_PATH) + strlen (current_user.user_name)); + strcpy (mp, DEFAULT_MAIL_PATH); + strcpy (mp + sizeof (DEFAULT_MAIL_PATH) - 1, current_user.user_name); + return (mp); +} /* Return the colon separated list of pathnames to check for mail. */ static char * @@ -251,10 +254,7 @@ if (mailpaths) return (savestring (mailpaths)); - mailpaths = xmalloc (1 + DEFAULT_PATH_LEN + strlen (current_user.user_name)); - strcpy (mailpaths, DEFAULT_MAIL_PATH); - strcpy (mailpaths + DEFAULT_PATH_LEN, current_user.user_name); - return (mailpaths); + return (make_default_mailpath ()); } /* Take an element from $MAILPATH and return the portion from @@ -291,10 +291,11 @@ void remember_mail_dates () { - char *mailpaths = get_mailpaths (); + char *mailpaths; char *mailfile, *mp; int i = 0; - + + mailpaths = get_mailpaths (); while (mailfile = extract_colon_unit (mailpaths, &i)) { mp = parse_mailpath_spec (mailfile); Index: nojobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/nojobs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- nojobs.c 10 Mar 2002 21:45:13 -0000 1.2 +++ nojobs.c 10 Mar 2002 23:25:31 -0000 1.3 @@ -37,6 +37,7 @@ #include "jobs.h" #include "execute_cmd.h" #include "externs.h" +#include "error.h" #if defined (__NT_VC__) # include <process.h> Index: parse.y =================================================================== RCS file: /cvsroot/winbash/winbash/parse.y,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parse.y 10 Mar 2002 21:45:13 -0000 1.3 +++ parse.y 10 Mar 2002 23:25:31 -0000 1.4 @@ -1610,6 +1610,9 @@ bind_variable ("_", last_lastarg); FREE (last_lastarg); + + if (token_to_read == '\n') + token_to_read = 0; } /* Command to read_token () explaining what we want it to do. */ @@ -2469,14 +2472,19 @@ static void reset_readline_prompt () { - if (prompt_string_pointer && *prompt_string_pointer) + if (prompt_string_pointer) { char *temp_prompt; - temp_prompt = decode_prompt_string (*prompt_string_pointer); + temp_prompt = *prompt_string_pointer + ? decode_prompt_string (*prompt_string_pointer) + : (char *)NULL; - if (!temp_prompt) - temp_prompt = savestring (""); + if (temp_prompt == 0) + { + temp_prompt = xmalloc (1); + temp_prompt[0] = '\0'; + } FREE (current_readline_prompt); @@ -2533,10 +2541,15 @@ if (!prompt_string_pointer) prompt_string_pointer = &ps1_prompt; - if (*prompt_string_pointer) - temp_prompt = decode_prompt_string (*prompt_string_pointer); - else - temp_prompt = savestring (""); + temp_prompt = (*prompt_string_pointer) + ? decode_prompt_string (*prompt_string_pointer) + : (char *)NULL; + + if (temp_prompt == 0) + { + temp_prompt = xmalloc (1); + temp_prompt[0] = '\0'; + } current_prompt_string = *prompt_string_pointer; prompt_string_pointer = &ps2_prompt; @@ -2762,6 +2775,7 @@ temp = savestring (geteuid () == 0 ? "#" : "$"); goto add_string; +#if defined (READLINE) case '[': case ']': temp = xmalloc(3); @@ -2769,6 +2783,7 @@ temp[1] = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE; temp[2] = '\0'; goto add_string; +#endif case '\\': temp = savestring ("\\"); Index: print_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/print_cmd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- print_cmd.c 10 Mar 2002 21:45:13 -0000 1.2 +++ print_cmd.c 10 Mar 2002 23:25:31 -0000 1.3 @@ -664,7 +664,7 @@ char char_arg[2], *argp, *args[2]; int arg_len, c, arg_index; - args[0] = arg1; + args[arg_index = 0] = arg1; args[1] = arg2; arg_len = strlen (format); Index: shell.c =================================================================== RCS file: /cvsroot/winbash/winbash/shell.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- shell.c 10 Mar 2002 21:45:13 -0000 1.4 +++ shell.c 10 Mar 2002 23:25:31 -0000 1.5 @@ -95,7 +95,7 @@ /* The current maintainer of the shell. You change this in the Makefile. */ #if !defined (MAINTAINER) -#define MAINTAINER "deliberately-anonymous" +#define MAINTAINER "bas...@pr..." #endif char *the_current_maintainer = MAINTAINER; @@ -511,7 +511,10 @@ else { #if defined (HISTORY) - history_expansion = remember_on_history = 0; +# if defined (BANG_HISTORY) + history_expansion = 0; +# endif + remember_on_history = 0; #endif /* HISTORY */ interactive_shell = startup_state = interactive = 0; no_line_editing = 1; @@ -740,7 +743,9 @@ if (!interactive_shell || (!isatty (fd))) { #if defined (HISTORY) +# if defined (BANG_HISTORY) history_expansion = 0; +# endif remember_on_history = 0; #endif /* HISTORY */ interactive = interactive_shell = 0; @@ -821,7 +826,7 @@ #endif /* PROCESS_SUBSTITUTION */ #if defined (HISTORY) - if (interactive && remember_on_history) + if (interactive_shell) maybe_save_shell_history (); #endif /* HISTORY */ @@ -1078,8 +1083,9 @@ { /* Some kind of throw to top_level has occured. */ case FORCE_EOF: - case EXITPROG: return last_command_exit_value = 127; + case EXITPROG: + return last_command_exit_value; case DISCARD: return last_command_exit_value = 1; default: @@ -1192,17 +1198,20 @@ indirection_level_string () { register int i, j; - char *ps4 = get_string_value ("PS4"); + char *ps4; - if (!ps4) - ps4 = savestring ("+ "); - else - ps4 = decode_prompt_string (ps4); + indirection_string[0] = '\0'; + ps4 = get_string_value ("PS4"); - for (i = 0; i < indirection_level && i < 99; i++) + if (ps4 == 0 || *ps4 == '\0') + return (indirection_string); + + ps4 = decode_prompt_string (ps4); + + for (i = 0; *ps4 && i < indirection_level && i < 99; i++) indirection_string[i] = *ps4; - for (j = 1; ps4[j] && i < 99; i++, j++) + for (j = 1; *ps4 && ps4[j] && i < 99; i++, j++) indirection_string[i] = ps4[j]; indirection_string[i] = '\0'; @@ -1405,7 +1414,10 @@ debugging = do_version = line_number = last_command_exit_value = 0; forced_interactive = interactive_shell = subshell_environment = 0; #if defined (HISTORY) - remember_on_history = history_expansion = 0; +# if defined (BANG_HISTORY) + history_expansion = 0; +# endif + remember_on_history = 0; #endif /* HISTORY */ #if defined (RESTRICTED_SHELL) @@ -1558,7 +1570,7 @@ run_interrupt_trap (); #if defined (HISTORY) - if (interactive && remember_on_history) + if (interactive_shell) maybe_save_shell_history (); #endif /* HISTORY */ @@ -1573,7 +1585,7 @@ #endif /* PROCESS_SUBSTITUTION */ run_exit_trap (); - signal (sig, SIG_DFL); + set_signal_handler (sig, SIG_DFL); kill (getpid (), sig); #if !defined (VOID_SIGHANDLER) @@ -1619,12 +1631,12 @@ for (i = 0; i < TERMSIGS_LENGTH; i++) { terminating_signals[i].orig_handler = - signal (XSIG (i), termination_unwind_protect); + set_signal_handler (XSIG (i), termination_unwind_protect); /* Don't do anything with signals that are ignored at shell entry if the shell is not interactive. */ if (!interactive_shell && terminating_signals[i].orig_handler == SIG_IGN) { - signal (XSIG (i), SIG_IGN); + set_signal_handler (XSIG (i), SIG_IGN); set_signal_ignored (XSIG (i)); } } @@ -1641,12 +1653,12 @@ #if defined (SIGQUIT) /* And, some signals that are specifically ignored by the shell. */ - signal (SIGQUIT, SIG_IGN); + set_signal_handler (SIGQUIT, SIG_IGN); if (interactive) { set_signal_handler (SIGINT, sigint_sighandler); - signal (SIGTERM, SIG_IGN); + set_signal_handler (SIGTERM, SIG_IGN); } #endif /* SIGQUIT */ } @@ -1677,7 +1689,7 @@ if (signal_is_trapped (XSIG (i)) || signal_is_special (XSIG (i))) continue; - signal (XSIG (i), XHANDLER (i)); + set_signal_handler (XSIG (i), XHANDLER (i)); } #endif } Index: siglist.h =================================================================== RCS file: /cvsroot/winbash/winbash/siglist.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- siglist.h 9 Mar 2002 16:05:42 -0000 1.2 +++ siglist.h 10 Mar 2002 23:25:31 -0000 1.3 @@ -28,10 +28,10 @@ #endif /* Solaris || USGr4_2 || drs6000 || amiga || Minix */ #if !defined (Solaris) && !defined (Linux) && !defined (__BSD_4_4__) && \ - !defined (Minix) && !defined (NetBSD) && !defined (FreeBSD) && \ - !defined (__linux__) + !defined (Minix) && !defined (NetBSD) && !defined (FreeBSD) && \ + !defined (BSD_OS) extern char *sys_siglist[]; -#endif /* !Solaris && !Linux && !__BSD_4_4__ && !Minix && !NetBSD && !FreeBSD */ +#endif /* !Solaris && !Linux && !__BSD_4_4__ && !Minix && !NetBSD && !FreeBSD && !BSD_OS */ #if !defined (strsignal) && !defined (Solaris) && !defined (NetBSD) # define strsignal(sig) (char *)sys_siglist[sig] Index: stdc.h =================================================================== RCS file: /cvsroot/winbash/winbash/stdc.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- stdc.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ stdc.h 10 Mar 2002 23:25:31 -0000 1.2 @@ -45,19 +45,33 @@ # endif # define __STRING(x) "x" -#if !defined (const) -# if defined (__GNUC__) /* gcc with -traditional */ +#if defined (__GNUC__) /* gcc with -traditional */ +# if !defined (const) # define const __const +# endif +# if !defined (inline) # define inline __inline +# endif +# if !defined (signed) # define signed __signed +# endif +# if !defined (volatile) # define volatile __volatile -# else /* !__GNUC__ */ +# endif +#else /* !__GNUC__ */ +# if !defined (const) # define const +# endif +# if !defined (inline) # define inline +# endif +# if !defined (signed) # define signed +# endif +# if !defined (volatile) # define volatile -# endif /* !__GNUC__ */ -#endif /* !const */ +# endif +#endif /* !__GNUC__ */ #endif /* !__STDC__ */ Index: subst.c =================================================================== RCS file: /cvsroot/winbash/winbash/subst.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- subst.c 10 Mar 2002 21:45:13 -0000 1.3 +++ subst.c 10 Mar 2002 23:25:31 -0000 1.4 @@ -2438,7 +2438,7 @@ SHELL_VAR *var = find_variable (name); if (var && !invisible_p (var) && (temp = value_cell (var))) - temp = quote_escapes (temp); + temp = quote_escapes (temp); } return (temp); } @@ -2453,6 +2453,7 @@ { WORD_LIST *l; char *t, *t1, *temp; + int i; if (value[0] == '~' || (strchr (value, '~') && unquoted_substring ("=~", value))) @@ -2460,7 +2461,15 @@ else temp = savestring (value); - l = *temp ? expand_string_internal (temp, 0) : (WORD_LIST *)NULL; + /* This is a hack. A better fix is coming later. */ + if (*temp == '"') + { + i = 1; + t = string_extract_double_quoted (temp, &i); /* XXX */ + free (temp); + temp = t; + } + l = *temp ? expand_string_internal (temp, quoted) : (WORD_LIST *)NULL; free (temp); if (l) @@ -2690,6 +2699,7 @@ int old_index; if (string[++sindex] != '(' || quoted || posixly_correct) + temp = (char *)NULL; { sindex--; goto add_character; @@ -2742,10 +2752,17 @@ case '7': case '8': case '9': - if (dollar_vars[digit_value (c)]) - temp = savestring (dollar_vars[digit_value (c)]); - else - temp = (char *) NULL; + temp = dollar_vars[digit_value (c)]; + if (unbound_vars_is_error && temp == (char *)NULL) + { + report_error ("$%c: unbound variable", c); + free (string); + free (istring); + last_command_exit_value = 1; + return (&expand_word_error); + } + if (temp) + temp = savestring (temp); goto dollar_add_string; /* $$ -- pid of the invoking shell. */ @@ -3577,72 +3594,51 @@ int quoted; { char *r, *result_string, *temp, *temp1; - int sindex, tindex, c; + int sindex, tindex, c, dquote; /* The result can be no longer than the original string. */ r = result_string = xmalloc (strlen (string) + 1); - sindex = 0; - for (;;) + for (sindex = dquote = 0; c = string[sindex];) { - c = string[sindex]; - if (c == '\0') - break; - switch (c) - { - case '\\': - c = string[++sindex]; - if (quoted && !member (c, slashify_in_quotes)) - { - *r++ = '\\'; - *r++ = c; - } - else - *r++ = c; - - sindex++; - break; - - case '"': - tindex = ++sindex; - temp = string_extract_double_quoted (string, &tindex); - sindex = tindex; - - if (temp) - { - strcpy (r, temp); - r += strlen (r); - free (temp); - } - break; - - case '\'': - if (quoted) + { + case '\\': + c = string[++sindex]; + if ((quoted || dquote) && !member (c, slashify_in_quotes)) + *r++ = '\\'; + + default: + *r++ = c; + sindex++; + break; + + case '\'': + if (quoted || dquote) { *r++ = c; sindex++; } - else - { - tindex = ++sindex; - temp = string_extract_single_quoted (string, &tindex); - sindex = tindex; - - if (temp) - { - strcpy (r, temp); - r += strlen (r); - free (temp); - } - } - break; - - default: - *r++ = c; - sindex++; - break; - } + else + { + tindex = ++sindex; + temp = string_extract_single_quoted (string, &tindex); + sindex = tindex; + + if (temp) + { + strcpy (r, temp); + r += strlen (r); + free (temp); + } + } + break; + + case '"': + dquote = 1 - dquote; + sindex++; + break; + } } *r = '\0'; return (result_string); @@ -4426,8 +4422,11 @@ #endif #if defined (HISTORY) -void sv_histsize (), sv_histfilesize (), sv_histchars (), sv_history_control (), - sv_command_oriented_history (); +void sv_histsize (), sv_histfilesize (), + sv_history_control (), sv_command_oriented_history (); +# if defined (BANG_HISTORY) +void sv_histchars (); +# endif #endif /* HISTORY */ #if defined (GETOPTS_BUILTIN) @@ -4440,144 +4439,57 @@ #define SET_INT_VAR(name, intvar) intvar = find_variable (name) != 0 -struct name_and_function - { - char *name; - VFunction *function; - } -special_vars[] = -{ - { - "PATH", sv_path - } - , - { - "MAIL", sv_mail - } - , - { - "MAILPATH", sv_mail - } - , - { - "MAILCHECK", sv_mail - } - , +struct name_and_function { + char *name; + VFunction *function; +} special_vars[] = { + { "PATH", sv_path }, + { "MAIL", sv_mail }, + { "MAILPATH", sv_mail }, + { "MAILCHECK", sv_mail }, - { - "POSIXLY_CORRECT", sv_strict_posix - } - , - { - "POSIX_PEDANTIC", sv_strict_posix - } - , + { "POSIXLY_CORRECT", sv_strict_posix }, + { "POSIX_PEDANTIC", sv_strict_posix }, /* Variables which only do something special when READLINE is defined. */ #if defined (READLINE) - { - "TERM", sv_terminal - } - , - { - "TERMCAP", sv_terminal - } - , - { - "TERMINFO", sv_terminal - } - , - { - "hostname_completion_file", sv_hostname_completion_file - } - , - { - "HOSTFILE", sv_hostname_completion_file - } - , + { "TERM", sv_terminal }, + { "TERMCAP", sv_terminal }, + { "TERMINFO", sv_terminal }, + { "hostname_completion_file", sv_hostname_completion_file }, + { "HOSTFILE", sv_hostname_completion_file }, #endif /* READLINE */ /* Variables which only do something special when HISTORY is defined. */ #if defined (HISTORY) - { - "HISTSIZE", sv_histsize - } - , - { - "HISTFILESIZE", sv_histfilesize - } - , - { - "command_oriented_history", sv_command_oriented_history - } - , - { - "histchars", sv_histchars - } - , - { - "history_control", sv_history_control - } - , - { - "HISTCONTROL", sv_history_control - } - , + { "HISTSIZE", sv_histsize }, + { "HISTFILESIZE", sv_histfilesize }, + { "command_oriented_history", sv_command_oriented_history }, +# if defined (BANG_HISTORY) + { "histchars", sv_histchars }, +# endif + { "history_control", sv_history_control }, + { "HISTCONTROL", sv_history_control }, #endif /* HISTORY */ - { - "EUID", sv_uids - } - , - { - "UID", sv_uids - } - , - { - "IGNOREEOF", sv_ignoreeof - } - , - { - "ignoreeof", sv_ignoreeof - } - , + { "EUID", sv_uids}, + { "UID", sv_uids}, + { "IGNOREEOF", sv_ignoreeof }, + { "ignoreeof", sv_ignoreeof }, #if defined (GETOPTS_BUILTIN) - { - "OPTIND", sv_optind - } - , - { - "OPTERR", sv_opterr - } - , + { "OPTIND", sv_optind }, + { "OPTERR", sv_opterr }, #endif /* GETOPTS_BUILTIN */ #if defined (JOB_CONTROL) - { - "notify", sv_notify - } - , -#endif /* JOB_CONTROL */ + { "notify", sv_notify }, +#endif /* JOB_CONTROL */ - { - "glob_dot_filenames", sv_glob_dot_filenames - } - , - { - "allow_null_glob_expansion", sv_allow_null_glob_expansion - } - , - { - "noclobber", sv_noclobber - } - , - { - "nolinks", sv_nolinks - } - , - { - (char *) 0x00, (VFunction *) 0x00 - } + { "glob_dot_filenames", sv_glob_dot_filenames }, + { "allow_null_glob_expansion", sv_allow_null_glob_expansion }, + { "noclobber", sv_noclobber }, + { "nolinks", sv_nolinks }, + { (char *)0x00, (VFunction *)0x00 } }; /* The variable in NAME has just had its state changed. Check to see if it @@ -4732,6 +4644,7 @@ SET_INT_VAR (name, command_oriented_history); } +# if defined (BANG_HISTORY) /* Setting/unsetting of the history expansion character. */ void @@ -4757,6 +4670,7 @@ history_comment_char = '#'; } } +# endif /* BANG_HISTORY */ #endif /* HISTORY */ void Index: trap.c =================================================================== RCS file: /cvsroot/winbash/winbash/trap.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- trap.c 10 Mar 2002 21:45:13 -0000 1.3 +++ trap.c 10 Mar 2002 23:25:31 -0000 1.4 @@ -89,8 +89,8 @@ /* Show which signals are treated specially by the shell. */ #if defined (SIGCHLD) - original_signals[SIGCHLD] = (SigHandler *) signal (SIGCHLD, SIG_DFL); - signal (SIGCHLD, original_signals[SIGCHLD]); + original_signals[SIGCHLD] = (SigHandler *) set_signal_handler (SIGCHLD, SIG_DFL); + set_signal_handler (SIGCHLD, original_signals[SIGCHLD]); sigmodes[SIGCHLD] |= (SIG_SPECIAL | SIG_NO_TRAP); #endif /* SIGCHLD */ @@ -112,8 +112,8 @@ if (interactive) { - original_signals[SIGTERM] = (SigHandler *)signal (SIGTERM, SIG_DFL); - signal (SIGTERM, original_signals[SIGTERM]); + original_signals[SIGTERM] = (SigHandler *)set_signal_handler (SIGTERM, SIG_DFL); + set_signal_handler (SIGTERM, original_signals[SIGTERM]); sigmodes[SIGTERM] |= SIG_SPECIAL; } } @@ -232,7 +232,7 @@ else { #if defined (USG) && !defined (HAVE_BSD_SIGNALS) && !defined (_POSIX_VERSION) - signal (sig, trap_handler); + set_signal_handler (sig, trap_handler); #endif /* USG && !HAVE_BSD_SIGNALS && !_POSIX_VERSION */ catch_flag = 1; @@ -323,7 +323,7 @@ /* If we aren't sure of the original value, check it. */ if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER) { - original_signals[sig] = (SigHandler *)signal (sig, SIG_DFL); + original_signals[sig] = (SigHandler *)set_signal_handler (sig, SIG_DFL); set_signal_handler (sig, original_signals[sig]); } @@ -392,7 +392,7 @@ { original_signals[sig] = (SigHandler *) set_signal_handler (sig, SIG_DFL); - signal (sig, original_signals[sig]); + set_signal_handler (sig, original_signals[sig]); /* Signals ignored on entry to the shell cannot be trapped. */ if (original_signals[sig] == SIG_IGN) @@ -457,7 +457,7 @@ /* Only change the signal handler for SIG if it allows it. */ if (!(sigmodes[sig] & SIG_NO_TRAP)) - signal (sig, SIG_IGN); + set_signal_handler (sig, SIG_IGN); /* Change the trap command in either case. */ change_signal (sig, (char *)IGNORE_SIG); @@ -511,11 +511,7 @@ for (i = 0; i < NSIG; i++) { - if ((sigmodes[i] & SIG_TRAPPED) && trap_list[i] && - (trap_list[i] != (char *)IGNORE_SIG) && - (trap_list[i] != (char *)DEFAULT_SIG) && - (trap_list[i] != (char *)IMPOSSIBLE_TRAP_HANDLER)) - free (trap_list[i]); + free_trap_command (i); trap_list[i] = (char *)DEFAULT_SIG; sigmodes[i] &= ~SIG_TRAPPED; } @@ -526,7 +522,7 @@ reset_signal (sig) int sig; { - signal (sig, original_signals[sig]); + set_signal_handler (sig, original_signals[sig]); } /* Reset the handlers for all trapped signals to the values they had when @@ -536,6 +532,13 @@ { register int i; + if (sigmodes[0] & SIG_TRAPPED) + { + free_trap_command (0); + trap_list[0] = (char *)NULL; + sigmodes[0] &= ~SIG_TRAPPED; + } + for (i = 1; i < NSIG; i++) { if (sigmodes[i] & SIG_SPECIAL) @@ -543,7 +546,7 @@ else if (sigmodes[i] & SIG_TRAPPED) { if (trap_list[i] == (char *)IGNORE_SIG) - signal (i, SIG_IGN); + set_signal_handler (i, SIG_IGN); else reset_signal (i); } @@ -559,6 +562,14 @@ register int i; reset_terminating_signals (); /* in shell.c */ + + if (sigmodes[0] & SIG_TRAPPED) + { + free_trap_command (0); + trap_list[0] = (char *)NULL; + sigmodes[0] &= ~SIG_TRAPPED; + } + for (i = 1; i < NSIG; i++) { if (sigmodes[i] & SIG_SPECIAL) @@ -566,7 +577,7 @@ else if (sigmodes[i] & SIG_TRAPPED) { if (trap_list[i] == (char *)IGNORE_SIG) - signal (i, SIG_IGN); + set_signal_handler (i, SIG_IGN); else restore_signal (i); } Index: variables.c =================================================================== RCS file: /cvsroot/winbash/winbash/variables.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- variables.c 10 Mar 2002 21:45:13 -0000 1.3 +++ variables.c 10 Mar 2002 23:25:31 -0000 1.4 @@ -92,12 +92,6 @@ /* The list of variables that may not be unset in this shell. */ char **non_unsettable_vars = (char **)NULL; -#if defined (USG) -#define DEFAULT_MAIL_PATH "/usr/mail/" -#else -#define DEFAULT_MAIL_PATH "/usr/spool/mail/" -#endif - static char *have_local_variables; /* XXX */ static int local_variable_stack_size = 0; /* XXX */ @@ -289,6 +283,7 @@ set_if_not ("PS1", primary_prompt); set_if_not ("PS2", secondary_prompt); } + set_if_not ("PS4", "+ "); #if defined (INSECURITY) set_if_not ("IFS", " \t\n"); @@ -304,25 +299,9 @@ set_auto_export (temp_var); #endif - /* Default MAILPATH, and MAILCHECK for interactive shells. */ + /* Default MAILCHECK for interactive shells. */ if (interactive_shell) - { - set_if_not ("MAILCHECK", "60"); - - if ((get_string_value ("MAIL") == (char *)NULL) && - (get_string_value ("MAILPATH") == (char *)NULL)) - { - char *tem; - - tem = xmalloc (1 + sizeof (DEFAULT_MAIL_PATH) - + strlen (current_user.user_name)); - strcpy (tem, DEFAULT_MAIL_PATH); - strcat (tem, current_user.user_name); - - bind_variable ("MAILPATH", tem); - free (tem); - } - } + set_if_not ("MAILCHECK", "60"); /* Do some things with shell level. */ temp_var = set_if_not ("SHLVL", "0"); @@ -408,7 +387,6 @@ /* Make a variable called BASH, which is the name of THIS shell. */ temp_var = bind_variable ("BASH", name); - temp_var->attributes |= att_exported; free (name); } Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- version.h 10 Mar 2002 20:33:03 -0000 1.4 +++ version.h 10 Mar 2002 23:25:31 -0000 1.5 @@ -5,12 +5,12 @@ #define DISTVERSION "1.14" /* The patch level of this version of the shell. */ -#define PATCHLEVEL 3 +#define PATCHLEVEL 4 /* The last built version of this shell. */ -#define BUILDVERSION 2 +#define BUILDVERSION 3 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.3(2) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.4(3) GNU" |
From: kevin s. <xk...@us...> - 2002-03-10 21:45:17
|
Update of /cvsroot/winbash/winbash/builtins In directory usw-pr-cvs1:/tmp/cvs-serv3155/builtins Modified Files: alias.def bind.def command.def common.c declare.def exec.def exit.def getopts.def return.def set.def source.def trap.def Log Message: renamed (almost) all members of the thread_env struct and added some #define's for accessing these member from thr_me. the goal is to reduce the number of places thr_me is referenced and hence the number of diffs with the bash mainline. the hope it that this will make patching to 1.14.7 easier. Index: alias.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/alias.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- alias.def 9 Mar 2002 04:20:36 -0000 1.2 +++ alias.def 10 Mar 2002 21:45:13 -0000 1.3 @@ -90,7 +90,7 @@ print_alias (t); else { - if (thr_me->interactive) + if (interactive) builtin_error ("`%s' not found", name); any_failed++; } @@ -150,7 +150,7 @@ remove_alias (alias->name); else { - if (thr_me->interactive) + if (interactive) builtin_error ("`%s' not an alias", list->word->word); any_failed++; Index: bind.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/bind.def,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bind.def 10 Mar 2002 15:54:11 -0000 1.4 +++ bind.def 10 Mar 2002 21:45:14 -0000 1.5 @@ -59,7 +59,7 @@ static int query_bindings (); extern int bash_readline_initialized; -extern int no_line_editing; +/*extern int no_line_editing;*/ #define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0) Index: command.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/command.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- command.def 9 Mar 2002 04:20:36 -0000 1.2 +++ command.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -127,7 +127,7 @@ command->value.Simple->flags |= (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION); /* If we're in a subshell, see if we can get away without forking again, since we've already forked to run this builtin. */ - if (thr_me->subshell_environment) + if (subshell_environment) { command->flags |= CMD_NO_FORK; command->value.Simple->flags |= CMD_NO_FORK; Index: common.c =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/common.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- common.c 9 Mar 2002 16:05:42 -0000 1.3 +++ common.c 10 Mar 2002 21:45:14 -0000 1.4 @@ -326,7 +326,7 @@ push_context () { push_dollar_vars (); - thr_me->variable_context++; + variable_context++; } void @@ -334,7 +334,7 @@ { pop_dollar_vars (); kill_all_local_variables (); - thr_me->variable_context--; + variable_context--; } /* Save the existing positional parameters on a stack. */ @@ -557,15 +557,15 @@ unwind_protect_int (parse_and_execute_level); unwind_protect_jmp_buf (top_level); unwind_protect_int (indirection_level); - if (interact != -1 && thr_me->interactive != interact) - unwind_protect_int (thr_me->interactive); + if (interact != -1 && interactive != interact) + unwind_protect_int (interactive); #if defined (HISTORY) - if (thr_me->interactive_shell) + if (interactive_shell) { - unwind_protect_int (thr_me->remember_on_history); + unwind_protect_int (remember_on_history); # if defined (BANG_HISTORY) - unwind_protect_int (thr_me->history_expansion_inhibited); + unwind_protect_int (history_expansion_inhibited); # endif /* BANG_HISTORY */ } #endif /* HISTORY */ @@ -579,14 +579,14 @@ push_stream (); indirection_level++; if (interact != -1) - thr_me->interactive = interact; - + interactive = interact; + #if defined (HISTORY) /* We don't remember text read by the shell this way on the history list, and we don't use !$ in shell scripts. */ - thr_me->remember_on_history = 0; + remember_on_history = 0; # if defined (BANG_HISTORY) - thr_me->history_expansion_inhibited = 1; + history_expansion_inhibited = 1; # endif /* BANG_HISTORY */ #endif /* HISTORY */ @@ -623,7 +623,7 @@ case DISCARD: dispose_command (command); run_unwind_frame ("pe_dispose"); - thr_me->last_command_exit_value = 1; + last_command_exit_value = 1; continue; default: @@ -682,7 +682,7 @@ /* An interrupt during non-interactive execution in an interactive shell (e.g. via $PROMPT_COMMAND) should not cause the shell to exit. */ - thr_me->interactive = thr_me->interactive_shell; + interactive = interactive_shell; throw_to_top_level (); } Index: declare.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/declare.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- declare.def 9 Mar 2002 04:20:36 -0000 1.2 +++ declare.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -81,7 +81,7 @@ local_builtin (list) register WORD_LIST *list; { - if (thr_me->variable_context) + if (variable_context) return (declare_internal (list, 1)); else { @@ -151,7 +151,7 @@ register SHELL_VAR **vlist; register int i; - vlist = map_over (variable_in_context, thr_me->shell_variables); + vlist = map_over (variable_in_context, shell_variables); if (vlist) { @@ -200,7 +200,7 @@ inside of a function. This means we should make local variables, not global ones. */ - if (thr_me->variable_context) + if (variable_context) make_local_variable (name); /* If we are declaring a function, then complain about it in some way. Index: exec.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/exec.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exec.def 9 Mar 2002 16:05:42 -0000 1.3 +++ exec.def 10 Mar 2002 21:45:14 -0000 1.4 @@ -128,14 +128,14 @@ restore_original_signals (); #if defined (JOB_CONTROL) - if (thr_me->subshell_environment == 0) + if (subshell_environment == 0) end_job_control (); #endif /* JOB_CONTROL */ #if defined (__NT_VC__) - nt_shell_execve (command, args, thr_me->export_env); + nt_shell_execve (command, args, export_env); #else /* !__NT_VC__ */ - shell_execve (command, args, thr_me->export_env); + shell_execve (command, args, export_env); #endif /* !__NT_VC__ */ adjust_shell_level (1); @@ -152,8 +152,8 @@ if (command) free (command); - if (thr_me->subshell_environment || - (!thr_me->interactive && !find_variable ("no_exit_on_failed_exec"))) + if (subshell_environment || + (!interactive && !find_variable ("no_exit_on_failed_exec"))) exit (exit_value); initialize_traps (); Index: exit.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/exit.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exit.def 9 Mar 2002 16:05:42 -0000 1.3 +++ exit.def 10 Mar 2002 21:45:14 -0000 1.4 @@ -43,9 +43,9 @@ exit_builtin (list) WORD_LIST *list; { - if (thr_me->interactive) + if (interactive) { - fprintf (stderr, thr_me->login_shell ? "logout\n" : "exit\n"); + fprintf (stderr, login_shell ? "logout\n" : "exit\n"); fflush (stderr); } @@ -63,7 +63,7 @@ logout_builtin (list) WORD_LIST *list; { - if (!thr_me->login_shell && thr_me->interactive) + if (!login_shell && interactive) { builtin_error ("Not login shell: use `exit'"); return (EXECUTION_FAILURE); @@ -85,7 +85,7 @@ #if defined (JOB_CONTROL) int exit_immediate_okay; - exit_immediate_okay = (!thr_me->interactive || + exit_immediate_okay = (!interactive || last_shell_builtin == exit_builtin || last_shell_builtin == logout_builtin || last_shell_builtin == jobs_builtin); @@ -114,13 +114,13 @@ if (list) exit_value = get_numeric_arg (list); else - exit_value = thr_me->last_command_exit_value; + exit_value = last_command_exit_value; /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ - if (thr_me->login_shell && sourced_logout++ == 0) + if (login_shell && sourced_logout++ == 0) maybe_execute_file ("~/.bash_logout", 1); - thr_me->last_command_exit_value = exit_value; + last_command_exit_value = exit_value; /* Exit the program. */ longjmp (top_level, EXITPROG); Index: getopts.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/getopts.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- getopts.def 9 Mar 2002 04:20:36 -0000 1.2 +++ getopts.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -241,7 +241,7 @@ bind_variable ("OPTARG", strval); } else - makunbound ("OPTARG", thr_me->shell_variables); + makunbound ("OPTARG", shell_variables); return (EXECUTION_SUCCESS); } @@ -263,7 +263,7 @@ strval[0] = '?'; strval[1] = '\0'; bind_variable (name, strval); - makunbound ("OPTARG", thr_me->shell_variables); + makunbound ("OPTARG", shell_variables); } return (EXECUTION_SUCCESS); } Index: return.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/return.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- return.def 9 Mar 2002 04:20:36 -0000 1.2 +++ return.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -45,7 +45,7 @@ return_catch_value = get_numeric_arg (list); if (!list) - return_catch_value = thr_me->last_command_exit_value; + return_catch_value = last_command_exit_value; if (return_catch_flag) longjmp (return_catch, 1); Index: set.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/set.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- set.def 9 Mar 2002 04:20:36 -0000 1.2 +++ set.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -30,7 +30,8 @@ extern int noclobber, no_brace_expansion, posixly_correct; #if defined (READLINE) -extern int rl_editing_mode, no_line_editing; +extern int rl_editing_mode; +/*extern int no_line_editing;*/ #endif /* READLINE */ #define USAGE_STRING "set [--abefhknotuvxldHCP] [-o option] [arg ...]" @@ -215,7 +216,7 @@ { rl_variable_bind ("editing-mode", option_name); - if (thr_me->interactive) + if (interactive) with_input_from_stdin (); no_line_editing = 0; } @@ -225,7 +226,7 @@ if ((isemacs && STREQ (option_name, "emacs")) || (!isemacs && STREQ (option_name, "vi"))) { - if (thr_me->interactive) + if (interactive) with_input_from_stream (stdin, "stdin"); no_line_editing = 1; } @@ -500,14 +501,14 @@ /* Unless the -f option is supplied, the name refers to a variable. */ tem = makunbound - (name, unset_function ? thr_me->shell_functions : thr_me->shell_variables); + (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, thr_me->shell_functions); + tem = makunbound (name, shell_functions); if (tem == -1) any_failed++; Index: source.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/source.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- source.def 9 Mar 2002 16:05:42 -0000 1.3 +++ source.def 10 Mar 2002 21:45:14 -0000 1.4 @@ -127,7 +127,7 @@ free (filename); /* POSIX shells exit if non-interactive and file error. */ - if (posixly_correct && !thr_me->interactive_shell) + if (posixly_correct && !interactive_shell) longjmp (top_level, EXITPROG); return (EXECUTION_FAILURE); @@ -155,10 +155,10 @@ unwind_protect_int (return_catch_flag); unwind_protect_jmp_buf (return_catch); - unwind_protect_int (thr_me->interactive); + unwind_protect_int (interactive); unwind_protect_int (sourcelevel); add_unwind_protect ((Function *)xfree, filename); - thr_me->interactive = 0; + interactive = 0; sourcelevel++; set_dollar_vars_unchanged (); Index: trap.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/trap.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- trap.def 9 Mar 2002 04:20:36 -0000 1.2 +++ trap.def 10 Mar 2002 21:45:14 -0000 1.3 @@ -154,7 +154,7 @@ switch (sig) { case SIGINT: - if (thr_me->interactive) + if (interactive) signal (SIGINT, sigint_sighandler); else signal (SIGINT, termination_unwind_protect); @@ -172,7 +172,7 @@ case SIGTTOU: case SIGTSTP: #endif /* JOB_CONTROL */ - if (thr_me->interactive) + if (interactive) signal (sig, SIG_IGN); break; } |
From: kevin s. <xk...@us...> - 2002-03-10 21:45:17
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv3155 Modified Files: bashhist.c bashhist.h error.c execute_cmd.c input.c jobs.c nojobs.c nt_execute_cmd.c nt_io.c nt_types.h parse.y print_cmd.c shell.c shell.h subst.c test.c trap.c variables.c Log Message: renamed (almost) all members of the thread_env struct and added some #define's for accessing these member from thr_me. the goal is to reduce the number of places thr_me is referenced and hence the number of diffs with the bash mainline. the hope it that this will make patching to 1.14.7 easier. Index: bashhist.c =================================================================== RCS file: /cvsroot/winbash/winbash/bashhist.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- bashhist.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ bashhist.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -150,7 +150,7 @@ { int result = 0; - if (thr_me->interactive && history_lines_this_session) + if (interactive && history_lines_this_session) { char *hf = get_string_value ("HISTFILE"); @@ -220,7 +220,7 @@ # if defined (BANG_HISTORY) /* History expand the line. If this results in no errors, then add that line to the history if ADDIT is non-zero. */ - if (!thr_me->history_expansion_inhibited && history_expansion) + if (!history_expansion_inhibited && history_expansion) { expanded = history_expand (line, &history_value); @@ -261,7 +261,7 @@ } # endif /* BANG_HISTORY */ - if (addit && thr_me->remember_on_history && *return_value) + if (addit && remember_on_history && *return_value) maybe_add_history (return_value); if (!expanded) Index: bashhist.h =================================================================== RCS file: /cvsroot/winbash/winbash/bashhist.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- bashhist.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ bashhist.h 10 Mar 2002 21:45:13 -0000 1.2 @@ -21,7 +21,7 @@ #if !defined (__BASHHIST_H__) #define __BASHHIST_H__ -extern int remember_on_history; +/* extern int remember_on_history; */ extern int history_lines_this_session; extern int history_lines_in_file; extern int history_expansion; @@ -29,7 +29,7 @@ extern int command_oriented_history; # if defined (BANG_HISTORY) -extern int history_expansion_inhibited; +/* extern int history_expansion_inhibited; */ # endif /* BANG_HISTORY */ extern void load_history (); Index: error.c =================================================================== RCS file: /cvsroot/winbash/winbash/error.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- error.c 9 Mar 2002 16:05:41 -0000 1.2 +++ error.c 10 Mar 2002 21:45:13 -0000 1.3 @@ -50,7 +50,7 @@ { char *name = (char *) NULL; - if (!thr_me->interactive_shell) + if (!interactive_shell) name = dollar_vars[0]; if (!name && shell_name && *shell_name) name = base_pathname (shell_name); Index: execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- execute_cmd.c 9 Mar 2002 16:05:41 -0000 1.2 +++ execute_cmd.c 10 Mar 2002 21:45:13 -0000 1.3 @@ -330,7 +330,7 @@ } #endif /* !__NT_VC__ */ -#define DESCRIBE_PID(pid) if (thr_me->interactive) describe_pid (pid) +#define DESCRIBE_PID(pid) if (interactive) describe_pid (pid) /* Execute the command passed in COMMAND, perhaps doing it asynchrounously. COMMAND is exactly what read_command () places into GLOBAL_COMMAND. @@ -435,7 +435,7 @@ if (!asynchronous) #endif /* !_MT */ { - thr_me->last_command_exit_value = wait_for (paren_pid); + last_command_exit_value = wait_for (paren_pid); #if defined (_MT) /* Check if the subshell changed our current working directory. If so, @@ -451,13 +451,13 @@ /* If we have to, invert the return value. */ if (invert) { - if (thr_me->last_command_exit_value == EXECUTION_SUCCESS) + if (last_command_exit_value == EXECUTION_SUCCESS) return (EXECUTION_FAILURE); else return (EXECUTION_SUCCESS); } else - return (thr_me->last_command_exit_value); + return (last_command_exit_value); } else { @@ -604,9 +604,9 @@ /* NT allows thread handles (bash pids) to be recycled too quickly, so the last_made_pid may be the same as it was before. Just set it to -1 and hope no one else needs to use it... */ - pid_t last_pid = thr_me->last_made_pid = -1; + pid_t last_pid = last_made_pid = -1; #else - pid_t last_pid = thr_me->last_made_pid; + pid_t last_pid = last_made_pid; #endif if (ignore_return && command->value.Simple) @@ -630,29 +630,29 @@ /* XXX - this is something to watch out for if there are problems when the shell is compiled without job control. */ - if (thr_me->already_making_children && pipe_out == NO_PIPE && - last_pid != thr_me->last_made_pid) + if (already_making_children && pipe_out == NO_PIPE && + last_pid != last_made_pid) { stop_pipeline (asynchronous, (COMMAND *) NULL); if (asynchronous) { - DESCRIBE_PID (thr_me->last_made_pid); + DESCRIBE_PID (last_made_pid); } else #if !defined (JOB_CONTROL) /* Do not wait for asynchronous processes started from startup files. */ - if (thr_me->last_made_pid != thr_me->last_asynchronous_pid) + if (last_made_pid != last_asynchronous_pid) #endif /* When executing a shell function that executes other commands, this causes the last simple command in the function to be waited for twice. */ - exec_result = wait_for (thr_me->last_made_pid); + exec_result = wait_for (last_made_pid); #if !defined (JOB_CONTROL) else report_error ("last_made_pid (%d) != last_asynchronous_pid (%d)\n", - thr_me->last_made_pid, thr_me->last_asynchronous_pid); + last_made_pid, last_asynchronous_pid); #endif } } @@ -660,7 +660,7 @@ if (!ignore_return && exit_immediately_on_error && !invert && (exec_result != EXECUTION_SUCCESS)) { - thr_me->last_command_exit_value = exec_result; + last_command_exit_value = exec_result; run_pending_traps (); LONGJMP (top_level, EXITPROG); } @@ -690,7 +690,7 @@ then the standard input for an asynchronous command is forced to /dev/null. */ # if defined (JOB_CONTROL) - if ((!thr_me->interactive_shell || thr_me->subshell_environment || !job_control) && + if ((!interactive_shell || subshell_environment || !job_control) && !stdin_redir) # else if (!stdin_redir) @@ -707,7 +707,7 @@ (tc, 1, pipe_in, pipe_out, fds_to_close); #if defined (JOB_CONTROL) - if ((!thr_me->interactive_shell || thr_me->subshell_environment || !job_control) && + if ((!interactive_shell || subshell_environment || !job_control) && !stdin_redir) #else if (!stdin_redir) @@ -795,7 +795,7 @@ terminate_current_pipeline (); kill_current_pipeline (); #endif /* JOB_CONTROL */ - thr_me->last_command_exit_value = EXECUTION_FAILURE; + last_command_exit_value = EXECUTION_FAILURE; /* The unwind-protects installed below will take care of closing all of the open file descriptors. */ throw_to_top_level (); @@ -963,9 +963,9 @@ exec_result = EXECUTION_SUCCESS; } - thr_me->last_command_exit_value = exec_result; + last_command_exit_value = exec_result; run_pending_traps (); - return (thr_me->last_command_exit_value); + return (last_command_exit_value); } #define WEIRD_SYNC_PROBLEM 1 /* (cat a|cat)|cat hangs */ @@ -1021,14 +1021,14 @@ undoing all the work we just did in make_child. */ original_pgrp = -1; #endif /* JOB_CONTROL */ - thr_me->interactive_shell = 0; + interactive_shell = 0; asynchronous = 0; } /* Subshells are neither login nor interactive. */ - thr_me->login_shell = thr_me->interactive = 0; + login_shell = interactive = 0; - thr_me->subshell_environment = 1; + subshell_environment = 1; #if defined (JOB_CONTROL) /* Delete all traces that there were any jobs running. This is @@ -1119,7 +1119,7 @@ to do the `shell cleanup' things, such as running traps[0]. */ if (user_subshell && signal_is_trapped (0)) { - thr_me->last_command_exit_value = return_code; + last_command_exit_value = return_code; return_code = run_exit_trap (); } @@ -1135,7 +1135,7 @@ #define REAP() \ do \ { \ - if (!thr_me->interactive_shell) \ + if (!interactive_shell) \ reap_dead_jobs (); \ } \ while (0) @@ -1143,7 +1143,7 @@ #define REAP() \ do \ { \ - if (!thr_me->interactive_shell) \ + if (!interactive_shell) \ cleanup_dead_jobs (); \ } \ while (0) @@ -1192,7 +1192,7 @@ QUIT; bind_variable (identifier, list->word->word); execute_command (for_command->action); - retval = thr_me->last_command_exit_value; + retval = last_command_exit_value; REAP (); QUIT; @@ -1217,7 +1217,7 @@ if (lexical_scoping) { if (!old_value) - makunbound (identifier, thr_me->shell_variables); + makunbound (identifier, shell_variables); else { SHELL_VAR *new_value; @@ -1376,7 +1376,7 @@ { print_select_list (list, list_len, max_elem_len, indices_len); printf ("%s", prompt); - fflush (thr_me->stdfile[1]); + fflush (stdfile[1]); QUIT; if (read_builtin ((WORD_LIST *) NULL) == EXECUTION_FAILURE) @@ -1491,7 +1491,7 @@ if (lexical_scoping) { if (!old_value) - makunbound (identifier, thr_me->shell_variables); + makunbound (identifier, shell_variables); else { SHELL_VAR *new_value; @@ -1578,7 +1578,7 @@ (case_command->flags & CMD_IGNORE_RETURN)) clauses->action->flags |= CMD_IGNORE_RETURN; execute_command (clauses->action); - retval = thr_me->last_command_exit_value; + retval = last_command_exit_value; goto exit_command; } @@ -1723,14 +1723,14 @@ result = EXECUTION_SUCCESS; /* If we're in a function, update the pseudo-line-number information. */ - if (thr_me->variable_context) + if (variable_context) line_number = simple_command->line - function_line_number; /* Remember what this command line looks like at invocation. */ - thr_me->command_string_index = 0; + command_string_index = 0; print_simple_command (simple_command); - command_line = (char *)alloca (1 + strlen (thr_me->the_printed_command)); - strcpy (command_line, thr_me->the_printed_command); + command_line = (char *)alloca (1 + strlen (the_printed_command)); + strcpy (command_line, the_printed_command); first_word_quoted = simple_command->words ? simple_command->words->word->quoted : 0; @@ -1912,7 +1912,7 @@ } else /* in parent */ { - HANDLE h = find_handle_by_pid(thr_me->last_made_pid); + HANDLE h = find_handle_by_pid(last_made_pid); P (sem_piping_builtin); V (cs_pipe_builtin); close_pipes (pipe_in, pipe_out); @@ -1964,7 +1964,7 @@ do_piping (pipe_in, pipe_out); - thr_me->subshell_environment = 1; + subshell_environment = 1; if (do_redirections (simple_command->redirects, 1, 0, 0) == 0) exit (EXECUTION_SUCCESS); @@ -1993,7 +1993,7 @@ if (do_redirections (simple_command->redirects, 0, 0, 0) != 0) result = EXECUTION_FAILURE; else if (old_last_command_subst_pid != last_command_subst_pid) - result = thr_me->last_command_exit_value; + result = last_command_exit_value; else result = EXECUTION_SUCCESS; } @@ -2037,17 +2037,17 @@ if (builtin == source_builtin) { if (subshell == 0) - begin_unwind_frame ("thr_me->builtin_env"); + begin_unwind_frame ("builtin_env"); - if (thr_me->temporary_env) + if (temporary_env) { - thr_me->builtin_env = copy_array (thr_me->temporary_env); + builtin_env = copy_array (temporary_env); if (subshell == 0) add_unwind_protect (dispose_builtin_env, (char *) NULL); dispose_used_env_vars (); } else - thr_me->builtin_env = (char **) NULL; + builtin_env = (char **) NULL; } result = ((*builtin) (words->next)); @@ -2055,7 +2055,7 @@ if (subshell == 0 && builtin == source_builtin) { dispose_builtin_env (); - discard_unwind_frame ("thr_me->builtin_env"); + discard_unwind_frame ("builtin_env"); } if (subshell == 0 && builtin == eval_builtin && (flags & CMD_IGNORE_RETURN)) @@ -2098,7 +2098,7 @@ unwind_protect_int (line_number); } else - unwind_protect_int (thr_me->variable_context); + unwind_protect_int (variable_context); unwind_protect_int (loop_level); unwind_protect_int (return_catch_flag); @@ -2107,14 +2107,14 @@ /* The temporary environment for a function is supposed to apply to all commands executed within the function body. */ - if (thr_me->temporary_env) + if (temporary_env) { - thr_me->function_env = copy_array (thr_me->temporary_env); + function_env = copy_array (temporary_env); add_unwind_protect (dispose_function_env, (char *) NULL); dispose_used_env_vars (); } else - thr_me->function_env = (char **) NULL; + function_env = (char **) NULL; /* Note the second argument of "1", meaning that we discard the current value of "$*"! This is apparently the right thing. */ @@ -2135,7 +2135,7 @@ if (fc && (flags & CMD_IGNORE_RETURN)) fc->flags |= CMD_IGNORE_RETURN; - thr_me->variable_context++; + variable_context++; } else fc = tc; @@ -2180,9 +2180,9 @@ int flags; { /* A subshell is neither a login shell nor interactive. */ - thr_me->login_shell = thr_me->interactive = 0; + login_shell = interactive = 0; - thr_me->subshell_environment = 1; + subshell_environment = 1; maybe_make_export_env (); @@ -2222,9 +2222,9 @@ if (result == EXITPROG) #if defined (__NT_VC__) - return thr_me->last_command_exit_value; + return last_command_exit_value; #else /* !__NT_VC__ */ - exit (thr_me->last_command_exit_value); + exit (last_command_exit_value); #endif /* !__NT_VC__ */ else if (result) #if defined (__NT_VC__) @@ -2381,7 +2381,7 @@ { report_error ("%s: restricted: cannot specify `/' in command names", pathname); - thr_me->last_command_exit_value = EXECUTION_FAILURE; + last_command_exit_value = EXECUTION_FAILURE; return; } #endif /* RESTRICTED_SHELL */ @@ -2491,11 +2491,11 @@ if (async) { - old_interactive = thr_me->interactive; - thr_me->interactive = 0; + old_interactive = interactive; + interactive = 0; } - thr_me->subshell_environment = 1; + subshell_environment = 1; /* This functionality is now provided by close-on-exec of the file descriptors manipulated by redirection and piping. @@ -2516,7 +2516,7 @@ } if (async) - thr_me->interactive = old_interactive; + interactive = old_interactive; if (!command) { @@ -2524,7 +2524,7 @@ exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */ } - exit (shell_execve (command, args, thr_me->export_env)); + exit (shell_execve (command, args, export_env)); #endif /* !__NT_VC__ */ } else @@ -2853,10 +2853,10 @@ if (expandable_redirection_filename (temp)) { - if (posixly_correct && !thr_me->interactive_shell) + if (posixly_correct && !interactive_shell) disallow_filename_globbing++; filename = redirection_expand (temp->redirectee.filename); - if (posixly_correct && !thr_me->interactive_shell) + if (posixly_correct && !interactive_shell) disallow_filename_globbing--; if (!filename) @@ -3048,10 +3048,10 @@ case r_input_output: case r_output_force: - if (posixly_correct && !thr_me->interactive_shell) + if (posixly_correct && !interactive_shell) disallow_filename_globbing++; redirectee_word = redirection_expand (redirectee); - if (posixly_correct && !thr_me->interactive_shell) + if (posixly_correct && !interactive_shell) disallow_filename_globbing--; if (!redirectee_word) @@ -3116,8 +3116,8 @@ { if (remembering) /* Only setup to undo it if the thing to undo is active. */ - /* if ((fd != thr_me->fd[redirector]) && (fcntl (thr_me->fd[redirector], F_GETFD, 0) != -1)) */ - if ((fd != thr_me->fd[redirector]) /* && IS_OPEN_FD (thr_me->fd[redirector]) */) + /* if ((fd != fd[redirector]) && (fcntl (fd[redirector], F_GETFD, 0) != -1)) */ + if ((fd != thr_me->fd[redirector]) /* && IS_OPEN_FD (fd[redirector]) */) add_undo_redirect (redirector); else add_undo_close_redirect (redirector); @@ -3347,9 +3347,9 @@ /* if ((already_set || set_unconditionally) && (ok_to_set)) set_it () */ #if !defined (__NT_VC__) - if (((fcntl (thr_me->fd[redir_fd], F_GETFD, 0) == 1) || set_clexec) && - (thr_me->fd[redirector] > 2)) - SET_CLOSE_ON_EXEC (thr_me->fd[redirector]); + if (((fcntl (fd[redir_fd], F_GETFD, 0) == 1) || set_clexec) && + (fd[redirector] > 2)) + SET_CLOSE_ON_EXEC (fd[redirector]); #endif /* !__NT_VC__ */ } break; @@ -3357,7 +3357,7 @@ case r_close_this: if (for_real) { - /* if (remembering && (fcntl (thr_me->fd[redirector], F_GETFD, 0) != -1)) */ + /* if (remembering && (fcntl (fd[redirector], F_GETFD, 0) != -1)) */ if (remembering && IS_OPEN_FD (thr_me->fd[redirector])) add_undo_redirect (redirector); @@ -3366,8 +3366,8 @@ close_buffered_fd (thr_me->fd[redirector]); thr_me->fd[redirector] = -1; #else /* !BUFFERED_INPUT */ - close (thr_me->fd[redirector]); - thr_me->fd[redirector] = -1; + close (fd[redirector]); + fd[redirector] = -1; #endif /* !BUFFERED_INPUT */ } break; @@ -3393,7 +3393,7 @@ new_fd = dup (fd); thr_me->fd[new_fd] = new_fd; #else - new_fd = fcntl (thr_me->fd[fd], F_DUPFD, SHELL_FD_BASE); + new_fd = fcntl (fd[fd], F_DUPFD, SHELL_FD_BASE); #endif if (new_fd < 0) Index: input.c =================================================================== RCS file: /cvsroot/winbash/winbash/input.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- input.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ input.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -135,7 +135,7 @@ int nfd; if (fd > 0 && ((bash_input.type == st_bstream && bash_input.location.buffered_fd == fd) || - (thr_me->interactive_shell == 0 && default_buffered_input == fd))) + (interactive_shell == 0 && default_buffered_input == fd))) { #if !defined (_MT) /* Sync the stream so we can re-read from the new file descriptor. We Index: jobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/jobs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- jobs.c 9 Mar 2002 16:05:41 -0000 1.2 +++ jobs.c 10 Mar 2002 21:45:13 -0000 1.3 @@ -1393,7 +1393,7 @@ if (interrupt_immediately || (this_shell_builtin && this_shell_builtin == wait_builtin)) { - thr_me->last_command_exit_value = EXECUTION_FAILURE; + last_command_exit_value = EXECUTION_FAILURE; restore_sigint_handler (); interrupt_state++; QUIT; @@ -1445,7 +1445,7 @@ if (!job_control) old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); - termination_state = thr_me->last_command_exit_value; + termination_state = last_command_exit_value; /* If we say wait_for (), then we have a record of this child somewhere. If this child and all of its peers are not running, then don't @@ -2143,7 +2143,7 @@ /* If SIGINT is trapped, set the exit status so that the trap handler can see it. */ if (signal_is_trapped (SIGINT)) - thr_me->last_command_exit_value = process_exit_status + last_command_exit_value = process_exit_status (jobs[job]->pipe->status); /* If the signal is trapped, let the trap handler @@ -2200,7 +2200,7 @@ trap_command = savestring (trap_list[SIGCHLD]); begin_unwind_frame ("SIGCHLD trap"); - unwind_protect_int (thr_me->last_command_exit_value); + unwind_protect_int (last_command_exit_value); unwind_protect_int (last_made_pid); unwind_protect_int (interrupt_immediately); unwind_protect_int (freeze_jobs_list); Index: nojobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/nojobs.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- nojobs.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ nojobs.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -130,9 +130,9 @@ { register int i; - for (i = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].pid == pid) - return (thr_me->pid_list[i].h); + for (i = 0; i < pid_list_size; i++) + if (pid_list[i].pid == pid) + return (pid_list[i].h); return (INVALID_HANDLE_VALUE); } @@ -162,11 +162,11 @@ int slot; slot = find_proc_slot (); - thr_me->pid_list[slot].pid = get_next_pid(); - thr_me->pid_list[slot].status = PROC_STILL_ALIVE; - thr_me->pid_list[slot].h = h; + pid_list[slot].pid = get_next_pid(); + pid_list[slot].status = PROC_STILL_ALIVE; + pid_list[slot].h = h; - return (thr_me->pid_list[slot].pid); + return (pid_list[slot].pid); } /* recycle a slot in the per-thread pid table so it can be used again */ @@ -181,9 +181,9 @@ return; /* reinitialize all fields */ - thr_me->pid_list[slot].h = INVALID_HANDLE_VALUE; - thr_me->pid_list[slot].pid = NO_PID; - thr_me->pid_list[slot].status = PROC_NULL; + pid_list[slot].h = INVALID_HANDLE_VALUE; + pid_list[slot].pid = NO_PID; + pid_list[slot].status = PROC_NULL; } @@ -221,18 +221,18 @@ alloc_pid_list () { register int i; - int old = thr_me->pid_list_size; + int old = pid_list_size; - thr_me->pid_list_size += 10; - thr_me->pid_list = (struct proc_status *) - xrealloc (thr_me->pid_list, thr_me->pid_list_size * sizeof (struct proc_status)); + pid_list_size += 10; + pid_list = (struct proc_status *) + xrealloc (pid_list, pid_list_size * sizeof (struct proc_status)); /* None of the newly allocated slots have process id's yet. */ - for (i = old; i < thr_me->pid_list_size; i++) { - thr_me->pid_list[i].pid = NO_PID; - thr_me->pid_list[i].status = PROC_NULL; + for (i = old; i < pid_list_size; i++) { + pid_list[i].pid = NO_PID; + pid_list[i].status = PROC_NULL; #ifdef __NT_VC__ - thr_me->pid_list[i].h = INVALID_HANDLE_VALUE; + pid_list[i].h = INVALID_HANDLE_VALUE; #endif } } @@ -244,11 +244,11 @@ { register int i; - for (i = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].pid == NO_PID) + for (i = 0; i < pid_list_size; i++) + if (pid_list[i].pid == NO_PID) return (i); - if (i == thr_me->pid_list_size) + if (i == pid_list_size) alloc_pid_list (); return (i); @@ -262,8 +262,8 @@ { register int i; - for (i = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].pid == pid) + for (i = 0; i < pid_list_size; i++) + if (pid_list[i].pid == pid) return (i); return (NO_PID); @@ -280,7 +280,7 @@ i = find_index_by_pid (pid); if (i == NO_PID) return (PROC_BAD); - return (thr_me->pid_list[i].status); + return (pid_list[i].status); } /* Give PID the status value STATUS in the PID_LIST array. */ @@ -296,13 +296,13 @@ return; if (WIFSIGNALED (status)) - thr_me->pid_list[slot].status = 128 + WTERMSIG (status); + pid_list[slot].status = 128 + WTERMSIG (status); else - thr_me->pid_list[slot].status = WEXITSTATUS (status); + pid_list[slot].status = WEXITSTATUS (status); #ifdef __NT_VC__ - CloseHandle(thr_me->pid_list[slot].h); - thr_me->pid_list[slot].h = INVALID_HANDLE_VALUE; + CloseHandle(pid_list[slot].h); + pid_list[slot].h = INVALID_HANDLE_VALUE; #endif } @@ -313,8 +313,8 @@ int slot; slot = find_proc_slot (); - thr_me->pid_list[slot].pid = pid; - thr_me->pid_list[slot].status = PROC_STILL_ALIVE; + pid_list[slot].pid = pid; + pid_list[slot].status = PROC_STILL_ALIVE; } int @@ -332,9 +332,9 @@ * the table is freed each time a thread is reaped. Since there * is a per-thread resource, there is no need to do this clean up. */ - for (i = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].status != PROC_STILL_ALIVE) - thr_me->pid_list[i].pid = NO_PID; + for (i = 0; i < pid_list_size; i++) + if (pid_list[i].status != PROC_STILL_ALIVE) + pid_list[i].pid = NO_PID; #endif } @@ -373,7 +373,7 @@ /* If this is a login shell we don't wish to be disturbed by stop signals. */ - if (thr_me->login_shell) + if (login_shell) { #if defined (SIGTSTP) set_signal_handler (SIGTSTP, SIG_IGN); @@ -405,11 +405,11 @@ int bContinue = TRUE; DWORD dwWhich; - if (thr_me->pid_list_size) { + if (pid_list_size) { int i,j; int rc; - HANDLE* harray = calloc(thr_me->pid_list_size, sizeof (HANDLE)); - pid_t* parray = calloc(thr_me->pid_list_size, sizeof (pid_t)); + HANDLE* harray = calloc(pid_list_size, sizeof (HANDLE)); + pid_t* parray = calloc(pid_list_size, sizeof (pid_t)); if (!harray || !parray) { if (harray) free(harray); @@ -418,12 +418,12 @@ } /* build up array of thread handles to wait on */ - for (i = 0, j = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].pid != NO_PID && - thr_me->pid_list[i].status == PROC_STILL_ALIVE && - thr_me->pid_list[i].h != INVALID_HANDLE_VALUE) { - harray[j] = thr_me->pid_list[i].h; - parray[j] = thr_me->pid_list[i].pid; + for (i = 0, j = 0; i < pid_list_size; i++) + if (pid_list[i].pid != NO_PID && + pid_list[i].status == PROC_STILL_ALIVE && + pid_list[i].h != INVALID_HANDLE_VALUE) { + harray[j] = pid_list[i].h; + parray[j] = pid_list[i].pid; j++; } @@ -548,7 +548,7 @@ set_signal_handler (SIGINT, SIG_IGN); set_signal_handler (SIGQUIT, SIG_IGN); #endif - thr_me->last_asynchronous_pid = getpid (); + last_asynchronous_pid = getpid (); } #if defined (SIGTSTP) @@ -561,10 +561,10 @@ { /* In the parent. */ - thr_me->last_made_pid = pid; + last_made_pid = pid; if (async_p) - thr_me->last_asynchronous_pid = pid; + last_asynchronous_pid = pid; add_pid (pid); } @@ -720,52 +720,52 @@ if (thr_me->fd[i] >= 0) SET_CLOSE_ON_EXEC (thr_me->fd[i]); } - thr_child->stdfile[0] = fdopen (thr_child->fd[0], "r"); - thr_child->stdfile[1] = fdopen (thr_child->fd[1], "w"); - thr_child->stdfile[2] = fdopen (thr_child->fd[2], "w"); + thr_child->stdfile_[0] = fdopen (thr_child->fd[0], "r"); + thr_child->stdfile_[1] = fdopen (thr_child->fd[1], "w"); + thr_child->stdfile_[2] = fdopen (thr_child->fd[2], "w"); - thr_child->last_made_pid = thr_me->last_made_pid; - thr_child->last_asynchronous_pid = thr_me->last_asynchronous_pid; - thr_child->last_command_exit_value = thr_me->last_command_exit_value; - thr_child->subshell_environment = thr_me->subshell_environment; + thr_child->last_made_pid_ = last_made_pid; + thr_child->last_asynchronous_pid_ = last_asynchronous_pid; + thr_child->last_command_exit_value_ = last_command_exit_value; + thr_child->subshell_environment_ = subshell_environment; - if (thr_me->temporary_env) - thr_child->temporary_env = copy_array (thr_me->temporary_env); - if (thr_me->function_env) - thr_child->function_env = copy_array (thr_me->function_env); - if (thr_me->builtin_env) - thr_child->builtin_env = copy_array (thr_me->builtin_env); + if (temporary_env) + thr_child->temporary_env_ = copy_array (temporary_env); + if (function_env) + thr_child->function_env_ = copy_array (function_env); + if (builtin_env) + thr_child->builtin_env_ = copy_array (builtin_env); - if (thr_me->shell_variables) - thr_child->shell_variables = copy_hash_table (thr_me->shell_variables, copy_variable); - if (thr_me->shell_functions) - thr_child->shell_functions = copy_hash_table (thr_me->shell_functions, copy_variable); - thr_child->variable_context = thr_me->variable_context; + if (shell_variables) + thr_child->shell_variables_ = copy_hash_table (shell_variables, copy_variable); + if (shell_functions) + thr_child->shell_functions_ = copy_hash_table (shell_functions, copy_variable); + thr_child->variable_context_ = variable_context; - if (thr_me->shell_environment) - thr_child->shell_environment = copy_array (thr_me->shell_environment); - if (thr_me->export_env) - thr_child->export_env = copy_array (thr_me->export_env); + if (shell_environment) + thr_child->shell_environment_ = copy_array (shell_environment); + if (export_env) + thr_child->export_env_ = copy_array (export_env); - thr_child->interactive = thr_me->interactive; - thr_child->login_shell = thr_me->login_shell; - thr_child->interactive_shell = thr_me->interactive_shell; - thr_child->shell_level = thr_me->shell_level; + thr_child->interactive_ = interactive; + thr_child->login_shell_ = login_shell; + thr_child->interactive_shell_ = interactive_shell; + thr_child->shell_level_ = shell_level; - thr_child->already_making_children = thr_me->already_making_children; + thr_child->already_making_children_ = already_making_children; - if (thr_me->the_printed_command) - thr_child->the_printed_command = savestring (thr_me->the_printed_command); + if (the_printed_command) + thr_child->the_printed_command_ = savestring (the_printed_command); else - thr_child->the_printed_command = (char *) NULL; - thr_child->command_string_index = thr_me->command_string_index; + thr_child->the_printed_command_ = (char *) NULL; + thr_child->command_string_index_ = command_string_index; - thr_child->remember_on_history = thr_me->remember_on_history; - thr_child->no_line_editing = thr_me->no_line_editing; - thr_child->history_expansion_inhibited = thr_me->history_expansion_inhibited; + thr_child->remember_on_history_ = remember_on_history; + thr_child->no_line_editing_ = no_line_editing; + thr_child->history_expansion_inhibited_ = history_expansion_inhibited; - thr_child->pid_list_size = 0; - thr_child->pid_list = NULL; + thr_child->pid_list_size_ = 0; + thr_child->pid_list_ = NULL; thr_args->thr_env = thr_child; @@ -781,10 +781,10 @@ { pid_t pid = add_pid_w32((HANDLE) hThread); - thr_me->last_made_pid = pid; + last_made_pid = pid; if (async_p) - thr_me->last_asynchronous_pid = pid; + last_asynchronous_pid = pid; return pid; } @@ -877,11 +877,11 @@ * a job via wait_for_single_pid() and this means leaving the * pid status in the per-thread pid table for it to be found later. */ - if (thr_me->pid_list_size) { + if (pid_list_size) { int i,j; int rc; - HANDLE* harray = calloc(thr_me->pid_list_size, sizeof (HANDLE)); - pid_t* parray = calloc(thr_me->pid_list_size, sizeof (HANDLE)); + HANDLE* harray = calloc(pid_list_size, sizeof (HANDLE)); + pid_t* parray = calloc(pid_list_size, sizeof (HANDLE)); if (!harray || !parray) { if (harray) free(harray); @@ -890,11 +890,11 @@ } /* build up array of thread handles to wait on */ - for (i = 0, j = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].pid != NO_PID && - thr_me->pid_list[i].status == PROC_STILL_ALIVE) { - harray[j] = thr_me->pid_list[i].h; - parray[j] = thr_me->pid_list[i].pid; + for (i = 0, j = 0; i < pid_list_size; i++) + if (pid_list[i].pid != NO_PID && + pid_list[i].status == PROC_STILL_ALIVE) { + harray[j] = pid_list[i].h; + parray[j] = pid_list[i].pid; j++; } @@ -985,7 +985,7 @@ /* If we are running a script, ignore SIGINT while we're waiting for a child to exit. The loop below does some of this, but not all. */ - if (!thr_me->interactive_shell) + if (!interactive_shell) old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); while ((got_pid = WAITPID (-1, &status, 0)) != pid) /* XXX was pid now -1 */ @@ -1012,7 +1012,7 @@ reap_zombie_children (); #endif /* _POSIX_VERSION */ - if (!thr_me->interactive_shell) + if (!interactive_shell) { set_signal_handler (SIGINT, old_sigint_handler); /* If the job exited because of SIGINT, make sure the shell acts as if @@ -1040,7 +1040,7 @@ fprintf (stderr, "\n"); } - if (thr_me->interactive_shell && !thr_me->subshell_environment) + if (interactive_shell && !subshell_environment) { if (WIFSIGNALED (status) || WIFSTOPPED (status)) set_tty_state (); @@ -1144,13 +1144,13 @@ int async; COMMAND *ignore; { - thr_me->already_making_children = 0; + already_making_children = 0; } void start_pipeline () { - thr_me->already_making_children = 1; + already_making_children = 1; } /* Print descriptive information about the job with leader pid PID. */ Index: nt_execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/nt_execute_cmd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- nt_execute_cmd.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ nt_execute_cmd.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -275,8 +275,8 @@ #endif /* Write the error to stderr too */ - if (thr_main && thr_main->stdfile[2]) - outf = thr_main->stdfile[2]; + if (thr_main && thr_main->stdfile_[2]) + outf = thr_main->stdfile_[2]; else outf = &_iob[2]; @@ -367,12 +367,12 @@ for (i = 3; i < MAX_FD; i++) thr_me->fd[i] = -1; - thr_me->last_made_pid = NO_PID; - thr_me->last_asynchronous_pid = NO_PID; - thr_me->remember_on_history = 1; + last_made_pid = NO_PID; + last_asynchronous_pid = NO_PID; + remember_on_history = 1; - thr_me->pid_list_size = 0; - thr_me->pid_list = NULL; + pid_list_size = 0; + pid_list = NULL; } void @@ -396,24 +396,24 @@ if (stderr) FCLOSE (stderr); - if (thr_me->temporary_env) - free_array (thr_me->temporary_env); - if (thr_me->builtin_env) - free_array (thr_me->builtin_env); - if (thr_me->function_env) - free_array (thr_me->function_env); + if (temporary_env) + free_array (temporary_env); + if (builtin_env) + free_array (builtin_env); + if (function_env) + free_array (function_env); - if (thr_me->shell_variables) - dispose_hash_table (thr_me->shell_variables, dispose_variable); - if (thr_me->shell_functions) - dispose_hash_table (thr_me->shell_functions, dispose_variable); - if (thr_me->shell_environment) - free_array (thr_me->shell_environment); - if (thr_me->export_env) - free_array (thr_me->export_env); + if (shell_variables) + dispose_hash_table (shell_variables, dispose_variable); + if (shell_functions) + dispose_hash_table (shell_functions, dispose_variable); + if (shell_environment) + free_array (shell_environment); + if (export_env) + free_array (export_env); - if (thr_me->the_printed_command) - FREE (thr_me->the_printed_command); + if (the_printed_command) + FREE (the_printed_command); FREE (thr_me); } @@ -445,7 +445,7 @@ V (sem_piping_subshell); if (result == EXITPROG) - status = thr_me->last_command_exit_value; + status = last_command_exit_value; else if (result) status = EXECUTION_FAILURE; else @@ -502,35 +502,35 @@ if (thr_me->fd[i] > 0) close (thr_me->fd[i]); - if (thr_me->temporary_env) - free_array (thr_me->temporary_env); - if (thr_me->builtin_env) - free_array (thr_me->builtin_env); - if (thr_me->function_env) - free_array (thr_me->function_env); + if (temporary_env) + free_array (temporary_env); + if (builtin_env) + free_array (builtin_env); + if (function_env) + free_array (function_env); - if (thr_me->shell_variables) - dispose_hash_table (thr_me->shell_variables, dispose_variable); - if (thr_me->shell_functions) - dispose_hash_table (thr_me->shell_functions, dispose_variable); - if (thr_me->shell_environment) - free_array (thr_me->shell_environment); - if (thr_me->export_env) - free_array (thr_me->export_env); - if (thr_me->pid_list_size) { + if (shell_variables) + dispose_hash_table (shell_variables, dispose_variable); + if (shell_functions) + dispose_hash_table (shell_functions, dispose_variable); + if (shell_environment) + free_array (shell_environment); + if (export_env) + free_array (export_env); + if (pid_list_size) { int i; /* parent exiting, reap any active thread handles */ - for (i = 0; i < thr_me->pid_list_size; i++) - if (thr_me->pid_list[i].h != INVALID_HANDLE_VALUE) - CloseHandle(thr_me->pid_list[i].h); + for (i = 0; i < pid_list_size; i++) + if (pid_list[i].h != INVALID_HANDLE_VALUE) + CloseHandle(pid_list[i].h); /* reclaim heap */ - FREE(thr_me->pid_list); + FREE(pid_list); } - if (thr_me->the_printed_command) - FREE (thr_me->the_printed_command); + if (the_printed_command) + FREE (the_printed_command); FREE (thr_me); @@ -581,11 +581,11 @@ if (async) { - old_interactive = thr_me->interactive; - thr_me->interactive = 0; + old_interactive = interactive; + interactive = 0; } - thr_me->subshell_environment = 1; + subshell_environment = 1; /* This functionality is now provided by close-on-exec of the file descriptors manipulated by redirection and piping. @@ -607,7 +607,7 @@ } if (async) - thr_me->interactive = old_interactive; + interactive = old_interactive; if (!command) { @@ -616,7 +616,7 @@ return 127; /* was EX_NOTFOUND */ /* Posix.2 says the exit status is 127 */ } - pi = nt_shell_execve_async (command, args, thr_me->export_env); + pi = nt_shell_execve_async (command, args, export_env); V (sem_piping_disk); @@ -1392,7 +1392,7 @@ close (fildes[0]); /* The currently executing shell is not interactive. */ - thr_me->interactive = 0; + interactive = 0; remove_quoted_escapes (string); @@ -1401,7 +1401,7 @@ result = SETJMP (top_level); if (result == EXITPROG) - return (thr_me->last_command_exit_value); + return (last_command_exit_value); else if (result) return (EXECUTION_FAILURE); else Index: nt_io.c =================================================================== RCS file: /cvsroot/winbash/winbash/nt_io.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- nt_io.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ nt_io.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -148,11 +148,11 @@ int ret; int save_count = count; #if 0 - fprintf (stderr, "DEBUG: nt_read interactive=%d running_in_emacs=%d\n", thr_me->interactive_shell,running_in_emacs); + fprintf (stderr, "DEBUG: nt_read interactive=%d running_in_emacs=%d\n", interactive_shell,running_in_emacs); fflush (stderr); #endif - if (thr_me->interactive_shell) // && !running_in_emacs) + if (interactive_shell) { int i; for (i = 0; i < count; buf[i++] = getch ()) Index: nt_types.h =================================================================== RCS file: /cvsroot/winbash/winbash/nt_types.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- nt_types.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ nt_types.h 10 Mar 2002 21:45:13 -0000 1.2 @@ -54,53 +54,91 @@ struct thread_env { int fd[MAX_FD]; - FILE *stdfile[3]; + FILE *stdfile_[3]; - int last_made_pid; - int last_asynchronous_pid; - int subshell_environment; /* Non-zero if we have just forked and are currently running in a subshell + int last_made_pid_; + int last_asynchronous_pid_; + int subshell_environment_; /* Non-zero if we have just forked and are currently running in a subshell environment. */ - char **temporary_env; - char **function_env; - char **builtin_env; - HASH_TABLE *shell_variables; - HASH_TABLE *shell_functions; - int variable_context; - char **shell_environment; - char **export_env; + char **temporary_env_; + char **function_env_; + char **builtin_env_; + HASH_TABLE *shell_variables_; + HASH_TABLE *shell_functions_; + int variable_context_; + char **shell_environment_; + char **export_env_; - int interactive; - int login_shell; - int last_command_exit_value; /* The value returned by the last synchronous command. */ - int interactive_shell; + int interactive_; + int login_shell_; + int last_command_exit_value_; /* The value returned by the last synchronous command. */ + int interactive_shell_; - int already_making_children; + int already_making_children_; - int shell_level; + int shell_level_; - char *the_printed_command; - int command_string_index; + char *the_printed_command_; + int command_string_index_; - int remember_on_history; - int no_line_editing; - int history_expansion_inhibited; + int remember_on_history_; + int no_line_editing_; + int history_expansion_inhibited_; - struct proc_status *pid_list; - int pid_list_size; + struct proc_status *pid_list_; + int pid_list_size_; }; extern __declspec(thread) struct thread_env *thr_me; +/* macros to access members of the thr_me structure. + use these macros to reference thread-local variables. + this, in theory, will make it easier to merge changes + from the bash mainline into the windows port. */ +#define stdfile thr_me->stdfile_ + +#define last_made_pid thr_me->last_made_pid_ +#define last_asynchronous_pid thr_me->last_asynchronous_pid_ +#define subshell_environment thr_me->subshell_environment_ + +#define temporary_env thr_me->temporary_env_ +#define function_env thr_me->function_env_ +#define builtin_env thr_me->builtin_env_ +#define shell_variables thr_me->shell_variables_ +#define shell_functions thr_me->shell_functions_ +#define variable_context thr_me->variable_context_ +#define shell_environment thr_me->shell_environment_ +#define export_env thr_me->export_env_ + +#define interactive thr_me->interactive_ +#define login_shell thr_me->login_shell_ +#define last_command_exit_value thr_me->last_command_exit_value_ +#define interactive_shell thr_me->interactive_shell_ + +#define already_making_children thr_me->already_making_children_ + +#define shell_level thr_me->shell_level_ + +#define the_printed_command thr_me->the_printed_command_ +#define command_string_index thr_me->command_string_index_ + +#define remember_on_history thr_me->remember_on_history_ +#define no_line_editing thr_me->no_line_editing_ +#define history_expansion_inhibited thr_me->history_expansion_inhibited_ + +#define pid_list thr_me->pid_list_ +#define pid_list_size thr_me->pid_list_size_ + /* Some convenience macros. */ #define FD0 (thr_me->fd[0]) #define FD1 (thr_me->fd[1]) #define FD2 (thr_me->fd[2]) -#define STDIN (thr_me->stdfile[0]) -#define STDOUT (thr_me->stdfile[1]) -#define STDERR (thr_me->stdfile[2]) +#define STDIN (thr_me->stdfile_[0]) +#define STDOUT (thr_me->stdfile_[1]) +#define STDERR (thr_me->stdfile_[2]) /* Thread I/O routines. */ extern int thr_printf (const char *, ...); @@ -108,17 +146,17 @@ #if defined (stdin) #undef stdin #endif /* stdin */ -#define stdin (thr_me->stdfile[0]) +#define stdin (thr_me->stdfile_[0]) #if defined (stdout) #undef stdout #endif /* stdout */ -#define stdout (thr_me->stdfile[1]) +#define stdout (thr_me->stdfile_[1]) #if defined (stderr) #undef stderr #endif /* stderr */ -#define stderr (thr_me->stdfile[2]) +#define stderr (thr_me->stdfile_[2]) #ifdef putchar #undef putchar Index: parse.y =================================================================== RCS file: /cvsroot/winbash/winbash/parse.y,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- parse.y 9 Mar 2002 16:05:42 -0000 1.2 +++ parse.y 10 Mar 2002 21:45:13 -0000 1.3 @@ -184,7 +184,7 @@ global_command = (COMMAND *)NULL; eof_encountered = 0; discard_parser_constructs (1); - if (thr_me->interactive) + if (interactive) { YYACCEPT; } @@ -1420,9 +1420,9 @@ #endif /* !JOB_CONTROL */ #if defined (READLINE) - if (thr_me->interactive && bash_input.type != st_string && thr_me->no_line_editing) + if (interactive && bash_input.type != st_string && no_line_editing) #else - if (thr_me->interactive && bash_input.type != st_string) + if (interactive && bash_input.type != st_string) #endif print_prompt (); @@ -1463,7 +1463,7 @@ shell_input_line_len = i; /* == strlen (shell_input_line) */ #if defined (HISTORY) - if (thr_me->interactive && shell_input_line && shell_input_line[0]) + if (interactive && shell_input_line && shell_input_line[0]) { char *expansions; @@ -1595,7 +1595,7 @@ temp_last = last_shell_builtin; temp_this = this_shell_builtin; - temp_exit_value = thr_me->last_command_exit_value; + temp_exit_value = last_command_exit_value; temp_eof_encountered = eof_encountered; last_lastarg = get_string_value ("_"); if (last_lastarg) @@ -1605,7 +1605,7 @@ last_shell_builtin = temp_last; this_shell_builtin = temp_this; - thr_me->last_command_exit_value = temp_exit_value; + last_command_exit_value = temp_exit_value; eof_encountered = temp_eof_encountered; bind_variable ("_", last_lastarg); @@ -1623,7 +1623,7 @@ yylex () { - if (thr_me->interactive && (!current_token || current_token == '\n')) + if (interactive && (!current_token || current_token == '\n')) { /* Before we print a prompt, we might have to check mailboxes. We do this only if it is time to do so. Notice that only here @@ -1637,7 +1637,7 @@ /* Avoid printing a prompt if we're not going to read anything, e.g. after resetting the parser with read_token (RESET). */ - if (token_to_read == 0 && thr_me->interactive) + if (token_to_read == 0 && interactive) prompt_again (); } @@ -1819,7 +1819,7 @@ return (yacc_EOF); } - if (character == '#' && (!thr_me->interactive || interactive_comments)) + if (character == '#' && (!interactive || interactive_comments)) { /* A comment. Discard until EOL or EOF, and then return a newline. */ discard_until ('\n'); @@ -2232,7 +2232,7 @@ token = xrealloc (token, token_buffer_size); } next_character: - if (character == '\n' && thr_me->interactive && bash_input.type != st_string) + if (character == '\n' && interactive && bash_input.type != st_string) prompt_again (); /* We want to remove quoted newlines (that is, a \<newline> pair) @@ -2351,7 +2351,7 @@ Special cases that disqualify: In a pattern list in a case statement (in_case_pattern_list). */ - if (thr_me->interactive_shell && !quoted && !in_case_pattern_list && + if (interactive_shell && !quoted && !in_case_pattern_list && (expand_next_token || command_token_position (last_read_token))) { char *alias_expand_word (), *expanded; @@ -2524,7 +2524,7 @@ { char *temp_prompt; - if (!thr_me->interactive) /* XXX */ + if (!interactive) /* XXX */ return; ps1_prompt = get_string_value ("PS1"); @@ -2542,7 +2542,7 @@ prompt_string_pointer = &ps2_prompt; #if defined (READLINE) - if (!thr_me->no_line_editing) + if (!no_line_editing) { FREE (current_readline_prompt); current_readline_prompt = temp_prompt; @@ -2683,7 +2683,7 @@ } case 'n': - if (!thr_me->no_line_editing) + if (!no_line_editing) temp = savestring ("\r\n"); else temp = savestring ("\n"); @@ -2829,7 +2829,7 @@ { if (message) { - if (!thr_me->interactive) + if (!interactive) { char *name = bash_input.name ? bash_input.name : "stdin"; report_error ("%s: line %d: `%s'", name, line_number, message); @@ -2841,7 +2841,7 @@ report_error ("%s", message); } - thr_me->last_command_exit_value = EX_USAGE; + last_command_exit_value = EX_USAGE; return; } @@ -2885,7 +2885,7 @@ report_error ("syntax error near unexpected token `%s'", etoken); } - if (!thr_me->interactive) + if (!interactive) { char *temp = savestring (shell_input_line); char *name = bash_input.name ? bash_input.name : "stdin"; @@ -2901,13 +2901,13 @@ else { char *name, *msg; - if (!thr_me->interactive) + if (!interactive) name = bash_input.name ? bash_input.name : "stdin"; if (EOF_Reached) msg = "syntax error: unexpected end of file"; else msg = "syntax error"; - if (!thr_me->interactive) + if (!interactive) report_error ("%s: line %d: %s", name, line_number, msg); else { @@ -2918,7 +2918,7 @@ report_error (msg); } } - thr_me->last_command_exit_value = EX_USAGE; + last_command_exit_value = EX_USAGE; } /* ??? Needed function. ??? We have to be able to discard the constructs @@ -2951,7 +2951,7 @@ static void handle_eof_input_unit () { - if (thr_me->interactive) + if (interactive) { /* shell.c may use this to decide whether or not to write out the history, among other things. We use it only for error reporting @@ -2965,7 +2965,7 @@ if (eof_encountered < eof_encountered_limit) { fprintf (STDERR, "Use \"%s\" to leave the shell.\n", - thr_me->login_shell ? "logout" : "exit"); + login_shell ? "logout" : "exit"); fflush (STDERR); eof_encountered++; /* Reset the prompt string to be $PS1. */ Index: print_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/print_cmd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- print_cmd.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ print_cmd.c 10 Mar 2002 21:45:13 -0000 1.2 @@ -83,7 +83,7 @@ print_command (command) COMMAND *command; { - thr_me->command_string_index = 0; + command_string_index = 0; printf ("%s", make_command_string (command)); } @@ -95,9 +95,9 @@ make_command_string (command) COMMAND *command; { - thr_me->command_string_index = 0; + command_string_index = 0; make_command_string_internal (command); - return (thr_me->the_printed_command); + return (the_printed_command); } /* The internal function. This is the real workhorse. */ @@ -571,7 +571,7 @@ char *result; int old_indent = indentation, old_amount = indentation_amount; - thr_me->command_string_index = 0; + command_string_index = 0; if (name && *name) cprintf ("%s ", name); @@ -607,7 +607,7 @@ newline ("}"); - result = thr_me->the_printed_command; + result = the_printed_command; if (!multi_line) { @@ -649,7 +649,7 @@ static void semicolon () { - if (thr_me->command_string_index > 0 && thr_me->the_printed_command[thr_me->command_string_index - 1] == '&') + if (command_string_index > 0 && the_printed_command[command_string_index - 1] == '&') return; cprintf (";"); } @@ -718,14 +718,14 @@ if (argp) { the_printed_command_resize (arg_len + 1); - FASTCOPY (argp, thr_me->the_printed_command + thr_me->command_string_index, arg_len); - thr_me->command_string_index += arg_len; + FASTCOPY (argp, the_printed_command + command_string_index, arg_len); + command_string_index += arg_len; if (free_argp) free (argp); } } - thr_me->the_printed_command[thr_me->command_string_index] = '\0'; + the_printed_command[command_string_index] = '\0'; } #else /* We have support for varargs. */ @@ -794,14 +794,14 @@ if (argp) { the_printed_command_resize (arg_len + 1); - FASTCOPY (argp, thr_me->the_printed_command + thr_me->command_string_index, arg_len); - thr_me->command_string_index += arg_len; + FASTCOPY (argp, the_printed_command + command_string_index, arg_len); + command_string_index += arg_len; if (free_argp) free (argp); } } - thr_me->the_printed_command[thr_me->command_string_index] = '\0'; + the_printed_command[command_string_index] = '\0'; } #endif /* HAVE_VARARGS_H */ @@ -811,19 +811,19 @@ the_printed_command_resize (length) int length; { - if (!thr_me->the_printed_command) + if (!the_printed_command) { the_printed_command_size = length + 1; - thr_me->the_printed_command = xmalloc (the_printed_command_size); - thr_me->command_string_index = 0; + the_printed_command = xmalloc (the_printed_command_size); + command_string_index = 0; } - else if ((thr_me->command_string_index + length) >= the_printed_command_size) + else if ((command_string_index + length) >= the_printed_command_size) { int new; - new = thr_me->command_string_index + length + 1; + new = command_string_index + length + 1; new = new + 2 * PRINTED_COMMAND_GROW_SIZE - 1; new -= new % PRINTED_COMMAND_GROW_SIZE; the_printed_command_size = new; - thr_me->the_printed_command = xrealloc (thr_me->the_printed_command, the_printed_command_size); + the_printed_command = xrealloc (the_printed_command, the_printed_command_size); } } Index: shell.c =================================================================== RCS file: /cvsroot/winbash/winbash/shell.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- shell.c 10 Mar 2002 20:33:03 -0000 1.3 +++ shell.c 10 Mar 2002 21:45:13 -0000 1.4 @@ -190,7 +190,7 @@ static int quiet = 0; /* Be quiet when starting up. */ static int make_login_shell = 0; /* Make this shell be a `-bash' shell. */ -int no_line_editing = 0; /* Don't do fancy line editing. */ +int no_line_editing_private = 0; /* Don't do fancy line editing. */ int no_brace_expansion = 0; /* Non-zero means no foo{a,b} -> fooa foob. */ int posixly_correct = 0; /* Non-zero means posix.2 superset. */ @@ -211,7 +211,7 @@ { "version", Int, &do_version, (char **)0x0 }, { "quiet", Int, &quiet, (char **)0x0 }, { "login", Int, &make_login_shell, (char **)0x0 }, - { "nolineediting", Int, &no_line_editing, (char **)0x0 }, + { "nolineediting", Int, &no_line_editing_private, (char **)0x0 }, { "nobraceexpansion", Int, &no_brace_expansion, (char **)0x0 }, { "posix", Int, &posixly_correct, (char **)0x0 }, { (char *)0x0, Int, (int *)0x0, (char **)0x0 } @@ -318,7 +318,7 @@ /* Fix for the `infinite process creation' bug when running shell scripts from startup files on System V. */ - thr_me->login_shell = make_login_shell = 0; + login_shell = make_login_shell = 0; /* If this shell has already been run, then reinitialize it to a vanilla state. */ @@ -344,14 +344,14 @@ yydebug = 0; - thr_me->shell_environment = env; + shell_environment = env; shell_name = argv[0]; dollar_vars[0] = savestring (shell_name); if (*shell_name == '-') { shell_name++; - thr_me->login_shell++; + login_shell++; } #if defined (JOB_CONTROL) @@ -408,8 +408,8 @@ /* If user supplied the "-login" flag, then set and invert LOGIN_SHELL. */ if (make_login_shell) { - thr_me->login_shell++; - thr_me->login_shell = -thr_me->login_shell; + login_shell++; + login_shell = -login_shell; } /* All done with full word options; do standard shell option parsing.*/ @@ -506,15 +506,15 @@ isatty (fileno (stdin)) && /* Input is a terminal and */ isatty (fileno (stdout)))) /* output is a terminal. */ { - thr_me->interactive_shell = startup_state = thr_me->interactive = 1; + interactive_shell = startup_state = interactive = 1; } else { #if defined (HISTORY) - history_expansion = thr_me->remember_on_history = 0; + history_expansion = remember_on_history = 0; #endif /* HISTORY */ - thr_me->interactive_shell = startup_state = thr_me->interactive = 0; - thr_me->no_line_editing = 1; + interactive_shell = startup_state = interactive = 0; + no_line_editing = 1; #if defined (JOB_CONTROL) job_control = 0; #endif /* JOB_CONTROL */ @@ -531,7 +531,7 @@ * of the getpw* functions, and it's set to be open across execs. That * means one for login, one for xterm, one for shelltool, etc. */ - if (thr_me->login_shell && thr_me->interactive_shell) + if (login_shell && interactive_shell) { for (i = 3; i < 20; i++) close (i); @@ -542,10 +542,10 @@ Variables from the environment are expected to be set, etc. */ shell_initialize (); - if (thr_me->interactive_shell) + if (interactive_shell) { char *term = getenv ("TERM"); - thr_me->no_line_editing |= term && (STREQ (term, "emacs")); + no_line_editing |= term && (STREQ (term, "emacs")); } top_level_arg_index = arg_index; @@ -574,18 +574,16 @@ /* Execute the start-up scripts. */ - if (!thr_me->interactive_shell) + if (!interactive_shell) { - makunbound ("PS1", thr_me->shell_variables); - makunbound ("PS2", thr_me->shell_variables); - thr_me->interactive = 0; - + makunbound ("PS1", shell_variables); + makunbound ("PS2", shell_variables); + interactive = 0; } else { change_flag ('i', FLAG_ON); - thr_me->interactive = 1; - + interactive = 1; } if (!locally_skip_execution) @@ -627,7 +625,7 @@ } /* Do the things that should be done only for interactive shells. */ - if (thr_me->interactive_shell) + if (interactive_shell) { /* Set up for checking for presence of mail. */ remember_mail_dates (); @@ -739,14 +737,14 @@ #endif /* !BUFFERED_INPUT */ - if (!thr_me->interactive_shell || (!isatty (fd))) + if (!interactive_shell || (!isatty (fd))) { #if defined (HISTORY) history_expansion = 0; - thr_me->remember_on_history = 0; + remember_on_history = 0; #endif /* HISTORY */ - thr_me->interactive = thr_me->interactive_shell = 0; - thr_me->no_line_editing = 1; + interactive = interactive_shell = 0; + no_line_editing = 1; #if defined (JOB_CONTROL) set_job_control (0); @@ -761,7 +759,7 @@ fclose (default_input); } } - else if (!thr_me->interactive) + else if (!interactive) /* In this mode, bash is reading a script from stdin, which is a pipe or redirected file. */ #if defined (BUFFERED_INPUT) @@ -781,7 +779,7 @@ } #if defined (BUFFERED_INPUT) - if (!thr_me->interactive) + if (!interactive) unset_nodelay_mode (default_buffered_input); else unset_nodelay_mode (fileno (stdin)); @@ -790,12 +788,12 @@ #endif /* !BUFFERED_INPUT */ /* with_input_from_stdin really means `with_input_from_readline' */ - if (thr_me->interactive && !thr_me->no_line_editing) + if (interactive && !no_line_editing) with_input_from_stdin (); else #if defined (BUFFERED_INPUT) { - if (!thr_me->interactive) + if (!interactive) with_input_from_buffered_stream (default_buffered_input, dollar_vars[0]); else with_input_from_stream (default_input, dollar_vars[0]); @@ -816,14 +814,14 @@ exit_shell: /* Do trap[0] if defined. */ if (signal_is_trapped (0)) - thr_me->last_command_exit_value = run_exit_trap (); + last_command_exit_value = run_exit_trap (); #if defined (PROCESS_SUBSTITUTION) unlink_fifo_list (); #endif /* PROCESS_SUBSTITUTION */ #if defined (HISTORY) - if (thr_me->interactive && thr_me->remember_on_history) + if (interactive && remember_on_history) maybe_save_shell_history (); #endif /* HISTORY */ @@ -847,12 +845,12 @@ #if defined (__NT_VC__) { - int last_command_exit_value = thr_me->last_command_exit_value; + int the_last_command_exit_value = last_command_exit_value; nt_cleanup (); #endif /* __NT_VC__ */ /* Always return the exit status of the last command to our parent. */ - exit (last_command_exit_value); + exit (the_last_command_exit_value); #if defined (__NT_VC__) } #endif /* __NT_VC__ */ @@ -871,7 +869,7 @@ { if (!posixly_correct) { - if (thr_me... [truncated message content] |
From: kevin s. <xk...@us...> - 2002-03-10 21:42:19
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv2917 Modified Files: Makefile Log Message: added TAGS target, some small cleanup Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile 9 Mar 2002 16:58:09 -0000 1.4 +++ Makefile 10 Mar 2002 21:42:16 -0000 1.5 @@ -44,7 +44,7 @@ %.obj: %.c $(RM) $@ - cl.exe -c $(CPPFLAGS) $(CFLAGS) /Fo$@ $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) /Fo$@ $< BUILTIN_SRCS = \ builtins/mkbuiltins.c \ @@ -163,6 +163,11 @@ $(LIB_GLOB_SRCS) \ $(WINBASH_SRCS) +# used for builing tags +CSOURCES = $(BASH-SRCS) +# FIXME -- this could be a little more specific. +HSOURCES = $(wildcard *.h lib/readline/*.h builtins/*.h dum_inc/*.h) + BASH-OBJS = $(BASH-SRCS:%.c=%.obj) LDLIBS += builtins/builtins.lib @@ -187,7 +192,9 @@ $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $@ $< clean: - $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb + $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb \ + newversion.pdb newversion.ilk \ + TAGS cd builtins ; $(MAKE) clean .distribution: @@ -364,3 +371,6 @@ flags.h general.h hash.h input.h jobs.h make_cmd.h maxpath.h \ memalloc.h nt_types.h quit.h shell.h siglist.h stdc.h subst.h \ unwind_prot.h variables.h + +TAGS: $(CSOURCES) $(HSOURCES) + etags --ignore-indentation --members --declarations --output=$@ $? |
From: kevin s. <xk...@us...> - 2002-03-10 20:33:06
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv18107 Modified Files: .build shell.c version.h Log Message: non-interactive shells were thinking that they were indeed interactive. i don't know why we never saw a problem with this before -- probably fixed something else that was broken during the patching from 1.14.2->1.14.3. i noticed this when running make (which spawns a lot of sub-shells) - i kept seeing "exit" get printed out. Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- .build 10 Mar 2002 15:54:10 -0000 1.4 +++ .build 10 Mar 2002 20:33:03 -0000 1.5 @@ -1 +1 @@ -1 +2 Index: shell.c =================================================================== RCS file: /cvsroot/winbash/winbash/shell.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- shell.c 9 Mar 2002 16:05:42 -0000 1.2 +++ shell.c 10 Mar 2002 20:33:03 -0000 1.3 @@ -578,7 +578,7 @@ { makunbound ("PS1", thr_me->shell_variables); makunbound ("PS2", thr_me->shell_variables); - thr_me->interactive = 1; + thr_me->interactive = 0; } else Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- version.h 10 Mar 2002 15:54:10 -0000 1.3 +++ version.h 10 Mar 2002 20:33:03 -0000 1.4 @@ -8,9 +8,9 @@ #define PATCHLEVEL 3 /* The last built version of this shell. */ -#define BUILDVERSION 1 +#define BUILDVERSION 2 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.3(1) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.3(2) GNU" |
From: Enrico B. <enr...@us...> - 2002-03-10 15:54:14
|
Update of /cvsroot/winbash/winbash/builtins In directory usw-pr-cvs1:/tmp/cvs-serv26197/builtins Modified Files: Makefile bind.def echo.def enable.def fc.def hash.def help.def history.def setattr.def type.def ulimit.def umask.def Log Message: re-added inclusion of nt_types in builtins Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile 9 Mar 2002 04:17:14 -0000 1.2 +++ Makefile 10 Mar 2002 15:54:10 -0000 1.3 @@ -25,40 +25,37 @@ CPPFLAGS += -D_DEBUG endif -srcdir = . -VPATH = .:$(srcdir) - .SUFFIXES: .SUFFIXES: .def .c .obj # How to make a .obj file from a .def file. .def.obj: $(RM) $@ - ./$(MKBUILTINS) $(DIRECTDEFINE) $< + ./$(MKBUILTINS) -D '' $(DIRECTDEFINE) $< $(CC) -c $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) $*.c # $(RM) $*.c # How to make a .c file from a .def file. .def.c: $(RM) $@ - ./$(MKBUILTINS) $(DIRECTDEFINE) $< + ./$(MKBUILTINS) -D '' $(DIRECTDEFINE) $< .c.obj: $(RM) $@ $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -DEFS = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \ - $(srcdir)/builtin.def $(srcdir)/cd.def $(srcdir)/colon.def \ - $(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \ - $(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \ - $(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \ - $(srcdir)/fg_bg.def $(srcdir)/hash.def $(srcdir)/help.def \ - $(srcdir)/history.def $(srcdir)/jobs.def $(srcdir)/kill.def \ - $(srcdir)/let.def $(srcdir)/read.def $(srcdir)/return.def \ - $(srcdir)/set.def $(srcdir)/setattr.def $(srcdir)/shift.def \ - $(srcdir)/source.def $(srcdir)/suspend.def $(srcdir)/test.def \ - $(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \ - $(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \ - $(srcdir)/inlib.def +DEFS = alias.def bind.def break.def \ + builtin.def cd.def colon.def \ + command.def declare.def echo.def \ + enable.def eval.def getopts.def \ + exec.def exit.def fc.def \ + fg_bg.def hash.def help.def \ + history.def jobs.def kill.def \ + let.def read.def return.def \ + set.def setattr.def shift.def \ + source.def suspend.def test.def \ + times.def trap.def type.def \ + ulimit.def umask.def wait.def \ + inlib.def STATIC_SOURCE = common.c getopt.c bashgetopt.c getopt.h @@ -77,8 +74,8 @@ ./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \ -noproduction $(DIRECTDEFINE) $(DEFS) -$(MKBUILTINS): $(srcdir)/mkbuiltins.c ../config.h - $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $(MKBUILTINS) $(srcdir)/mkbuiltins.c +$(MKBUILTINS): mkbuiltins.c ../config.h + $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $(MKBUILTINS) mkbuiltins.c ulimit.obj: ulimit.def pipesize.h Index: bind.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/bind.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bind.def 9 Mar 2002 16:05:42 -0000 1.3 +++ bind.def 10 Mar 2002 15:54:11 -0000 1.4 @@ -52,6 +52,10 @@ #include <readline/history.h> #include "bashgetopt.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + static int query_bindings (); extern int bash_readline_initialized; Index: echo.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/echo.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- echo.def 9 Mar 2002 04:20:36 -0000 1.2 +++ echo.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -58,6 +58,10 @@ # define VALID_ECHO_OPTIONS "n" #endif /* !V9_ECHO */ +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* Print the words in LIST to standard output. If the first word is `-n', then don't print a trailing newline. We also support the echo syntax from Version 9 unix systems. */ Index: enable.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/enable.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- enable.def 9 Mar 2002 04:20:36 -0000 1.2 +++ enable.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -35,6 +35,10 @@ #include "../builtins.h" #include "common.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + #define ENABLED 1 #define DISABLED 2 Index: fc.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/fc.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- fc.def 9 Mar 2002 04:20:36 -0000 1.2 +++ fc.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -62,6 +62,10 @@ #include <readline/history.h> #include "bashgetopt.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* Not all systems declare ERRNO in errno.h... and some systems #define it! */ #if !defined (errno) extern int errno; Index: hash.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/hash.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- hash.def 9 Mar 2002 04:20:36 -0000 1.2 +++ hash.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -48,6 +48,10 @@ #include "common.h" #include "../execute_cmd.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + extern int dot_found_in_search; void Index: help.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/help.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- help.def 9 Mar 2002 04:20:36 -0000 1.2 +++ help.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -39,6 +39,10 @@ # define FNM_NOMATCH 1 #endif /* USE_GLOB_LIBRARY */ +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* Print out a list of the known functions in the shell, and what they do. If LIST is supplied, print out the list which matches for each pattern specified. */ Index: history.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/history.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- history.def 9 Mar 2002 04:20:36 -0000 1.2 +++ history.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -44,6 +44,10 @@ #include "../bashhist.h" #include <readline/history.h> +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* History. Arg of -w FILENAME means write file, arg of -r FILENAME means read file. Arg of N means only display that many items. */ Index: setattr.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/setattr.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- setattr.def 9 Mar 2002 16:05:42 -0000 1.3 +++ setattr.def 10 Mar 2002 15:54:11 -0000 1.4 @@ -25,6 +25,10 @@ #include "common.h" #include "bashgetopt.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + extern int array_needs_making; extern char *this_command_name; Index: type.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/type.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- type.def 9 Mar 2002 04:20:36 -0000 1.2 +++ type.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -52,6 +52,10 @@ #include "common.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + extern STRING_INT_ALIST word_token_alist[]; /* For each word in LIST, find out what the shell is going to do with Index: ulimit.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/ulimit.def,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ulimit.def 9 Mar 2002 16:05:42 -0000 1.3 +++ ulimit.def 10 Mar 2002 15:54:11 -0000 1.4 @@ -73,6 +73,10 @@ # include <limits.h> #endif +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* Check for the most basic symbols. If they aren't present, this system's <sys/resource.h> isn't very useful to us. */ #if !defined (RLIMIT_FSIZE) || defined (GETRLIMIT_MISSING) Index: umask.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/umask.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- umask.def 9 Mar 2002 04:20:36 -0000 1.2 +++ umask.def 10 Mar 2002 15:54:11 -0000 1.3 @@ -38,6 +38,10 @@ #include "../posixstat.h" #include "common.h" +#if defined (__NT_VC__) +#include "../nt_types.h" +#endif + /* **************************************************************** */ /* */ /* UMASK Builtin and Helpers */ |
From: Enrico B. <enr...@us...> - 2002-03-10 15:54:14
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv26197 Modified Files: .build version.h Log Message: re-added inclusion of nt_types in builtins Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- .build 9 Mar 2002 16:58:09 -0000 1.3 +++ .build 10 Mar 2002 15:54:10 -0000 1.4 @@ -1 +1 @@ -10 +1 Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- version.h 9 Mar 2002 16:58:09 -0000 1.2 +++ version.h 10 Mar 2002 15:54:10 -0000 1.3 @@ -8,9 +8,9 @@ #define PATCHLEVEL 3 /* The last built version of this shell. */ -#define BUILDVERSION 10 +#define BUILDVERSION 1 /* A version string for use by sccs and the what command. */ -#define SCCSVERSION "@(#)Bash version 1.14.3(10) GNU" +#define SCCSVERSION "@(#)Bash version 1.14.3(1) GNU" |
From: Enrico B. <enr...@us...> - 2002-03-09 16:58:12
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv26871 Modified Files: .build .distribution .machine Makefile newversion.c version.h Log Message: applied newversion.exe changes to create build/release versions Index: .build =================================================================== RCS file: /cvsroot/winbash/winbash/.build,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- .build 9 Mar 2002 04:43:15 -0000 1.2 +++ .build 9 Mar 2002 16:58:09 -0000 1.3 @@ -1 +1 @@ -7 +10 Index: .distribution =================================================================== RCS file: /cvsroot/winbash/winbash/.distribution,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- .distribution 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ .distribution 9 Mar 2002 16:58:09 -0000 1.2 @@ -1 +1 @@ -1.14 +1.14 Index: .machine =================================================================== RCS file: /cvsroot/winbash/winbash/.machine,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- .machine 9 Mar 2002 04:43:15 -0000 1.2 +++ .machine 9 Mar 2002 16:58:09 -0000 1.3 @@ -1 +1,2 @@ -bash last made for a i386 running NT + + last made for a i386 running Windows_NT \ No newline at end of file Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile 9 Mar 2002 04:17:14 -0000 1.3 +++ Makefile 9 Mar 2002 16:58:09 -0000 1.4 @@ -4,8 +4,9 @@ # by default creates a debuggable version of bash.exe (sh.exe) # type 'make RELEASE=1' if you do not want debugging info in the exe # +srcdir = . HERE=$(shell pwd) - +CC = cl.exe -nologo DEFS = -nologo -DMAINTAINER="\"no...@wi...\"" DEFS += -DHOSTTYPE="i386" -DOSTYPE="NT" -DWIN32 -D_CONSOLE DEFS += -DProgram=bash -DINITIALIZE_SIGLIST -DHAVE_VFPRINTF -DHAVE_UNISTD_H @@ -23,6 +24,8 @@ CPPFLAGS += $(DEFS) CFLAGS = -MT -W2 +Machine=i386 + LDFLAGS += -nologo -incremental:no -subsystem:console -machine:IX86 @@ -180,9 +183,29 @@ builtins/builtins.lib: $(BUILTIN_DEFS) cd builtins ; $(MAKE) +newversion.exe: newversion.c + $(CC) $(CPPFLAGS) $(CPPDEFS) $(CFLAGS) -o $@ $< + clean: $(RM) $(BASH-OBJS) y.tab.c y.tab.h bash.exe sh.exe bash.pdb cd builtins ; $(MAKE) clean + +.distribution: + ./newversion.exe -dir $(srcdir) -dist `./bash.exe -c 'echo $$BASH_VERSION'` + +.build: $(SOURCES) newversion.exe + if ./newversion.exe -dir $(srcdir) -build; then mv -f newversion.h version.h; fi + @echo + @echo " ***************************************************" + @echo " * *" + @echo " * Making Bash-`cat $(srcdir)/.distribution`.`cat $(srcdir)/.patchlevel` for a $(Machine) running $(OS)" + @echo " * *" + @echo " ***************************************************" + @echo + @echo "$(Program) last made for a $(Machine) running $(OS)" >.machine + +version.h: newversion.exe + if ./newversion.exe -dir $(srcdir) -build; then mv -f newversion.h version.h; fi y.tab.c: parse.y cd bison && $(HERE)/bison/bison.exe -d -o ../$@ ../$< Index: newversion.c =================================================================== RCS file: /cvsroot/winbash/winbash/newversion.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- newversion.c 9 Mar 2002 16:05:42 -0000 1.2 +++ newversion.c 9 Mar 2002 16:58:09 -0000 1.3 @@ -20,6 +20,8 @@ with Bash; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define FOPEN(name, mode) fopen(name, mode); + #include <sys/types.h> #include "posixstat.h" #include <stdio.h> Index: version.h =================================================================== RCS file: /cvsroot/winbash/winbash/version.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- version.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ version.h 9 Mar 2002 16:58:09 -0000 1.2 @@ -1,16 +1,16 @@ -/* Version control for the shell. This file gets changed when you say - `make newversion' to the Makefile. It is created by newversion.aux. */ - -/* The distribution version number of this shell. */ -#define DISTVERSION "1.14" - -/* The patch level of this version of the shell. */ -#define PATCHLEVEL 2 - -/* The last built version of this shell. */ -#define BUILDVERSION 14 - -/* A version string for use by sccs and the what command. */ - -#define SCCSVERSION "@(#)Bash version 1.14.2(14) GNU" - +/* Version control for the shell. This file gets changed when you say + `make newversion' to the Makefile. It is created by newversion.aux. */ + +/* The distribution version number of this shell. */ +#define DISTVERSION "1.14" + +/* The patch level of this version of the shell. */ +#define PATCHLEVEL 3 + +/* The last built version of this shell. */ +#define BUILDVERSION 10 + +/* A version string for use by sccs and the what command. */ + +#define SCCSVERSION "@(#)Bash version 1.14.3(10) GNU" + |
Update of /cvsroot/winbash/winbash/builtins In directory usw-pr-cvs1:/tmp/cvs-serv14844/builtins Modified Files: bind.def common.c exec.def exit.def read.def reserved.def setattr.def shift.def source.def ulimit.def Log Message: Applied 1.14.3 diffs from GNU bash Index: bind.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/bind.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bind.def 9 Mar 2002 04:20:36 -0000 1.2 +++ bind.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -162,7 +162,7 @@ { if (rl_read_init_file (initfile) != 0) { - builtin_error ("cannot read %s: %s\n", initfile, strerror (errno)); + builtin_error ("cannot read %s: %s", initfile, strerror (errno)); BIND_RETURN (EXECUTION_FAILURE); } } @@ -181,6 +181,9 @@ rl_set_keymap (saved_keymap); bind_exit: + if (saved_keymap) + rl_set_keymap (saved_keymap); + rl_outstream = old_rl_outstream; return (return_code); } Index: common.c =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/common.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- common.c 9 Mar 2002 04:20:36 -0000 1.2 +++ common.c 9 Mar 2002 16:05:42 -0000 1.3 @@ -48,7 +48,8 @@ extern int no_symbolic_links; extern int indirection_level, startup_state; extern int hashing_disabled; -/* extern int variable_context; */ +/* extern int last_command_exit_value; + extern int variable_context; */ extern char *this_command_name, *shell_name; extern COMMAND *global_command; extern HASH_TABLE *hashed_filenames; @@ -620,7 +621,9 @@ goto out; case DISCARD: - run_unwind_frame ("pe_dispose"); + dispose_command (command); + run_unwind_frame ("pe_dispose"); + thr_me->last_command_exit_value = 1; continue; default: Index: exec.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/exec.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- exec.def 9 Mar 2002 04:20:36 -0000 1.2 +++ exec.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -47,7 +47,7 @@ #if !defined (errno) extern int errno; #endif /* !errno */ - +//extern int interactive, subshell_environment; extern REDIRECT *redirection_undo_list; int @@ -128,6 +128,7 @@ restore_original_signals (); #if defined (JOB_CONTROL) + if (thr_me->subshell_environment == 0) end_job_control (); #endif /* JOB_CONTROL */ @@ -151,8 +152,12 @@ if (command) free (command); - if (!thr_me->interactive && !find_variable ("no_exit_on_failed_exec")) - exit (exit_value); + if (thr_me->subshell_environment || + (!thr_me->interactive && !find_variable ("no_exit_on_failed_exec"))) + exit (exit_value); + + initialize_traps (); + reinitialize_signals (); #if defined (JOB_CONTROL) restart_job_control (); Index: exit.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/exit.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- exit.def 9 Mar 2002 04:20:36 -0000 1.2 +++ exit.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -1,5 +1,5 @@ This file is exit.def, from which is created exit.c. -It implements the builtins "bye" and "exit", and "logout" in Bash. +It implements the builtins "exit", and "logout" in Bash. Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. @@ -37,6 +37,7 @@ #include "builtext.h" /* for jobs_builtin */ static int exit_or_logout (); +static int sourced_logout = 0; int exit_builtin (list) @@ -64,7 +65,7 @@ { if (!thr_me->login_shell && thr_me->interactive) { - builtin_error ("Not login shell: use `exit' or `bye'"); + builtin_error ("Not login shell: use `exit'"); return (EXECUTION_FAILURE); } else @@ -116,7 +117,7 @@ exit_value = thr_me->last_command_exit_value; /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ - if (thr_me->login_shell) + if (thr_me->login_shell && sourced_logout++ == 0) maybe_execute_file ("~/.bash_logout", 1); thr_me->last_command_exit_value = exit_value; Index: read.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/read.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- read.def 9 Mar 2002 04:20:36 -0000 1.2 +++ read.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -38,6 +38,8 @@ #include "common.h" #include <errno.h> +#define issep(c) (strchr (ifs_chars, (c)) != (char *)0) + static int stream_close (); extern int interrupt_immediately; @@ -57,11 +59,12 @@ { register char *varname; int size, c, i, raw_mode, pass_next, saw_escape, retval; - char *input_string, *orig_input_string, *ifs_chars; + char *input_string, *orig_input_string, *ifs_chars, *t; #if !defined(__NT_VC__) FILE *input_stream; int fildes; #endif + SHELL_VAR *var; i = 0; /* Index into the string that we are reading. */ raw_mode = 0; /* Not reading raw input be default. */ @@ -90,6 +93,9 @@ /* We need unbuffered input from stdin. So we make a new stream with the same file descriptor as stdin, then unbuffer it. */ + var = find_variable ("IFS"); + ifs_chars = var ? value_cell (var) : " \t\n"; + ifs_chars = get_string_value ("IFS"); input_string = xmalloc (size = 128); @@ -175,16 +181,13 @@ if (c == EOF) { retval = EXECUTION_FAILURE; - input_string[0] = '\0'; + /* input_string[0] = '\0'; */ } else retval = EXECUTION_SUCCESS; if (!list) { - SHELL_VAR *var; - char *t; - if (saw_escape) { t = dequote_string (input_string); @@ -198,20 +201,28 @@ } else { - SHELL_VAR *var; - char *t; /* This code implements the Posix.2 spec for splitting the words read and assigning them to variables. If $IFS is unset, we use the default value of " \t\n". */ - if (!ifs_chars) - ifs_chars = ""; - orig_input_string = input_string; - while (list->next) + + /* Remove IFS white space at the beginning of the input string. If + $IFS is null, no field splitting is performed. */ + for (t = input_string; *ifs_chars && spctabnl (*t) && issep (*t); t++) + ; + input_string = t; + + for (; list->next; list = list->next) { char *e, *t1; varname = list->word->word; + if (legal_identifier (varname) == 0) + { + builtin_error ("%s: not a legal variable name", varname); + free (orig_input_string); + return (EXECUTION_FAILURE); + } /* If there are more variables than words read from the input, the remaining variables are set to the empty string. */ @@ -243,10 +254,14 @@ if (t) free (t); - - list = list->next; } + if (legal_identifier (list->word->word) == 0) + { + builtin_error ("%s: not a legal variable name", list->word->word); + free (orig_input_string); + return (EXECUTION_FAILURE); + } if (saw_escape) { t = dequote_string (input_string); Index: reserved.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/reserved.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- reserved.def 9 Mar 2002 04:20:36 -0000 1.2 +++ reserved.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -28,6 +28,21 @@ the COMMANDS are executed. $END +$BUILTIN select +$SHORT_DOC select NAME [in WORDS ... ;] do COMMANDS; done +The WORDS are expanded, generating a list of words. The +set of expanded words is printed on the standard error, each +preceded by a number. If `in WORDS' is not present, `in "$@"' +is assumed. The PS3 prompt is then displayed and a line read +from the standard input. If the line consists of the number +corresponding to one of the displayed words, then NAME is set +to that word. If the line is empty, WORDS and the prompt are +redisplayed. If EOF is read, the command completes. Any other +value read causes NAME to be set to null. The line read is saved +in the variable REPLY. COMMANDS are executed after each selection +until a break or return command is executed. +$END + $BUILTIN case $SHORT_DOC case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac Selectively execute COMMANDS based upon WORD matching PATTERN. The @@ -79,9 +94,9 @@ job specification with a `&' places the job in the background. $END -$BUILTIN Variables +$BUILTIN variables $DOCNAME variable_help -$SHORT_DOC Some variable names and meanings +$SHORT_DOC variables - Some variable names and meanings BASH_VERSION The version numbers of this Bash. CDPATH A colon separated list of directories to search when the argument to `cd' is not found in the current @@ -136,7 +151,4 @@ or set to any other value than those above means to save all lines on the history list. #endif /* HISTORY */ -#if defined (JOB_CONTROL) -notify Notify of job termination immediately. -#endif $END Index: setattr.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/setattr.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- setattr.def 9 Mar 2002 04:20:36 -0000 1.2 +++ setattr.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -108,6 +108,10 @@ if (attribute & att_exported) array_needs_making = 1; + /* Cannot undo readonly status. */ + if (undo && (attribute & att_readonly)) + attribute &= ~att_readonly; + while (list) { #ifndef __NT_VC__ Index: shift.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/shift.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- shift.def 9 Mar 2002 04:20:36 -0000 1.2 +++ shift.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -44,10 +44,11 @@ shift_builtin (list) WORD_LIST *list; { - int times = get_numeric_arg (list); - int number, r; + int times, number; WORD_LIST *args; + times = get_numeric_arg (list); + if (!times) return (EXECUTION_SUCCESS); @@ -61,12 +62,10 @@ number = list_length (args); dispose_words (args); - r = EXECUTION_SUCCESS; - if (times > number) { - times = number; - r = EXECUTION_FAILURE; + builtin_error ("shift count must be <= $#"); + return (EXECUTION_FAILURE); } while (times-- > 0) @@ -91,5 +90,6 @@ else dollar_vars[9] = (char *)NULL; } - return (r); + + return (EXECUTION_SUCCESS); } Index: source.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/source.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- source.def 9 Mar 2002 04:20:36 -0000 1.2 +++ source.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -178,5 +178,10 @@ if (return_val) result = return_catch_value; } + else + { + builtin_error ("filename argument required"); + result = EXECUTION_FAILURE; + } return (result); } Index: ulimit.def =================================================================== RCS file: /cvsroot/winbash/winbash/builtins/ulimit.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ulimit.def 9 Mar 2002 04:20:36 -0000 1.2 +++ ulimit.def 9 Mar 2002 16:05:42 -0000 1.3 @@ -24,7 +24,7 @@ $BUILTIN ulimit $FUNCTION ulimit_builtin $DEPENDS_ON !MINIX -$SHORT_DOC ulimit [-SHacdmstfpnuv [limit]] +$SHORT_DOC ulimit [-SHacdfmstpnuv [limit]] Ulimit provides control over the resources available to processes started by the shell, on systems that allow such control. If an option is given, it is interpreted as follows: @@ -79,6 +79,14 @@ # undef HAVE_RESOURCE #endif +#if !defined (RLIMTYPE) +# define RLIMTYPE long +# define string_to_rlimtype string_to_long +# define print_rlimtype(n, nl) printf ("%ld%s", n, nl ? "\n" : "") +#endif + +static void print_long (); + /* **************************************************************** */ /* */ /* Ulimit builtin and Hacks. */ @@ -114,12 +122,12 @@ #define LIMIT_HARD 0x01 #define LIMIT_SOFT 0x02 -static long shell_ulimit (); -static long pipesize (); -static long open_files (); +static RLIMTYPE shell_ulimit (); +static RLIMTYPE pipesize (); +static RLIMTYPE open_files (); #if defined (HAVE_RESOURCE) -static long getmaxvm (); +static RLIMTYPE getmaxvm (); #endif /* HAVE_RESOURCE */ static void print_specific_limits (); @@ -135,7 +143,7 @@ static int canraise (cmd, current, new) int cmd; - long current, new; + RLIMTYPE current, new; { # if defined (HAVE_SETDTABLESIZE) if (cmd == u_NUM_OPEN_FILES) @@ -157,10 +165,11 @@ register char *s; int c, setting, cmd, mode, verbose_print, opt_eof; int all_limits, specific_limits; - long current_limit, real_limit, limit = -1L; long block_factor; + RLIMTYPE current_limit, real_limit, limit; c = mode = verbose_print = opt_eof = 0; + limit = (RLIMTYPE)-1; do { @@ -290,7 +299,7 @@ if (STREQ (s, "unlimited")) limit = RLIM_INFINITY; else if (all_digits (s)) - limit = string_to_long (s); + limit = string_to_rlimtype (s); else { builtin_error ("bad non-numeric arg `%s'", s); @@ -329,7 +338,7 @@ } #endif /* !HAVE_RESOURCE */ - if (shell_ulimit (cmd, real_limit, 1, mode) == -1L) + if (shell_ulimit (cmd, real_limit, 1, mode) == (RLIMTYPE)-1) { builtin_error ("cannot raise limit: %s", strerror (errno)); return (EXECUTION_FAILURE); @@ -342,7 +351,7 @@ if (current_limit < 0) builtin_error ("cannot get limit: %s", strerror (errno)); else if (current_limit != RLIM_INFINITY) - printf ("%ld\n", (current_limit / block_factor)); + print_rlimtype ((current_limit / block_factor), 1); else printf ("unlimited\n"); } @@ -365,10 +374,10 @@ This includes most USG systems. Chet Ramey supplied the BSD resource limit code. */ -static long +static RLIMTYPE shell_ulimit (which, newlim, setting, mode) int which, setting, mode; - long newlim; + RLIMTYPE newlim; { #if defined (HAVE_RESOURCE) struct rlimit limit; @@ -388,7 +397,7 @@ /* ulimit () returns a number that is in 512 byte blocks, thus we must multiply it by 512 to get back to bytes. This is false only under HP/UX 6.x. */ - long result; + RLIMTYPE result; result = ulimit (1, 0L); @@ -423,7 +432,7 @@ cmd = RLIMIT_RSS; # else /* !RLIMIT_RSS */ errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); # endif /* !RLIMIT_RSS */ goto do_ulimit; @@ -439,7 +448,7 @@ do_ulimit: if (getrlimit (cmd, &limit) != 0) - return (-1L); + return ((RLIMTYPE)-1); if (!setting) { @@ -475,7 +484,7 @@ if (setting) { errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); } return (pipesize ()); @@ -490,7 +499,7 @@ return (setdtablesize (newlim)); # else errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); # endif /* HAVE_SETDTABLESIZE */ #endif /* !HAVE_RESOURCE || !RLIMIT_NOFILE */ } @@ -501,7 +510,7 @@ if (setting) { errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); } else { @@ -509,7 +518,7 @@ return (getmaxvm (mode)); #else /* !HAVE_RESOURCE */ errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); #endif /* !HAVE_RESOURCE */ } @@ -519,17 +528,17 @@ goto do_ulimit; #else /* !HAVE_RESOURCE || !RLIMIT_NPROC */ errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); #endif /* !HAVE_RESOURCE || !RLIMIT_NPROC */ default: errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); } } #if defined (HAVE_RESOURCE) -static long +static RLIMTYPE getmaxvm (mode) int mode; { @@ -537,19 +546,19 @@ #if defined (RLIMIT_VMEM) if (getrlimit (RLIMIT_VMEM, &rl) < 0) - return (-1L); + return ((RLIMTYPE)-1); else return (((mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max) / 1024L); #else /* !RLIMIT_VMEM */ - unsigned long maxdata, maxstack; + RLIMTYPE maxdata, maxstack; if (getrlimit (RLIMIT_DATA, &rl) < 0) - return (-1L); + return ((RLIMTYPE)-1); else maxdata = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max; if (getrlimit (RLIMIT_STACK, &rl) < 0) - return (-1L); + return ((RLIMTYPE)-1); else maxstack = (mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max; @@ -559,12 +568,12 @@ } #endif /* HAVE_RESOURCE */ -static long +static RLIMTYPE open_files (mode) int mode; { #if !defined (RLIMIT_NOFILE) - return ((long)getdtablesize ()); + return ((RLIMTYPE)getdtablesize ()); #else struct rlimit rl; @@ -576,19 +585,19 @@ #endif } -static long +static RLIMTYPE pipesize () { #if defined (PIPE_BUF) /* This is defined on Posix systems. */ - return ((long) PIPE_BUF); + return ((RLIMTYPE) PIPE_BUF); #else # if defined (PIPESIZE) /* This is defined by running a program from the Makefile. */ - return ((long) PIPESIZE); + return ((RLIMTYPE) PIPESIZE); # else errno = EINVAL; - return (-1L); + return ((RLIMTYPE)-1); # endif /* PIPESIZE */ #endif /* PIPE_BUF */ } @@ -632,7 +641,7 @@ int i, mode; { struct rlimit rl; - long limit; + RLIMTYPE limit; getrlimit (limits[i].parameter, &rl); if (mode & LIMIT_HARD) @@ -643,7 +652,7 @@ if (limit == RLIM_INFINITY) printf ("unlimited\n"); else - printf ("%ld\n", limit / limits[i].block_factor); + print_rlimtype ((limit / limits[i].block_factor), 1); } static void @@ -666,25 +675,36 @@ int cmd, mode; { if (mode == 0) - mode |= LIMIT_SOFT; + mode = LIMIT_SOFT; #if defined (HAVE_RESOURCE) print_specific_bsd_limits (cmd, mode); #else /* !HAVE_RESOURCE */ if (cmd & u_FILE_SIZE) - printf ("%-25s%ld\n", - "file size (blocks)", ulimit (1, 0L) / ULIMIT_DIVISOR); + { + printf ("%-25s", "file size (blocks)"); + print_rlimtype ((ulimit (1, 0L) / ULIMIT_DIVISOR), 1); + } #endif /* !HAVE_RESOURCE */ if (cmd & u_PIPE_SIZE) - printf ("%-25s%ld\n", "pipe size (512 bytes)", (pipesize () / 512)); + { + printf ("%-25s", "pipe size (512 bytes)"); + print_rlimtype ((pipesize () / 512), 1); + } if (cmd & u_NUM_OPEN_FILES) - printf ("%-25s%ld\n", "open files", open_files (mode)); + { + printf ("%-25s", "open files"); + print_rlimtype (open_files (mode), 1); + } #if defined (HAVE_RESOURCE) if (cmd & u_MAX_VIRTUAL_MEM) - printf ("%-25s%ld\n", "virtual memory (kbytes)", getmaxvm (mode)); + { + printf ("%-25s", "virtual memory (kbytes)"); + print_rlimtype (getmaxvm (mode), 1); + } #endif /* HAVE_RESOURCE */ } |
From: Enrico B. <enr...@us...> - 2002-03-09 16:06:15
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv14844 Modified Files: .patchlevel bashline.c braces.c error.c execute_cmd.c expr.c general.c general.h input.h jobs.c jobs.h machines.h newversion.c parse.y shell.c siglist.h subst.c test.c trap.c trap.h variables.c Log Message: Applied 1.14.3 diffs from GNU bash Index: .patchlevel =================================================================== RCS file: /cvsroot/winbash/winbash/.patchlevel,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- .patchlevel 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ .patchlevel 9 Mar 2002 16:05:41 -0000 1.2 @@ -1 +1 @@ -2 +3 Index: bashline.c =================================================================== RCS file: /cvsroot/winbash/winbash/bashline.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- bashline.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ bashline.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -23,6 +23,7 @@ #include <stdio.h> #include "bashansi.h" +#include <readline/rlconf.h> #include <readline/readline.h> #include <readline/history.h> #include "shell.h" @@ -116,6 +117,7 @@ #if defined (VI_MODE) static void vi_edit_and_execute_command (); +extern char *rl_vi_comment_begin; #endif static Function *old_rl_startup_hook = (Function *) NULL; @@ -181,6 +183,10 @@ rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap); rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap); +#if defined (VI_MODE) + rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap); +#endif + #if defined (BRACE_COMPLETION) rl_add_defun ("complete-into-braces", bash_brace_completion, -1); rl_bind_key_in_map ('{', bash_brace_completion, emacs_meta_keymap); @@ -264,6 +270,7 @@ { tilde_initialize (); rl_attempted_completion_function = attempt_shell_completion; + rl_completion_entry_function = (Function *)NULL; rl_directory_completion_hook = bash_directory_completion_hook; rl_ignore_some_completions_function = (Function *)filename_completion_ignore; } @@ -388,7 +395,11 @@ static void initialize_hostname_list () { - //char *temp = get_string_value ("hostname_completion_file"); +// char *temp; + +// temp = get_string_value ("HOSTFILE"); +// if (!temp) +// temp = get_string_value ("hostname_completion_file"); //if (!temp) // temp = ETCHOSTS; @@ -396,6 +407,7 @@ //snarf_hosts_from_file (temp); doEnumHosts(NULL); sort_hostname_list (); + if (hostname_list) hostname_list_initialized++; } @@ -1156,7 +1168,7 @@ int state; char *text; { - char **matches = (char **)NULL; + static char **matches = (char **)NULL; static char *orig_start, *filename_text = (char *)NULL; static int cmd_index, start_len; Index: braces.c =================================================================== RCS file: /cvsroot/winbash/winbash/braces.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- braces.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ braces.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -226,7 +226,7 @@ /* A backslash escapes the next character. This allows backslash to escape the quote character in a double-quoted string. */ - if (c == '\\' && (quoted == '"' || quoted == '`')) + if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`')) { pass_next = 1; continue; @@ -290,7 +290,7 @@ return (copy_array (arr2)); if (!arr2) - return (arr1); + return (copy_array (arr1)); len1 = array_len (arr1); len2 = array_len (arr2); Index: error.c =================================================================== RCS file: /cvsroot/winbash/winbash/error.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- error.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ error.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -18,6 +18,7 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> +#include <sys/types.h> #include <fcntl.h> #if defined (HAVE_VFPRINTF) Index: execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/execute_cmd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- execute_cmd.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ execute_cmd.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -1117,8 +1117,11 @@ /* If we were explicitly placed in a subshell with (), we need to do the `shell cleanup' things, such as running traps[0]. */ - if (user_subshell) - run_exit_trap (); + if (user_subshell && signal_is_trapped (0)) + { + thr_me->last_command_exit_value = return_code; + return_code = run_exit_trap (); + } #if defined (_MT) return return_code; @@ -1169,7 +1172,7 @@ loop_level++; identifier = for_command->name->word; - list = releaser = expand_words (for_command->map_list); + list = releaser = expand_words_no_vars (for_command->map_list); begin_unwind_frame ("for"); add_unwind_protect (dispose_words, releaser); @@ -1253,6 +1256,8 @@ register WORD_LIST *l; register int i; + if (list == 0) + return (0); i = ind; l = list; while (l && --i) @@ -1288,11 +1293,17 @@ int ind, row, elem_len, pos, cols, rows; int first_column_indices_len, other_indices_len; + if (list == 0) + { + putc ('\n', stderr); + return; + } + cols = COLS / max_elem_len; if (cols == 0) cols = 1; - rows = list_len / cols + (list_len % cols != 0); - cols = list_len / rows + (list_len % rows != 0); + rows = list_len ? list_len / cols + (list_len % cols != 0) : 1; + cols = list_len ? list_len / rows + (list_len % rows != 0) : 1; if (rows == 1) { @@ -1412,7 +1423,14 @@ /* command and arithmetic substitution, parameter and variable expansion, word splitting, pathname expansion, and quote removal. */ - list = releaser = expand_words (select_command->map_list); + list = releaser = expand_words_no_vars (select_command->map_list); + list_len = list_length (list); + if (list == 0 || list_len == 0) + { + if (list) + dispose_words (list); + return (EXECUTION_SUCCESS); + } begin_unwind_frame ("select"); add_unwind_protect (dispose_words, releaser); @@ -1429,7 +1447,6 @@ if (select_command->flags & CMD_IGNORE_RETURN) select_command->action->flags |= CMD_IGNORE_RETURN; - list_len = list_length (list); ps3_prompt = get_string_value ("PS3"); if (!ps3_prompt) ps3_prompt = "#? "; @@ -3586,15 +3603,17 @@ char *name; int flags; { - char *path_list = (char *) NULL; + char *path_list; SHELL_VAR *var; /* Search for the value of PATH in both the temporary environment, and in the regular list of variables. */ if (var = find_variable_internal ("PATH", 1)) path_list = value_cell (var); + else + path_list = (char *)NULL; - if (!path_list) + if (path_list == 0 || *path_list == '\0') return (savestring (name)); return (find_user_command_in_path (name, path_list, flags)); Index: expr.c =================================================================== RCS file: /cvsroot/winbash/winbash/expr.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- expr.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ expr.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -72,8 +72,11 @@ Here is a macro which accepts newlines, tabs and spaces as whitespace. */ #define cr_whitespace(c) (whitespace(c) || ((c) == '\n')) +extern char *this_command_name; + static char *expression = (char *) NULL; /* The current expression */ static char *tp = (char *) NULL; /* token lexical position */ +static char *lasttp; static int curtok = 0; /* the current token */ static int lasttok = 0; /* the previous token */ static int assigntok = 0; /* the OP in OP= */ @@ -655,7 +658,7 @@ if (c) cp++; - tp = cp - 1; + lasttp = tp = cp - 1; if (c == '\0') { @@ -758,8 +761,16 @@ evalerror (msg) char *msg; { - builtin_error ("%s: %s (remainder of expression is \"%s\")", - expression, msg, (tp && *tp) ? tp : ""); + char *name, *t; + + name = this_command_name; + if (name == 0) + name = get_name_for_error (); + for (t = expression; whitespace (*t); t++) + ; + fprintf (stderr, "%s: %s%s: %s (remainder of expression is \"%s\")", + name, t, + msg, (lasttp && *lasttp) ? lasttp : ""); LONGJMP (evalbuf, 1); } Index: general.c =================================================================== RCS file: /cvsroot/winbash/winbash/general.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- general.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ general.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -215,6 +215,53 @@ return (neg ? -ret : ret); } +#if defined (RLIMTYPE) +RLIMTYPE +string_to_rlimtype (s) + char *s; +{ + RLIMTYPE ret = 0; + int neg = 0; + + while (s && *s && whitespace (*s)) + s++; + if (*s == '-' || *s == '+') + { + neg = *s == '-'; + s++; + } + for ( ; s && *s && digit (*s); s++) + ret = (ret * 10) + digit_value (*s); + return (neg ? -ret : ret); +} + +void +print_rlimtype (n, addnl) + RLIMTYPE n; + int addnl; +{ + char s[sizeof (RLIMTYPE) * 3 + 1]; + int len = sizeof (RLIMTYPE) * 3 + 1; + + if (n == 0) + { + printf ("0%s", addnl ? "\n" : ""); + return; + } + + if (n < 0) + { + putchar ('-'); + n = -n; + } + + s[--len] = '\0'; + for ( ; n != 0; n /= 10) + s[--len] = n % 10 + '0'; + printf ("%s%s", s + len, addnl ? "\n" : ""); +} +#endif /* RLIMTYPE */ + /* Return 1 if this token is a legal shell `identifier'; that is, it consists solely of letters, digits, and underscores, and does not begin with a digit. */ Index: general.h =================================================================== RCS file: /cvsroot/winbash/winbash/general.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- general.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ general.h 9 Mar 2002 16:05:41 -0000 1.2 @@ -63,6 +63,10 @@ #define digit_value(c) ((c) - '0') #endif +/* Definitions used in subst.c and by the `read' builtin for field + splitting. */ +#define spctabnl(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') + #if !defined (__STDC__) && !defined (strchr) extern char *strchr (), *strrchr (); #endif /* !strchr */ @@ -111,7 +115,7 @@ #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0) /* More convenience definitions that possibly save system or libc calls. */ -#define STRLEN(s) ((s)[0] ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0) +#define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0) #define FREE(s) do { if (s) free (s); } while (0) #define MEMBER(c, s) (((c) && !(s)[1] && c == s[0]) || (member(c, s))) @@ -206,6 +210,11 @@ #if !defined (strerror) extern char *strerror __P((int)); +#endif + +#if defined (RLIMTYPE) +extern RLIMTYPE string_to_rlimtype __P((char *)); +extern void print_rlimtype __P((RLIMTYPE, int)); #endif #if !defined (HAVE_STRCASECMP) Index: input.h =================================================================== RCS file: /cvsroot/winbash/winbash/input.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- input.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ input.h 9 Mar 2002 16:05:41 -0000 1.2 @@ -33,11 +33,13 @@ #endif /* _FUNCTION_DEF */ /* Some stream `types'. */ +#define st_none 0 #define st_stream 1 #define st_string 2 +#define st_stdin 3 #if defined (BUFFERED_INPUT) -#define st_bstream 3 +#define st_bstream 4 /* Possible values for b_flag. */ #define B_EOF 0x1 Index: jobs.c =================================================================== RCS file: /cvsroot/winbash/winbash/jobs.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- jobs.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ jobs.c 9 Mar 2002 16:05:41 -0000 1.2 @@ -117,7 +117,7 @@ extern int interactive, interactive_shell, asynchronous_notification; extern int subshell_environment; extern int posixly_correct, no_symbolic_links, shell_level; -extern int interrupt_immediately, last_command_exit_value; +extern int interrupt_immediately;//, last_command_exit_value; extern int loop_level, breaking; extern Function *this_shell_builtin; extern char *shell_name, *this_command_name; @@ -320,6 +320,16 @@ } } +void +cleanup_the_pipeline () +{ + if (the_pipeline) + { + discard_pipeline (the_pipeline); + the_pipeline = (PROCESS *)NULL; + } +} + /* Start building a pipeline. */ void start_pipeline () @@ -1383,7 +1393,7 @@ if (interrupt_immediately || (this_shell_builtin && this_shell_builtin == wait_builtin)) { - last_command_exit_value = EXECUTION_FAILURE; + thr_me->last_command_exit_value = EXECUTION_FAILURE; restore_sigint_handler (); interrupt_state++; QUIT; @@ -1435,7 +1445,7 @@ if (!job_control) old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); - termination_state = last_command_exit_value; + termination_state = thr_me->last_command_exit_value; /* If we say wait_for (), then we have a record of this child somewhere. If this child and all of its peers are not running, then don't @@ -1486,34 +1496,31 @@ } } + /* XXX - the linux people say to check for JOBSTATE (job) == JSTOPPED */ if (child->running || ((job != NO_JOB) && (JOBSTATE (job) == JRUNNING))) { -#if defined (WAITPID_BROKEN) /* SCOv4 */ - sigset_t suspend_set; - sigemptyset (&suspend_set); - sigsuspend (&suspend_set); -#else /* !WAITPID_BROKEN */ -# if defined (MUST_UNBLOCK_CHILD) /* SCO */ +#if defined (_POSIX_VERSION) struct sigaction act, oact; - sigset_t nullset, chldset; - sigemptyset (&nullset); - sigemptyset (&chldset); - sigprocmask (SIG_SETMASK, &nullset, &chldset); act.sa_handler = SIG_DFL; sigemptyset (&act.sa_mask); - sigemptyset (&oact.sa_mask); act.sa_flags = 0; + sigaction (SIGCHLD, &act, &oact); -# endif - waiting_for_job = 1; - waitchld (0); - waiting_for_job = 0; -# if defined (MUST_UNBLOCK_CHILD) +#else + SigHandler *ihandler; + + ihandler = set_signal_handler (SIGCHLD, SIG_DFL); +#endif /* !_POSIX_VERSION */ + + flush_child (0); + +#if defined (_POSIX_VERSION) sigaction (SIGCHLD, &oact, (struct sigaction *)NULL); - sigprocmask (SIG_SETMASK, &chldset, (sigset_t *)NULL); -# endif -#endif /* !WAITPID_BROKEN */ +#else + set_signal_handler (SIGCHLD, ihandler); +#endif /* !_POSIX_VERSION */ + goto wait_loop; } @@ -1573,6 +1580,19 @@ } } + /* If job control is enabled, the job was started with job + control, the job was the foreground job, and it was killed + by SIGINT, then print a newline to compensate for the kernel + printing the ^C without a trailing newline. */ + if (job_control && (jobs[job]->flags & J_JOBCONTROL) && + (jobs[job]->flags & J_FOREGROUND) && + WIFSIGNALED (child->status) && + WTERMSIG (child->status) == SIGINT) + { + putchar ('\n'); + fflush (stdout); + } + notify_and_cleanup (); } else @@ -2023,6 +2043,7 @@ { WAIT status; PROCESS *child; + int any_tstped = 0; pid_t pid; int call_set_current = 0, last_stopped_job = NO_JOB; int children_exited = 0, flag; @@ -2122,7 +2143,7 @@ /* If SIGINT is trapped, set the exit status so that the trap handler can see it. */ if (signal_is_trapped (SIGINT)) - last_command_exit_value = process_exit_status + thr_me->last_command_exit_value = process_exit_status (jobs[job]->pipe->status); /* If the signal is trapped, let the trap handler @@ -2156,7 +2177,7 @@ children_exited++; } } - while ((s || sigchld) && pid > (pid_t)0); + while (sig && pid > (pid_t)0); /* If a job was running and became stopped, then set the current job. Otherwise, don't change a thing. */ @@ -2179,7 +2200,7 @@ trap_command = savestring (trap_list[SIGCHLD]); begin_unwind_frame ("SIGCHLD trap"); - unwind_protect_int (last_command_exit_value); + unwind_protect_int (thr_me->last_command_exit_value); unwind_protect_int (last_made_pid); unwind_protect_int (interrupt_immediately); unwind_protect_int (freeze_jobs_list); Index: jobs.h =================================================================== RCS file: /cvsroot/winbash/winbash/jobs.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- jobs.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ jobs.h 9 Mar 2002 16:05:42 -0000 1.2 @@ -282,9 +282,9 @@ #endif /* !_POSIX_VERSION */ /* System calls. */ -#if !defined (Solaris) && !defined (USGr4_2) && !defined (__BSD_4_4__) +#if !defined (SunOS5) && !defined (USGr4_2) && !defined (__BSD_4_4__) extern pid_t fork (), getpid (), getpgrp (); -#endif /* !Solaris && !USGr4_2 */ +#endif /* !SunOS5 && !USGr4_2 && !__BSD_4_4__ */ /* Stuff from the jobs.c file. */ extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp; @@ -295,6 +295,7 @@ extern void making_children __P((void)); extern void stop_making_children __P((void)); +extern void cleanup_the_pipeline __P((void)); extern void start_pipeline __P((void)); extern int stop_pipeline __P((int, COMMAND *)); extern void delete_job __P((int)); Index: machines.h =================================================================== RCS file: /cvsroot/winbash/winbash/machines.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- machines.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ machines.h 9 Mar 2002 16:05:42 -0000 1.2 @@ -31,11 +31,11 @@ various machine specific entries. */ /* If this file is being processed with Gcc, then the user has Gcc. */ -#if defined (__GNUC__) && !defined (NeXT) +#if defined (__GNUC__) && !defined (NeXT) && !defined (__FreeBSD__) # if !defined (HAVE_GCC) # define HAVE_GCC # endif /* HAVE_GCC */ -#endif /* __GNUC__ && !NeXT */ +#endif /* __GNUC__ && !NeXT && !__FreeBSD__ */ /* Assume that all machines have the getwd () system call. We unset it for USG systems. */ @@ -85,7 +85,8 @@ #if defined (sparc) && defined (__NetBSD__) # define M_MACHINE "sun4" # define M_OS "NetBSD" -# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \ + -DRLIMTYPE=quad_t # define SYSDEP_LDFLAGS -static # define HAVE_SYS_SIGLIST # define HAVE_SETLINEBUF @@ -205,7 +206,8 @@ # else /* !MIPSEL */ # define M_MACHINE "vax" # endif /* !MIPSEL */ -# define SYSDEP_CFLAGS -DBSD_GETPGRP -DTERMIOS_MISSING -DTERMIOS_LDISC +# define SYSDEP_CFLAGS -DBSD_GETPGRP -DTERMIOS_MISSING -DTERMIOS_LDISC \ + -DINT_GROUPS_ARRAY # define M_OS "Ultrix" # define HAVE_DIRENT # define VOID_SIGHANDLER @@ -584,6 +586,7 @@ # define HAVE_RESOURCE # endif # define HAVE_STRCASECMP +# define GCC_STANDARD # undef HAVE_GETWD # undef HAVE_GETCWD # undef USE_GNU_MALLOC @@ -676,7 +679,11 @@ # endif /* __STDC__ */ # define SYSDEP_CFLAGS ISC_SYSDEPS ISC_POSIX ISC_EXTRA # undef HAVE_GETWD -# undef HAVE_GETCWD +# if !defined (ISC_4) +# undef HAVE_GETCWD +# else +# undef HAVE_RESOURCE +# endif /* ISC_4 */ # endif /* isc386 */ /* Xenix386 machine (with help from Ronald Khoo <ro...@ro...>). */ @@ -716,11 +723,11 @@ # define done386 # define M_MACHINE "i386" # define M_OS "SCO" -# define SCO_CFLAGS -DUSG -DUSGr3 -DNO_DEV_TTY_JOB_CONTROL -DPGRP_PIPE +# define SCO_CFLAGS -DUSG -DUSGr3 -DPGRP_PIPE # if defined (SCOv4) # define SYSDEP_CFLAGS SCO_CFLAGS # else /* !SCOv4 */ -# define SYSDEP_CFLAGS SCO_CFLAGS -DBROKEN_SIGSUSPEND -DOPENDIR_NOT_ROBUST +# define SYSDEP_CFLAGS SCO_CFLAGS -DOPENDIR_NOT_ROBUST # endif /* !SCOv4 */ # define HAVE_VFPRINTF # define VOID_SIGHANDLER @@ -772,7 +779,8 @@ # define done386 # define M_MACHINE "i386" # define M_OS "NetBSD" -# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \ + -DRLIMTYPE=quad_t # define HAVE_SYS_SIGLIST # define HAVE_SETLINEBUF # define HAVE_GETGROUPS @@ -788,7 +796,11 @@ # define done386 # define M_MACHINE "i386" # define M_OS "FreeBSD" -# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# if __FreeBSD__ > 1 +# define SYSDEP_CFLAGS -D__BSD_4_4__ -DRLIMTYPE=quad_t +# else +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# endif # define HAVE_SYS_SIGLIST # define HAVE_SETLINEBUF # define HAVE_GETGROUPS @@ -797,6 +809,7 @@ # define VOID_SIGHANDLER # define HAVE_DIRENT # define HAVE_STRCASECMP +# define GCC_STANDARD # endif /* !done386 && __FreeBSD__ */ /* Jolitz 386BSD running on a 386 or 486. */ @@ -993,6 +1006,7 @@ # define HAVE_RESOURCE # endif # define HAVE_STRCASECMP +# define GCC_STANDARD # undef HAVE_GETWD # undef HAVE_GETCWD # undef HAVE_DIRENT_H @@ -1010,7 +1024,8 @@ # define M_MACHINE MACHINE # define M_OS "NetBSD" /* os/netbsd.h */ -# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \ + -DRLIMTYPE=quad_t # define HAVE_SYS_SIGLIST # define HAVE_SETLINEBUF # define HAVE_GETGROUPS @@ -1018,6 +1033,7 @@ # define HAVE_STRERROR # define VOID_SIGHANDLER # define HAVE_DIRENT +# define HAVE_STRCASECMP #endif /* m68k && __NetBSD__ */ /* ************************ */ @@ -1096,7 +1112,7 @@ # else /* !HPUX_USG */ /* All of the other operating systems need HPUX to be defined. */ -# define HPUX_EXTRA -DHPUX -DHAVE_GETHOSTNAME -DUSG +# define HPUX_EXTRA -DHPUX -Dhpux -DHAVE_GETHOSTNAME -DUSG /* HPUX 6.2 .. 6.5 require -lBSD for getwd (), and -lPW for alloca (). */ # if defined (HPUX_6) @@ -1122,10 +1138,13 @@ # define M_OS "hpux_8" # if !defined (__GNUC__) # undef HAVE_ALLOCA +# define HPUX_ANSI +O3 -Aa -D_HPUX_SOURCE +# else +# define HPUX_ANSI # endif # undef HAVE_GETWD # undef USE_GNU_MALLOC -# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS +# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS HPUX_ANSI # endif /* HPUX_8 */ /* HP-UX 9.0 reportedly fixes the alloca problems present in the 8.0 @@ -1134,11 +1153,14 @@ # define M_OS "hpux_9" # if !defined (__GNUC__) # undef HAVE_ALLOCA +# define HPUX_ANSI +O3 -Ae +# else +# define HPUX_ANSI # endif # undef HAVE_GETWD # undef USE_GNU_MALLOC # undef HAVE_RESOURCE -# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS -DHAVE_GETHOSTNAME +# define HPUX_CFLAGS -DNO_SBRK_DECL -DHAVE_SOCKETS -DHAVE_GETHOSTNAME HPUX_ANSI # endif /* HPUX_9 */ # endif /* !HPUX_USG */ @@ -1568,10 +1590,25 @@ /* ******************************************** */ /* */ -/* System V Release 4 on the Commodore Amiga */ +/* Commodore Amiga */ /* */ /* ******************************************** */ -#if defined (amiga) +#if defined (amiga) && defined (__NetBSD__) +# define M_MACHINE "amiga" +# define M_OS "NetBSD" +# define SYSDEP_CFLAGS -DOPENDIR_NOT_ROBUST -DINT_GROUPS_ARRAY \ + -DRLIMTYPE=quad_t +# define HAVE_SYS_SIGLIST +# define HAVE_SETLINEBUF +# define HAVE_GETGROUPS +# define HAVE_VFPRINTF +# define HAVE_STRERROR +# define VOID_SIGHANDLER +# define HAVE_DIRENT +# define HAVE_STRCASECMP +#endif /* amiga && __NetBSD__ */ + +#if defined (amiga) && !defined (M_MACHINE) # define M_MACHINE "amiga" # define M_OS "USG" # define SYSDEP_CFLAGS -DUSGr4 @@ -1883,6 +1920,7 @@ /* */ /* ************************ */ #if defined (cray) +# include <sys/param.h> # if defined (Cray1) || defined (Cray2) # define M_MACHINE "Cray" # define CRAY_STACK @@ -1894,7 +1932,7 @@ # if defined (CrayYMP) && !defined (M_MACHINE) # define M_MACHINE "CrayYMP" # if RELEASE_LEVEL >= 7000 -# define CRAY_STACK -DCRAY_STACKSEG_END=GETB67 +# define CRAY_STACK -DCRAY_STACKSEG_END=_getb67 # else # define CRAY_STACK -DCRAY_STACKSEG_END=getb67 # endif /* RELEASE_LEVEL < 7000 */ @@ -1904,7 +1942,8 @@ # define CRAY_STACK # endif # define M_OS "Unicos" -# define SYSDEP_CFLAGS -DUSG -DPGRP_PIPE -DOPENDIR_NOT_ROBUST CRAY_STACK +# define SYSDEP_CFLAGS -DUSG -DPGRP_PIPE -DOPENDIR_NOT_ROBUST \ + -DHAVE_BCOPY CRAY_STACK # define HAVE_VFPRINTF # define HAVE_MULTIPLE_GROUPS # define VOID_SIGHANDLER @@ -2093,8 +2132,6 @@ AFS - The Andrew File System is being used AFS_CREATE_BUG - AFS has a bug with file creation if O_CREAT is specified - BROKEN_SIGSUSPEND - sigsuspend(2) does not work to wake up processes - on SIGCHLD BSD_GETPGRP - getpgrp(2) takes a pid argument, a la 4.3 BSD HAVE_BCOPY - bcopy(3) exists and works as in BSD HAVE_GETDTABLESIZE - getdtablesize(2) exists and works correctly @@ -2111,7 +2148,6 @@ of integers MEMMOVE_MISSING - the system does not have memmove(3) MKFIFO_MISSING - named pipes do not work or mkfifo(3) is missing - NO_DEV_TTY_JOB_CONTROL - system can't do job control on /dev/tty NO_SBRK_DECL - don't declare sbrk as extern char *sbrk() in lib/malloc/malloc.c OPENDIR_NOT_ROBUST - opendir(3) allows you to open non-directory files @@ -2176,6 +2212,10 @@ if it cannot grok the -l<lib> flag, or both. */ /* # define LD_HAS_NO_DASH_L */ +/* Define GCC_STANDARD if the standard `cc' is gcc and you don't want + to use the compiler named `gcc' for some reason. */ +/* # define GCC_STANDARD */ + # if defined (LD_HAS_NO_DASH_L) # undef SEARCH_LIB_NEEDS_SPACE # endif /* LD_HAS_NO_DASH_L */ Index: newversion.c =================================================================== RCS file: /cvsroot/winbash/winbash/newversion.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- newversion.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ newversion.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -21,7 +21,7 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/types.h> -#include <sys/stat.h> +#include "posixstat.h" #include <stdio.h> char *progname; Index: parse.y =================================================================== RCS file: /cvsroot/winbash/winbash/parse.y,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- parse.y 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ parse.y 9 Mar 2002 16:05:42 -0000 1.2 @@ -821,16 +821,22 @@ give_terminal_to (shell_pgrp); #endif /* JOB_CONTROL */ - old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler); - interrupt_immediately++; + if (signal_is_ignored (SIGINT) == 0) + { + old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler); + interrupt_immediately++; + } if (!current_readline_prompt) current_readline_line = readline (""); else current_readline_line = readline (current_readline_prompt); - interrupt_immediately--; - set_signal_handler (SIGINT, old_sigint); + if (signal_is_ignored (SIGINT) == 0) + { + interrupt_immediately--; + set_signal_handler (SIGINT, old_sigint); + } /* Reset the prompt to whatever is in the decoded value of prompt_string_pointer. */ @@ -873,9 +879,12 @@ { INPUT_STREAM location; - location.string = current_readline_line; - init_yy_io (yy_readline_get, yy_readline_unget, - st_string, "readline stdin", location); + if (bash_input.type != st_stdin && stream_on_stack (st_stdin) == 0) + { + location.string = current_readline_line; + init_yy_io (yy_readline_get, yy_readline_unget, + st_stdin, "readline stdin", location); + } } #else /* !READLINE */ @@ -1051,6 +1060,20 @@ free (saver); } } + +/* Return 1 if a stream of type TYPE is saved on the stack. */ +int +stream_on_stack (type) + int type; +{ + register STREAM_SAVER *s; + + for (s = stream_list; s; s = s->next) + if (s->bash_input.type == type) + return 1; + return 0; +} + /* * This is used to inhibit alias expansion and reserved word recognition @@ -1264,9 +1287,9 @@ /* `+2' in case the final character in the buffer is a newline. */ if (indx + 2 > buffer_size) if (!buffer_size) - line_buffer = xmalloc (buffer_size = 400); + line_buffer = xmalloc (buffer_size = 128); else - line_buffer = xrealloc (line_buffer, buffer_size += 400); + line_buffer = xrealloc (line_buffer, buffer_size += 128); /* IF REMOVE_QUOTED_NEWLINES is non-zero, we are reading a here document with an unquoted delimiter. In this case, @@ -1397,9 +1420,9 @@ #endif /* !JOB_CONTROL */ #if defined (READLINE) - if (thr_me->interactive && thr_me->no_line_editing) + if (thr_me->interactive && bash_input.type != st_string && thr_me->no_line_editing) #else - if (thr_me->interactive) + if (thr_me->interactive && bash_input.type != st_string) #endif print_prompt (); @@ -1529,7 +1552,7 @@ return (EOF); } - return (c); + return ((unsigned char)c); } /* Put C back into the input for the shell. */ @@ -2615,12 +2638,25 @@ octal_string[3] = '\0'; n = read_octal (octal_string); + temp = xmalloc (3); - temp = savestring ("\\"); - if (n != -1) + if (n == CTLESC || n == CTLNUL) + { + string += 3; + temp[0] = CTLESC; + temp[1] = n; + temp[2] = '\0'; + } + else if (n == -1) + { + temp[0] = '\\'; + temp[1] = '\0'; + } + else { string += 3; temp[0] = n; + temp[1] = '\0'; } c = 0; @@ -2767,7 +2803,7 @@ /* Perform variable and parameter expansion and command substitution on the prompt string. */ - list = expand_string (result, 1); + list = expand_string_unsplit (result, 1); free (result); result = string_list (list); dispose_words (list); Index: shell.c =================================================================== RCS file: /cvsroot/winbash/winbash/shell.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- shell.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ shell.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -78,7 +78,7 @@ extern char *dist_version; extern int patch_level, build_version; -extern int last_command_exit_value; +//extern int last_command_exit_value; extern int return_catch_flag; extern jmp_buf return_catch; extern int need_here_doc, current_command_line_count, line_number; @@ -815,7 +815,8 @@ exit_shell: /* Do trap[0] if defined. */ - run_exit_trap (); + if (signal_is_trapped (0)) + thr_me->last_command_exit_value = run_exit_trap (); #if defined (PROCESS_SUBSTITUTION) unlink_fifo_list (); @@ -874,7 +875,8 @@ { /* We don't execute .bashrc for login shells. */ no_rc++; - maybe_execute_file (SYS_PROFILE, 1); + if (no_profile == 0) + maybe_execute_file (SYS_PROFILE, 1); } if (thr_me->login_shell && !no_profile) @@ -918,7 +920,7 @@ /* Try a TMB suggestion. If running a script, then execute the file mentioned in the ENV variable. */ - if (!privileged_mode && sourced_env++ == 0 && + if (!privileged_mode && sourced_env++ == 0 && act_like_sh == 0 && (posixly_correct || !thr_me->interactive_shell)) { char *env_file = (char *)NULL; @@ -1079,8 +1081,9 @@ /* Some kind of throw to top_level has occured. */ case FORCE_EOF: case EXITPROG: + return last_command_exit_value = 127; case DISCARD: - return 0; + return last_command_exit_value = 1; default: programming_error ("Bad jump %d", code); } @@ -1106,7 +1109,7 @@ unlink_fifo_list (); #endif /* PROCESS_SUBSTITUTION */ - if (thr_me->interactive_shell) + if (thr_me->interactive_shell && signal_is_ignored (SIGINT) == 0) set_signal_handler (SIGINT, sigint_sighandler); if (code != NOT_JUMPED) @@ -1129,6 +1132,7 @@ dispose_command (current_command); current_command = (COMMAND *)NULL; } + thr_me->last_command_exit_value = 1; break; default: @@ -1229,7 +1233,7 @@ /* Allow the execution of a random command just before the printing of each primary prompt. If the shell variable PROMPT_COMMAND is set then the value of it is the command to execute. */ - if (thr_me->interactive) + if (thr_me->interactive && bash_input.type != st_string) { char *command_to_execute; @@ -1437,6 +1441,13 @@ #endif } +void +reinitialize_signals () +{ + initialize_terminating_signals (); + initialize_job_signals (); +} + /* A structure describing a signal that terminates the shell if not caught. The orig_handler member is present so children can reset these signals back to their original handlers. */ @@ -1555,7 +1566,7 @@ #endif /* HISTORY */ #if defined (JOB_CONTROL) - if (thr_me->interactive && thr_me->login_shell && sig == SIGHUP) + if (thr_me->interactive && sig == SIGHUP) hangup_all_jobs (); end_job_control (); #endif /* JOB_CONTROL */ Index: siglist.h =================================================================== RCS file: /cvsroot/winbash/winbash/siglist.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- siglist.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ siglist.h 9 Mar 2002 16:05:42 -0000 1.2 @@ -33,8 +33,8 @@ extern char *sys_siglist[]; #endif /* !Solaris && !Linux && !__BSD_4_4__ && !Minix && !NetBSD && !FreeBSD */ -#if !defined (strsignal) && !defined (Solaris) +#if !defined (strsignal) && !defined (Solaris) && !defined (NetBSD) # define strsignal(sig) (char *)sys_siglist[sig] -#endif /* !strsignal */ +#endif /* !strsignal && !Solaris && !NetBSD */ #endif /* _SIGLIST_H */ Index: subst.c =================================================================== RCS file: /cvsroot/winbash/winbash/subst.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- subst.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ subst.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -1966,6 +1966,7 @@ #if defined (JOB_CONTROL) old_pipeline_pgrp = pipeline_pgrp; pipeline_pgrp = shell_pgrp; + cleanup_the_pipeline (); pid = make_child ((char *) NULL, 1); if (pid == 0) { @@ -1988,8 +1989,6 @@ } #endif /* !JOB_CONTROL */ - set_sigint_handler (); - if (pid < 0) { internal_error ("cannot make a child for process substitution: %s", @@ -2017,6 +2016,8 @@ return (pathname); } + set_sigint_handler (); + #if defined (JOB_CONTROL) set_job_control (0); #endif /* JOB_CONTROL */ @@ -2111,6 +2112,7 @@ pid_t old_pipeline_pgrp = pipeline_pgrp; pipeline_pgrp = shell_pgrp; + cleanup_the_pipeline (); pid = make_child ((char *) NULL, 0); if (pid == 0) /* Reset the signal handlers in the child, but don't free the @@ -2149,6 +2151,7 @@ if (pid == 0) { + set_sigint_handler (); /* XXX */ # if defined (JOB_CONTROL) set_job_control (0); # endif @@ -2183,6 +2186,9 @@ remove_quoted_escapes (string); + /* Command substitution does not inherit the -e flag. */ + exit_immediately_on_error = 0; + /* Give command substitution a place to jump back to on failure, so we don't go back up to main (). */ result = SETJMP (top_level); @@ -2454,11 +2460,16 @@ else temp = savestring (value); - l = expand_string_leave_quoted (temp, quoted); + l = *temp ? expand_string_internal (temp, 0) : (WORD_LIST *)NULL; free (temp); - temp = string_list (l); - dispose_words (l); + if (l) + { + temp = string_list (l); + dispose_words (l); + } + else + temp = (char *)NULL; if (c == '-' || c == '+') return (temp); @@ -3080,7 +3091,7 @@ } else if (c != '+') temp = parameter_brace_expand_rhs - (name, value, c, 0); /* XXX was quoted, not 0 */ + (name, value, c, quoted); free (value); } break; @@ -3534,10 +3545,11 @@ temp_list = list_string (istring, " ", 1); else { - temp_list = make_word_list - (make_word (istring), (WORD_LIST *) NULL); - temp_list->word->quoted = - (quoted || (quoted_state == WHOLLY_QUOTED)); + WORD_DESC *tword; + tword = make_word (istring); + temp_list = make_word_list (tword, (WORD_LIST *)NULL); + tword->quoted = quoted || (quoted_state == WHOLLY_QUOTED); + tword->assignment = word->assignment; } } @@ -3597,15 +3609,11 @@ temp = string_extract_double_quoted (string, &tindex); sindex = tindex; - temp1 = string_quote_removal (temp, 1); /* XXX is this needed? */ - - FREE (temp); - - if (temp1) + if (temp) { - strcpy (r, temp1); + strcpy (r, temp); r += strlen (r); - free (temp1); + free (temp); } break; @@ -3967,7 +3975,10 @@ This does all of the substitutions: brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, - process substitution, word splitting, and pathname expansion. */ + process substitution, word splitting, and pathname expansion. + Words with the `quoted' or `assignment' bits set, or for which no + expansion is done, do not undergo word splitting. Words with the + `assignment' but set do not undergo pathname expansion. */ static WORD_LIST * expand_words_internal (list, do_vars) WORD_LIST *list; @@ -4103,7 +4114,9 @@ LONGJMP (top_level, FORCE_EOF); } - if (expanded_something) + /* Don't split assignment words, even when they do not precede a + command name. */ + if (expanded_something && tlist->word->assignment == 0) { t = word_list_split (expanded); dispose_words (expanded); @@ -4169,7 +4182,7 @@ /* If the word isn't quoted and there is an unquoted pattern matching character in the word, then glob it. */ - if (!tlist->word->quoted && + if (!tlist->word->quoted && !tlist->word->assignment && unquoted_glob_pattern_p (tlist->word->word)) { temp_list = shell_glob_filename (tlist->word->word); Index: test.c =================================================================== RCS file: /cvsroot/winbash/winbash/test.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- test.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ test.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -469,8 +469,10 @@ { advance (1); value = expr (); - if (argv[pos][0] != ')' || argv[pos][1]) - test_syntax_error ("')' expected, found %s\n", argv[pos]); + if (argv[pos] == 0) + test_syntax_error ("`)' expected\n"); + else if (argv[pos][0] != ')' || argv[pos][1]) + test_syntax_error ("`)' expected, found %s\n", argv[pos]); advance (0); return (TRUE == (value)); } Index: trap.c =================================================================== RCS file: /cvsroot/winbash/winbash/trap.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- trap.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ trap.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -42,6 +42,9 @@ #define SIG_HARD_IGNORE 0x2 /* Signal was ignored on shell entry. */ #define SIG_SPECIAL 0x4 /* Treat this signal specially. */ #define SIG_NO_TRAP 0x8 /* Signal cannot be trapped. */ +#define SIG_INPROGRESS 0x10 /* Signal handler currently executing. */ +#define SIG_CHANGED 0x20 /* Trap value changed in trap handler. */ +#define SIG_IGNORED 0x40 /* The signal is currently being ignored. */ /* An array of such flags, one for each signal, describing what the shell will do with a signal. */ @@ -117,13 +120,13 @@ /* Return the print name of this signal. */ char * -signal_name (signal) - int signal; +signal_name (sig) + int sig; { - if (signal >= NSIG) + if (sig >= NSIG || sig < 0) return ("bad signal number"); else - return (signal_names[signal]); + return (signal_names[sig]); } /* Turn a string into a signal number, or a number into @@ -174,7 +177,7 @@ /* Preserve $? when running trap. */ old_exit_value = thr_me->last_command_exit_value; - for (sig = 0; sig < NSIG; sig++) + for (sig = 1; sig < NSIG; sig++) { /* XXX this could be made into a counter by using while (pending_traps[sig]--) instead of the if statement. */ @@ -288,17 +291,15 @@ if (sigmodes[SIGINT] & SIG_HARD_IGNORE) return ((SigHandler *)SIG_IGN); - if (sigmodes[SIGINT] & SIG_TRAPPED) - { - if (trap_list[SIGINT] == (char *)IGNORE_SIG) - return ((SigHandler *)SIG_IGN); - else - return ((SigHandler *)set_signal_handler (SIGINT, trap_handler)); - } + else if (sigmodes[SIGINT] & SIG_IGNORED) + return ((SigHandler *)set_signal_handler (SIGINT, SIG_IGN)); + + else if (sigmodes[SIGINT] & SIG_TRAPPED) + return ((SigHandler *)set_signal_handler (SIGINT, trap_handler)); /* The signal is not trapped, so set the handler to the shell's special interrupt handler. */ - if (thr_me->interactive) /* XXX - was interactive_shell */ + else if (thr_me->interactive) /* XXX - was interactive_shell */ return (set_signal_handler (SIGINT, sigint_sighandler)); else return (set_signal_handler (SIGINT, termination_unwind_protect)); @@ -348,26 +349,39 @@ change_signal (sig, savestring (string)); } -/* If SIG has a string assigned to it, get rid of it. Then give it - VALUE. */ static void -change_signal (sig, value) +free_trap_command (sig) int sig; - char *value; { if ((sigmodes[sig] & SIG_TRAPPED) && trap_list[sig] && (trap_list[sig] != (char *)IGNORE_SIG) && (trap_list[sig] != (char *)DEFAULT_SIG) && (trap_list[sig] != (char *)IMPOSSIBLE_TRAP_HANDLER)) free (trap_list[sig]); - +} + +/* If SIG has a string assigned to it, get rid of it. Then give it + VALUE. */ +static void +change_signal (sig, value) + int sig; + char *value; +{ + free_trap_command (sig); trap_list[sig] = value; + sigmodes[sig] |= SIG_TRAPPED; + if (value == (char *)IGNORE_SIG) + sigmodes[sig] |= SIG_IGNORED; + else + sigmodes[sig] &= ~SIG_IGNORED; + if (sigmodes[sig] & SIG_INPROGRESS) + sigmodes[sig] |= SIG_CHANGED; } #define GET_ORIGINAL_SIGNAL(sig) \ - if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER) \ - get_original_signal (sig) + if (sig && sig < NSIG && original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER) \ + get_original_signal (sig) static void get_original_signal (sig) @@ -394,6 +408,14 @@ restore_default_signal (sig) int sig; { + if (sig == 0) + { + free_trap_command (sig); + trap_list[sig] = (char *)NULL; + sigmodes[sig] &= ~SIG_TRAPPED; + return; + } + GET_ORIGINAL_SIGNAL (sig); /* A signal ignored on entry to the shell cannot be trapped or reset, but @@ -444,24 +466,26 @@ /* Handle the calling of "trap 0". The only sticky situation is when the command to be executed includes an "exit". This is why we have to provide our own place for top_level to jump to. */ -void +int run_exit_trap () { /* Run the trap only if signal 0 is trapped and not ignored. */ - if ((sigmodes[0] & SIG_TRAPPED) && (trap_list[0] != (char *)IGNORE_SIG)) + if ((sigmodes[0] & SIG_TRAPPED) && + (trap_list[0] != (char *)IGNORE_SIG) && + (sigmodes[0] & SIG_INPROGRESS) == 0) { - char *trap_command = savestring (trap_list[0]); - int code, old_exit_value; - - old_exit_value = thr_me->last_command_exit_value; - change_signal (0, (char *)NULL); + char *trap_command; + int code; + + trap_command= savestring (trap_list[0]); + sigmodes[0] &= ~SIG_TRAPPED; + sigmodes[0] |= SIG_INPROGRESS; code = SETJMP(top_level); if (code == 0) parse_and_execute (trap_command, "trap", 0); - - thr_me->last_command_exit_value = old_exit_value; } + return (thr_me->last_command_exit_value); } /* Set the handler signal SIG to the original and free any trap @@ -512,7 +536,7 @@ { register int i; - for (i = 0; i < NSIG; i++) + for (i = 1; i < NSIG; i++) { if (sigmodes[i] & SIG_SPECIAL) reset_signal (i); @@ -535,7 +559,7 @@ register int i; reset_terminating_signals (); /* in shell.c */ - for (i = 0; i < NSIG; i++) + for (i = 1; i < NSIG; i++) { if (sigmodes[i] & SIG_SPECIAL) restore_signal (i); @@ -561,21 +585,26 @@ we are not currently running in the interrupt trap handler. */ if ((sigmodes[SIGINT] & SIG_TRAPPED) && (trap_list[SIGINT] != (char *)IGNORE_SIG) && - (trap_list[SIGINT] != (char *)IMPOSSIBLE_TRAP_HANDLER)) + (trap_list[SIGINT] != (char *)IMPOSSIBLE_TRAP_HANDLER) && + ((sigmodes[SIGINT] & SIG_INPROGRESS) == 0)) { - command = savestring (trap_list[SIGINT]); - - old_exit_value = thr_me->last_command_exit_value; saved_command = trap_list[SIGINT]; + sigmodes[SIGINT] |= SIG_INPROGRESS; + sigmodes[SIGINT] &= ~SIG_CHANGED; - trap_list[SIGINT] = (char *)IMPOSSIBLE_TRAP_HANDLER; + command = savestring (saved_command); + old_exit_value = thr_me->last_command_exit_value; parse_and_execute (command, "interrupt trap", 0); - - if (trap_list[SIGINT] == (char *)IMPOSSIBLE_TRAP_HANDLER) - trap_list[SIGINT] = saved_command; - thr_me->last_command_exit_value = old_exit_value; + + sigmodes[SIGINT] &= ~SIG_INPROGRESS; + + if (sigmodes[SIGINT] & SIG_CHANGED) + { + free (saved_command); + sigmodes[SIGINT] &= ~SIG_CHANGED; + } } } @@ -619,6 +648,13 @@ int sig; { return (sigmodes[sig] & SIG_SPECIAL); +} + +int +signal_is_ignored (sig) + int sig; +{ + return (sigmodes[sig] & SIG_IGNORED); } void Index: trap.h =================================================================== RCS file: /cvsroot/winbash/winbash/trap.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- trap.h 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ trap.h 9 Mar 2002 16:05:42 -0000 1.2 @@ -48,7 +48,7 @@ extern void set_signal __P((int, char *)); extern void restore_default_signal __P((int)); extern void ignore_signal __P((int)); -extern void run_exit_trap __P((void)); +extern int run_exit_trap __P((void)); extern void free_trap_strings __P((void)); extern void reset_signal_handlers __P((void)); extern void restore_original_signals __P((void)); @@ -60,5 +60,6 @@ extern int maybe_call_trap_handler __P((int)); extern int signal_is_trapped __P((int)); extern int signal_is_special __P((int)); +extern int signal_is_ignored __P((int)); #endif /* __TRAP_H__ */ Index: variables.c =================================================================== RCS file: /cvsroot/winbash/winbash/variables.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- variables.c 9 Mar 2002 03:39:12 -0000 1.1.1.1 +++ variables.c 9 Mar 2002 16:05:42 -0000 1.2 @@ -107,7 +107,7 @@ /* Make VAR be auto-exported. VAR is a pointer to a SHELL_VAR. */ #define set_auto_export(var) \ -{ var->attributes |= att_exported; array_needs_making = 1; } + do { var->attributes |= att_exported; array_needs_making = 1; } while (0) #if defined (HISTORY) # include "bashhist.h" @@ -355,7 +355,7 @@ /* Get the full pathname to THIS shell, and set the BASH variable to it. */ { - char *tname = find_user_command (shell_name); + char *tname; if ((thr_me->login_shell == 1) && ((*shell_name != '/') || !(isletter (*shell_name) && shell_name[1] == ':'))) { @@ -365,16 +365,38 @@ name = savestring (current_user.shell); } + else if (*shell_name == '/') + name = savestring (shell_name); else { - if (!tname) - name = make_absolute (shell_name, get_string_value ("PWD")); + int s; + + tname = find_user_command (shell_name); + if (tname == 0) + { + /* Try the current directory. If there is not an executable + there, just punt and use the login shell. */ + s = file_status (shell_name); + if (s & FS_EXECABLE) + { + tname = make_absolute (shell_name, get_string_value ("PWD")); + if (*shell_name == '.') + { + name = canonicalize_pathname (tname); + free (tname); + } + else + name = tname; + } + else + name = savestring (current_user.shell); + } else { name = full_pathname (tname); free (tname); } - } + } /* Make the exported environment variable SHELL be the user's login shell. Note that the `tset' command looks at this variable |
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:47
|
Update of /cvsroot/winbash/winbash/tests In directory usw-pr-cvs1:/tmp/cvs-serv14844/tests Modified Files: glob-test Log Message: Applied 1.14.3 diffs from GNU bash Index: glob-test =================================================================== RCS file: /cvsroot/winbash/winbash/tests/glob-test,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- glob-test 9 Mar 2002 04:43:16 -0000 1.2 +++ glob-test 9 Mar 2002 16:05:45 -0000 1.3 @@ -7,6 +7,7 @@ } TESTDIR=/tmp/glob-test +rm -rf $TESTDIR mkdir $TESTDIR cd $TESTDIR |
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:47
|
Update of /cvsroot/winbash/winbash/support In directory usw-pr-cvs1:/tmp/cvs-serv14844/support Modified Files: bashbug.sh mksysdefs Log Message: Applied 1.14.3 diffs from GNU bash Index: bashbug.sh =================================================================== RCS file: /cvsroot/winbash/winbash/support/bashbug.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bashbug.sh 9 Mar 2002 04:43:16 -0000 1.2 +++ bashbug.sh 9 Mar 2002 16:05:44 -0000 1.3 @@ -17,7 +17,7 @@ TEMP=/tmp/bashbug.$$ -BUGADDR=${1:-bu...@pr...} +BUGADDR=${1-b...@pr...} : ${EDITOR=emacs} @@ -29,7 +29,16 @@ UN=`uname -a` fi +if [ -f /usr/lib/sendmail ] ; then + RMAIL="/usr/lib/sendmail -t" +elif [ -f /usr/sbin/sendmail ] ; then + RMAIL="/usr/sbin/sendmail -t" +else + RMAIL=rmail +fi + cat > $TEMP <<EOF +From: ${USER} To: ${BUGADDR} Subject: [50 character or so descriptive subject here (for reference)] @@ -66,7 +75,7 @@ exit fi - rmail $BUGADDR < $TEMP || cat $TEMP >> $HOME/dead.bashbug + ${RMAIL} $BUGADDR < $TEMP || cat $TEMP >> $HOME/dead.bashbug fi exit 0 Index: mksysdefs =================================================================== RCS file: /cvsroot/winbash/winbash/support/mksysdefs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mksysdefs 9 Mar 2002 04:43:16 -0000 1.2 +++ mksysdefs 9 Mar 2002 16:05:44 -0000 1.3 @@ -174,6 +174,10 @@ MAKE_ANSI=true elif [ -d /etc/conf/kconfig.d ] && [ -f /usr/include/sys/limits.h ]; then SYSDEF="isc386" # This is a 386 running ISC? + ISCREL="ISC_$RELEASE" + echo "#if !defined ($ISCREL)" >>$sysdefs + echo "# define $ISCREL" >>$sysdefs + echo "#endif /* $ISCREL */" >>$sysdefs elif [ -f /etc/xlc.cfg ]; then if fgrep _IBMR2 /etc/xlc.cfg >/dev/null 2>&1; then SYSDEF=RISC6000 @@ -241,16 +245,9 @@ # What release of SCO Unix is this? if [ "$SYSDEF" = "" -a -f /bin/uname ]; then case `/bin/uname -X 2>/dev/null | grep '^Release' 2>/dev/null` in - *3.2v4.*) SCOREL=SCOv4 ;; - *) SCOREL= ;; + *3.2v4.*) SYSDEF=SCOv4 ;; + *) SYSDEF=SCO ;; esac - - if [ "$SCOREL" ]; then - echo "" >>$sysdefs - echo "#if !defined ($SCOREL)" >>$sysdefs - echo "# define $SCOREL" >>$sysdefs - echo "#endif /* !$SCOREL */" >>$sysdefs - fi fi # |
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:47
|
Update of /cvsroot/winbash/winbash/lib/tilde In directory usw-pr-cvs1:/tmp/cvs-serv14844/lib/tilde Modified Files: tilde.c Log Message: Applied 1.14.3 diffs from GNU bash Index: tilde.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/tilde/tilde.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- tilde.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ tilde.c 9 Mar 2002 16:05:44 -0000 1.2 @@ -19,8 +19,6 @@ along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "memalloc.h" - #if defined (HAVE_STRING_H) # include <string.h> #else /* !HAVE_STRING_H */ @@ -34,6 +32,7 @@ #endif /* HAVE_STDLIB_H */ #include "tilde.h" +#include <sys/types.h> #include <pwd.h> #if defined (USG) && !defined (HAVE_GETPW_DECLS) @@ -251,22 +250,16 @@ } else { - char u_name[257]; - struct passwd *user_entry; char *username; - int i, c; + struct passwd *user_entry; + int i; - username = u_name; - for (i = 1; c = dirname[i]; i++) - { - if (c == '/') - break; - else - username[i - 1] = c; - } + username = xmalloc (strlen (dirname)); + for (i = 1; dirname[i] && dirname[i] != '/'; i++) + username[i - 1] = dirname[i]; username[i - 1] = '\0'; - if (!(user_entry = getpwnam (username))) + if ((user_entry = getpwnam (username)) == 0) { /* If the calling program has a special syntax for expanding tildes, and we couldn't find a standard @@ -299,7 +292,8 @@ free (dirname); dirname = temp_name; } - endpwent (); + endpwent (); + free (username); } } return (dirname); |
Update of /cvsroot/winbash/winbash/lib/readline In directory usw-pr-cvs1:/tmp/cvs-serv14844/lib/readline Modified Files: complete.c display.c history.c keymaps.c readline.c rltty.c search.c tilde.c Log Message: Applied 1.14.3 diffs from GNU bash Index: complete.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/complete.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- complete.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ complete.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -21,6 +21,10 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + #include <stdio.h> #include <sys/types.h> #include <fcntl.h> @@ -592,8 +596,12 @@ /* Sort the items. */ /* It is safe to sort this array, because the lowest common denominator found in matches[0] will remain in place. */ - //for (i = 1; matches[i]; i++); - //qsort (matches, i, sizeof (char *), compare_strings); + for (i = 0; matches[i]; i++) + ; + /* Try sorting the array without matches[0], since we need it to + stay in place no matter what. */ + if (i) + qsort (matches+1, i-1, sizeof (char *), compare_strings); /* Remember the lowest common denominator for it may be unique. */ lowest_common = savestring (matches[0]); @@ -898,19 +906,18 @@ count = (len + (limit - 1)) / limit; /* Watch out for special case. If LEN is less than LIMIT, then - just do the inner printing loop. */ - if (len < limit) - count = 1; + just do the inner printing loop. + 0 < len <= limit implies count = 1. */ /* Sort the items if they are not already sorted. */ if (!rl_ignore_completion_duplicates) - qsort (matches, len, sizeof (char *), compare_strings); + qsort (matches + 1, len - 1, sizeof (char *), compare_strings); /* Print the sorted items, up-and-down alphabetically, like ls might. */ crlf (); - for (i = 1; i < count + 1; i++) + for (i = 1; i <= count; i++) { for (j = 0, l = i; j < limit; j++) { @@ -1054,8 +1061,11 @@ while (entry = getpwent ()) { - if ((username[0] == entry->pw_name[0]) && - (strncmp (username, entry->pw_name, namelen) == 0)) + /* Null usernames should result in all users as possible completions. */ + if (namelen == 0) + break; + else if ((username[0] == entry->pw_name[0]) && + (strncmp (username, entry->pw_name, namelen) == 0)) break; } Index: display.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/display.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- display.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ display.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -21,6 +21,10 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + #include <stdio.h> #include <sys/types.h> @@ -471,7 +475,8 @@ (_rl_last_c_pos < visible_first_line_len)) { nleft = screenwidth + wrap_offset - _rl_last_c_pos; - clear_to_eol (nleft); + if (nleft) + clear_to_eol (nleft); } /* Since the new first line is now visible, save its length. */ @@ -497,7 +502,7 @@ /* Move the cursor where it should be. */ /* Which line? */ - nleft = c_pos - wrap_offset - term_xn + 1; + nleft = c_pos - wrap_offset + term_xn - 1; cursor_linenum = (nleft > 0) ? nleft / screenwidth : 0; /* CHANGED_SCREEN_LINE is set to 1 if we have moved to a Index: history.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/history.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- history.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ history.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -1540,9 +1540,9 @@ j += sl; \ if (j >= result_len) \ { \ - while (j >= result_len) \ - result_len += 128; \ - result = xrealloc (result, result_len); \ + while (j >= result_len) \ + result_len += 128; \ + result = xrealloc (result, result_len); \ } \ strcpy (result + j - sl, s); \ } \ @@ -1910,13 +1910,14 @@ last++; - if (first > len || last > len || first < 0 || last < 0) + if (first >= len || last > len || first < 0 || last < 0 || first > last) result = ((char *)NULL); else { for (size = 0, i = first; i < last; i++) size += strlen (list[i]) + 1; result = xmalloc (size + 1); + result[0] = '\0'; for (i = first; i < last; i++) { Index: keymaps.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/keymaps.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- keymaps.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ keymaps.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -20,6 +20,10 @@ Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + #if defined (HAVE_STDLIB_H) # include <stdlib.h> #else @@ -101,7 +105,7 @@ newmap = rl_make_bare_keymap (); /* All ASCII printing characters are self-inserting. */ - for (i = ' '; i < 126; i++) + for (i = ' '; i < 127; i++) newmap[i].function = rl_insert; newmap[TAB].function = rl_insert; Index: readline.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/readline.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- readline.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ readline.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -624,13 +624,13 @@ Keymap map; { int r = 0; - if (defining_kbd_macro) - add_macro_char (key); if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) { if (map[ESC].type == ISKMAP) { + if (defining_kbd_macro) + add_macro_char (ESC); map = FUNCTION_TO_KEYMAP (map, ESC); key = UNMETA (key); rl_key_sequence_length += 2; @@ -643,10 +643,7 @@ if (defining_kbd_macro) add_macro_char (key); - - if (defining_kbd_macro) - add_macro_char (key); - + switch (map[key].type) { case ISFUNC: @@ -927,8 +924,6 @@ /* Initliaze readline (and terminal if not already). */ rl_initialize () { - char *t; - /* If we have never been called before, initialize the terminal and data structures. */ if (!rl_initialized) @@ -945,16 +940,6 @@ /* We aren't done yet. We haven't even gotten started yet! */ rl_done = 0; - /* Check for LC_CTYPE and use its value to decide the defaults for - 8-bit character input and output. */ - t = getenv ("LC_CTYPE"); - if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0)) - { - _rl_meta_flag = 1; - _rl_convert_meta_chars_to_ascii = 0; - _rl_output_meta_chars = 1; - } - /* Tell the history routines what is going on. */ start_using_history (); @@ -1006,6 +991,16 @@ /* Initialize the function names. */ rl_initialize_funmap (); + /* Check for LC_CTYPE and use its value to decide the defaults for + 8-bit character input and output. */ + t = getenv ("LC_CTYPE"); + if (t && (strcmp (t, "iso-8859-1") == 0 || strcmp (t, "iso_8859_1") == 0)) + { + _rl_meta_flag = 1; + _rl_convert_meta_chars_to_ascii = 0; + _rl_output_meta_chars = 1; + } + /* Read in the init file. */ rl_read_init_file ((char *)NULL); @@ -1760,6 +1755,10 @@ from = to; to = t; } + + if (to > rl_end) + to = rl_end; + text = rl_copy_text (from, to); /* Some versions of strncpy() can't handle overlapping arguments. */ @@ -2313,14 +2312,20 @@ else { int orig_point = rl_point; - - while (rl_point && whitespace (the_line[rl_point - 1])) - rl_point--; - - while (rl_point && !whitespace (the_line[rl_point - 1])) - rl_point--; - + if (count <= 0) + count = 1; + + while (count--) + { + while (rl_point && whitespace (the_line[rl_point - 1])) + rl_point--; + + while (rl_point && !whitespace (the_line[rl_point - 1])) + rl_point--; + } + rl_kill_text (orig_point, rl_point); + } return 0; } @@ -2439,7 +2444,7 @@ break; default: - abort (); + ding (); return -1; } } Index: rltty.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/rltty.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- rltty.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ rltty.c 9 Mar 2002 16:05:44 -0000 1.2 @@ -22,6 +22,10 @@ 675 Mass Ave, Cambridge, MA 02139, USA. */ #define READLINE_LIBRARY +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + #include <sys/types.h> #include <signal.h> #include <errno.h> @@ -149,6 +153,7 @@ #endif } +#if 0 static void control_keypad (on) int on; @@ -160,6 +165,7 @@ tputs (term_ke, 1, outchar); #endif } +#endif /* **************************************************************** */ /* */ @@ -414,6 +420,7 @@ int tty; TIOTYPE *tiop; { + int ioctl_ret; #if !defined (SHELL) && defined (TIOCGWINSZ) struct winsize w; @@ -423,12 +430,12 @@ /* Keep looping if output is being flushed after a ^O (or whatever the flush character is). */ - while (GETATTR (tty, tiop) < 0 || OUTPUT_BEING_FLUSHED (tiop)) + while ((ioctl_ret = GETATTR (tty, tiop)) < 0 || OUTPUT_BEING_FLUSHED (tiop)) { + if (ioctl_ret < 0 && errno != EINTR) + return -1; if (OUTPUT_BEING_FLUSHED (tiop)) continue; - if (errno != EINTR) - return -1; errno = 0; } return 0; @@ -564,7 +571,9 @@ } control_meta_key (1); +#if 0 control_keypad (1); +#endif fflush (rl_outstream); terminal_prepped = 1; @@ -586,7 +595,9 @@ block_sigint (); control_meta_key (0); +#if 0 control_keypad (0); +#endif fflush (rl_outstream); if (set_tty_settings (tty, &otio) < 0) Index: search.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/search.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- search.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ search.c 9 Mar 2002 16:05:44 -0000 1.2 @@ -29,7 +29,6 @@ # include <unistd.h> #endif -#include "memalloc.h" #include "rldefs.h" #include "readline.h" #include "history.h" @@ -44,6 +43,7 @@ /* Variables imported from readline.c */ extern int rl_point, rl_end, rl_line_buffer_len; extern Keymap _rl_keymap; +extern int rl_editing_mode; extern char *rl_prompt; extern char *rl_line_buffer; extern HIST_ENTRY *saved_line_for_history; @@ -94,7 +94,7 @@ int oldpos, pos; HIST_ENTRY *entry; - if (string == 0 || *string == 0 || noninc_history_pos < 0) + if (string == 0 || *string == '\0' || noninc_history_pos < 0) { ding (); return; @@ -116,6 +116,9 @@ oldpos = where_history (); history_set_pos (noninc_history_pos); entry = current_history (); +#if defined (VI_MODE) + if (rl_editing_mode != vi_mode) +#endif history_set_pos (oldpos); { Index: tilde.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/readline/tilde.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- tilde.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ tilde.c 9 Mar 2002 16:05:44 -0000 1.2 @@ -19,8 +19,6 @@ along with Readline; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "memalloc.h" - #if defined (HAVE_STRING_H) # include <string.h> #else /* !HAVE_STRING_H */ @@ -34,6 +32,7 @@ #endif /* HAVE_STDLIB_H */ #include "tilde.h" +#include <sys/types.h> #include <pwd.h> #if defined (USG) && !defined (HAVE_GETPW_DECLS) @@ -251,22 +250,16 @@ } else { - char u_name[257]; - struct passwd *user_entry; char *username; - int i, c; + struct passwd *user_entry; + int i; - username = u_name; - for (i = 1; c = dirname[i]; i++) - { - if (c == '/') - break; - else - username[i - 1] = c; - } + username = xmalloc (strlen (dirname)); + for (i = 1; dirname[i] && dirname[i] != '/'; i++) + username[i - 1] = dirname[i]; username[i - 1] = '\0'; - if (!(user_entry = getpwnam (username))) + if ((user_entry = getpwnam (username)) == 0) { /* If the calling program has a special syntax for expanding tildes, and we couldn't find a standard @@ -299,7 +292,8 @@ free (dirname); dirname = temp_name; } - endpwent (); + endpwent (); + free (username); } } return (dirname); |
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:46
|
Update of /cvsroot/winbash/winbash/documentation In directory usw-pr-cvs1:/tmp/cvs-serv14844/documentation Modified Files: Makefile bash.1 Log Message: Applied 1.14.3 diffs from GNU bash Index: Makefile =================================================================== RCS file: /cvsroot/winbash/winbash/documentation/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile 9 Mar 2002 04:43:15 -0000 1.2 +++ Makefile 9 Mar 2002 16:05:42 -0000 1.3 @@ -106,12 +106,12 @@ realclean: clean install: all - [ -d $(mandir) ] || mkdir $(mandir) + -[ -d $(mandir) ] || mkdir $(mandir) $(INSTALL_DATA) bash.1 $(mandir) sed 's:so bash.1:so man1/bash.1:' < builtins.1 > $(mandir)/bash_builtins.1 - [ -d $(man3dir) ] || mkdir $(man3dir) + -[ -d $(man3dir) ] || mkdir $(man3dir) $(INSTALL_DATA) readline.3 $(man3dir) - [ -d $(infodir) ] || mkdir $(infodir) + -[ -d $(infodir) ] || mkdir $(infodir) $(INSTALL_DATA) features.info $(infodir)/bash.info uninstall: Index: bash.1 =================================================================== RCS file: /cvsroot/winbash/winbash/documentation/bash.1,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bash.1 9 Mar 2002 04:43:15 -0000 1.2 +++ bash.1 9 Mar 2002 16:05:42 -0000 1.3 @@ -6,11 +6,11 @@ .\" Case Western Reserve University .\" ch...@in... .\" -.\" Last Change: Wed Jul 20 16:13:25 EDT 1994 +.\" Last Change: Tue Dec 6 12:15:11 EST 1994 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ -.TH BASH 1 "1994 July 26" GNU +.TH BASH 1 "1994 Dec 6" GNU .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -4736,13 +4736,24 @@ The positional parameters from \fIn\fP+1 ... are renamed to .B $1 .B .... +Parameters represented by the numbers \fB$#\fP +down to \fB$#\fP\-\fIn\fP+1 are unset. +If +.I n +is 0, no parameters are changed. If .I n -is not given, it is assumed to be 1. The exit status is 1 if +is not given, it is assumed to be 1. +.I n +must be a non-negative number less than or equal to \fB$#\fP. +If +.I n +is greater than \fB$#\fP, the positional parameters are not changed. +The return status is greater than 0 if .I n is greater than -.BR $# ; -otherwise 0. +.B $# +or less than 0; otherwise 0. .TP \fBsuspend\fP [\fB\-f\fP] Suspend the execution of this shell until it receives a |
From: Enrico B. <enr...@us...> - 2002-03-09 16:05:46
|
Update of /cvsroot/winbash/winbash/lib/glob In directory usw-pr-cvs1:/tmp/cvs-serv14844/lib/glob Modified Files: glob.c Log Message: Applied 1.14.3 diffs from GNU bash Index: glob.c =================================================================== RCS file: /cvsroot/winbash/winbash/lib/glob/glob.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- glob.c 9 Mar 2002 03:39:13 -0000 1.1.1.1 +++ glob.c 9 Mar 2002 16:05:43 -0000 1.2 @@ -436,10 +436,14 @@ if (directories == NULL) goto memory_error; else if (directories == (char **)&glob_error_return) - return ((char **) &glob_error_return); + { + free ((char *)result); + return ((char **) &glob_error_return); + } else if (*directories == NULL) { free ((char *) directories); + free ((char *) result); return ((char **) &glob_error_return); } |