Update of /cvsroot/winbash/winbash/builtins
In directory usw-pr-cvs1:/tmp/cvs-serv29857
Modified Files:
alias.def bashgetopt.c bashgetopt.h bind.def break.def
builtin.def cd.def colon.def command.def common.c common.h
declare.def echo.def enable.def eval.def exec.def exit.def
fc.def fg_bg.def getopt.c getopt.h getopts.def hash.def
hashcom.h help.def history.def inlib.def jobs.def kill.def
let.def mkbuiltins.c pipesize.h psize.c psize.sh read.def
reserved.def return.def send_files set.def setattr.def
shift.def source.def suspend.def test.def times.def trap.def
type.def ulimit.def umask.def wait.def
Log Message:
Fixed cr/lf problems....
Index: alias.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/alias.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- alias.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ alias.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,180 +1,180 @@
-This file is alias.def, from which is created alias.c
-It implements the builtins "alias" and "unalias" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$BUILTIN alias
-$FUNCTION alias_builtin
-$DEPENDS_ON ALIAS
-$PRODUCES alias.c
-$SHORT_DOC alias [ name[=value] ... ]
-`alias' with no arguments prints the list of aliases in the form
-NAME=VALUE on standard output. An alias is defined for each NAME
-whose VALUE is given. A trailing space in VALUE causes the next
-word to be checked for alias substitution. Alias returns true
-unless a NAME is given for which no alias has been defined.
-$END
-
-#include "../config.h"
-
-#if defined (ALIAS)
-# include <stdio.h>
-# include "../shell.h"
-# include "../alias.h"
-# include "nt_types.h"
-# include "common.h"
-
-static void print_alias ();
-
-/* Hack the alias command in a Korn shell way. */
-alias_builtin (list)
- WORD_LIST *list;
-{
- int any_failed = 0;
-
- if (!list)
- {
- register int i;
- ASSOC **alias_list;
-
- if (!aliases)
- return (EXECUTION_FAILURE);
-
- alias_list = all_aliases ();
-
- if (!alias_list)
- return (EXECUTION_FAILURE);
-
- for (i = 0; alias_list[i]; i++)
- print_alias (alias_list[i]);
-
- free (alias_list); /* XXX - Do not free the strings. */
- }
- else
- {
- while (list)
- {
- register char *value, *name = list->word->word;
- register int offset;
-
- for (offset = 0; name[offset] && name[offset] != '='; offset++)
- ;
-
- if (offset && name[offset] == '=')
- {
- name[offset] = '\0';
- value = name + offset + 1;
-
- add_alias (name, value);
- }
- else
- {
- ASSOC *t = find_alias (name);
- if (t)
- print_alias (t);
- else
- {
- if (thr_me->interactive)
- builtin_error ("`%s' not found", name);
- any_failed++;
- }
- }
- list = list->next;
- }
- }
- if (any_failed)
- return (EXECUTION_FAILURE);
- else
- return (EXECUTION_SUCCESS);
-}
-#endif /* ALIAS */
-
-$BUILTIN unalias
-$FUNCTION unalias_builtin
-$DEPENDS_ON ALIAS
-$SHORT_DOC unalias [-a] [name ...]
-Remove NAMEs from the list of defined aliases. If the -a option is given,
-then remove all alias definitions.
-$END
-
-#if defined (ALIAS)
-/* Remove aliases named in LIST from the aliases database. */
-unalias_builtin (list)
- register WORD_LIST *list;
-{
- register ASSOC *alias;
- int any_failed = 0;
-
- while (list && *list->word->word == '-')
- {
- register char *word = list->word->word;
-
- if (ISOPTION (word, 'a'))
- {
- delete_all_aliases ();
- list = list->next;
- }
- else if (ISOPTION (word, '-'))
- {
- list = list->next;
- break;
- }
- else
- {
- bad_option (word);
- return (EXECUTION_FAILURE);
- }
- }
-
- while (list)
- {
- alias = find_alias (list->word->word);
-
- if (alias)
- remove_alias (alias->name);
- else
- {
- if (thr_me->interactive)
- builtin_error ("`%s' not an alias", list->word->word);
-
- any_failed++;
- }
-
- list = list->next;
- }
-
- if (any_failed)
- return (EXECUTION_FAILURE);
- else
- return (EXECUTION_SUCCESS);
-}
-
-/* Output ALIAS in such a way as to allow it to be read back in. */
-static void
-print_alias (alias)
- ASSOC *alias;
-{
- char *value = single_quote (alias->value);
-
- printf ("alias %s=%s\n", alias->name, value);
- free (value);
-
- fflush (stdout);
-}
-#endif /* ALIAS */
+This file is alias.def, from which is created alias.c
+It implements the builtins "alias" and "unalias" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$BUILTIN alias
+$FUNCTION alias_builtin
+$DEPENDS_ON ALIAS
+$PRODUCES alias.c
+$SHORT_DOC alias [ name[=value] ... ]
+`alias' with no arguments prints the list of aliases in the form
+NAME=VALUE on standard output. An alias is defined for each NAME
+whose VALUE is given. A trailing space in VALUE causes the next
+word to be checked for alias substitution. Alias returns true
+unless a NAME is given for which no alias has been defined.
+$END
+
+#include "../config.h"
+
+#if defined (ALIAS)
+# include <stdio.h>
+# include "../shell.h"
+# include "../alias.h"
+# include "nt_types.h"
+# include "common.h"
+
+static void print_alias ();
+
+/* Hack the alias command in a Korn shell way. */
+alias_builtin (list)
+ WORD_LIST *list;
+{
+ int any_failed = 0;
+
+ if (!list)
+ {
+ register int i;
+ ASSOC **alias_list;
+
+ if (!aliases)
+ return (EXECUTION_FAILURE);
+
+ alias_list = all_aliases ();
+
+ if (!alias_list)
+ return (EXECUTION_FAILURE);
+
+ for (i = 0; alias_list[i]; i++)
+ print_alias (alias_list[i]);
+
+ free (alias_list); /* XXX - Do not free the strings. */
+ }
+ else
+ {
+ while (list)
+ {
+ register char *value, *name = list->word->word;
+ register int offset;
+
+ for (offset = 0; name[offset] && name[offset] != '='; offset++)
+ ;
+
+ if (offset && name[offset] == '=')
+ {
+ name[offset] = '\0';
+ value = name + offset + 1;
+
+ add_alias (name, value);
+ }
+ else
+ {
+ ASSOC *t = find_alias (name);
+ if (t)
+ print_alias (t);
+ else
+ {
+ if (thr_me->interactive)
+ builtin_error ("`%s' not found", name);
+ any_failed++;
+ }
+ }
+ list = list->next;
+ }
+ }
+ if (any_failed)
+ return (EXECUTION_FAILURE);
+ else
+ return (EXECUTION_SUCCESS);
+}
+#endif /* ALIAS */
+
+$BUILTIN unalias
+$FUNCTION unalias_builtin
+$DEPENDS_ON ALIAS
+$SHORT_DOC unalias [-a] [name ...]
+Remove NAMEs from the list of defined aliases. If the -a option is given,
+then remove all alias definitions.
+$END
+
+#if defined (ALIAS)
+/* Remove aliases named in LIST from the aliases database. */
+unalias_builtin (list)
+ register WORD_LIST *list;
+{
+ register ASSOC *alias;
+ int any_failed = 0;
+
+ while (list && *list->word->word == '-')
+ {
+ register char *word = list->word->word;
+
+ if (ISOPTION (word, 'a'))
+ {
+ delete_all_aliases ();
+ list = list->next;
+ }
+ else if (ISOPTION (word, '-'))
+ {
+ list = list->next;
+ break;
+ }
+ else
+ {
+ bad_option (word);
+ return (EXECUTION_FAILURE);
+ }
+ }
+
+ while (list)
+ {
+ alias = find_alias (list->word->word);
+
+ if (alias)
+ remove_alias (alias->name);
+ else
+ {
+ if (thr_me->interactive)
+ builtin_error ("`%s' not an alias", list->word->word);
+
+ any_failed++;
+ }
+
+ list = list->next;
+ }
+
+ if (any_failed)
+ return (EXECUTION_FAILURE);
+ else
+ return (EXECUTION_SUCCESS);
+}
+
+/* Output ALIAS in such a way as to allow it to be read back in. */
+static void
+print_alias (alias)
+ ASSOC *alias;
+{
+ char *value = single_quote (alias->value);
+
+ printf ("alias %s=%s\n", alias->name, value);
+ free (value);
+
+ fflush (stdout);
+}
+#endif /* ALIAS */
Index: bashgetopt.c
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/bashgetopt.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- bashgetopt.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ bashgetopt.c 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,136 +1,136 @@
-/* bashgetopt.c -- `getopt' for use by the builtins. */
-
-/* Copyright (C) 1992 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include <errno.h>
-#include "shell.h"
-
-#include "bashansi.h"
-
-#define ERR(S, C) builtin_error("%s%c", (S), (C))
-
-static int sp;
-
-char *list_optarg;
-int list_optopt;
-
-static WORD_LIST *lhead = (WORD_LIST *)NULL;
-WORD_LIST *lcurrent = (WORD_LIST *)NULL;
-WORD_LIST *loptend; /* Points to the first non-option argument in the list */
-
-int
-internal_getopt(list, opts)
-WORD_LIST *list;
-char *opts;
-{
- register int c;
- register char *cp;
-
- if (!list) {
- list_optarg = (char *)NULL;
- loptend = (WORD_LIST *)NULL; /* No non-option arguments */
- return -1;
- }
-
- if (list != lhead || !lhead) {
- /* Hmmm.... called with a different word list. Reset. */
- sp = 1;
- lcurrent = lhead = list;
- loptend = (WORD_LIST *)NULL;
- }
-
- if (sp == 1) {
- if (!lcurrent ||
- (lcurrent->word->word[0] != '-' || lcurrent->word->word[1] == '\0')) {
- lhead = (WORD_LIST *)NULL;
- loptend = lcurrent;
- return(-1);
- } else if (lcurrent->word->word[0] == '-' &&
- lcurrent->word->word[1] == '-' &&
- lcurrent->word->word[2] == 0) {
- lhead = (WORD_LIST *)NULL;
- loptend = lcurrent->next;
- return(-1);
- }
- }
-
- list_optopt = c = lcurrent->word->word[sp];
-
- if (c == ':' || (cp = strchr(opts, c)) == NULL) {
- ERR("illegal option: -", c);
- if (lcurrent->word->word[++sp] == '\0') {
- lcurrent = lcurrent->next;
- sp = 1;
- }
- list_optarg = NULL;
- if (lcurrent)
- loptend = lcurrent->next;
- return('?');
- }
-
- if (*++cp == ':') {
- /* Option requires an argument. */
- /* We allow -l2 as equivalent to -l 2 */
- if (lcurrent->word->word[sp+1] != '\0') {
- list_optarg = &(lcurrent->word->word[sp+1]);
- lcurrent = lcurrent->next;
- } else if (lcurrent->next == NULL) {
- ERR("option requires an argument: -", c);
- sp = 1;
- list_optarg = (char *)NULL;
- return('?');
- } else {
- lcurrent = lcurrent->next;
- list_optarg = lcurrent->word->word;
- lcurrent = lcurrent->next;
- }
- sp = 1;
- } else {
- /* No argument, just return the option. */
- if (lcurrent->word->word[++sp] == '\0') {
- sp = 1;
- lcurrent = lcurrent->next;
- }
- list_optarg = (char *)NULL;
- }
-
- return(c);
-}
-
-/*
- * reset_internal_getopt -- force the in[ft]ernal getopt to reset
- */
-
-void
-reset_internal_getopt ()
-{
- lhead = lcurrent = loptend = (WORD_LIST *)NULL;
- sp = 1;
-}
-
-void
-report_bad_option ()
-{
- char s[3];
-
- s[0] = '-';
- s[1] = list_optopt;
- s[2] = '\0';
- bad_option (s);
-}
+/* bashgetopt.c -- `getopt' for use by the builtins. */
+
+/* Copyright (C) 1992 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+#include "shell.h"
+
+#include "bashansi.h"
+
+#define ERR(S, C) builtin_error("%s%c", (S), (C))
+
+static int sp;
+
+char *list_optarg;
+int list_optopt;
+
+static WORD_LIST *lhead = (WORD_LIST *)NULL;
+WORD_LIST *lcurrent = (WORD_LIST *)NULL;
+WORD_LIST *loptend; /* Points to the first non-option argument in the list */
+
+int
+internal_getopt(list, opts)
+WORD_LIST *list;
+char *opts;
+{
+ register int c;
+ register char *cp;
+
+ if (!list) {
+ list_optarg = (char *)NULL;
+ loptend = (WORD_LIST *)NULL; /* No non-option arguments */
+ return -1;
+ }
+
+ if (list != lhead || !lhead) {
+ /* Hmmm.... called with a different word list. Reset. */
+ sp = 1;
+ lcurrent = lhead = list;
+ loptend = (WORD_LIST *)NULL;
+ }
+
+ if (sp == 1) {
+ if (!lcurrent ||
+ (lcurrent->word->word[0] != '-' || lcurrent->word->word[1] == '\0')) {
+ lhead = (WORD_LIST *)NULL;
+ loptend = lcurrent;
+ return(-1);
+ } else if (lcurrent->word->word[0] == '-' &&
+ lcurrent->word->word[1] == '-' &&
+ lcurrent->word->word[2] == 0) {
+ lhead = (WORD_LIST *)NULL;
+ loptend = lcurrent->next;
+ return(-1);
+ }
+ }
+
+ list_optopt = c = lcurrent->word->word[sp];
+
+ if (c == ':' || (cp = strchr(opts, c)) == NULL) {
+ ERR("illegal option: -", c);
+ if (lcurrent->word->word[++sp] == '\0') {
+ lcurrent = lcurrent->next;
+ sp = 1;
+ }
+ list_optarg = NULL;
+ if (lcurrent)
+ loptend = lcurrent->next;
+ return('?');
+ }
+
+ if (*++cp == ':') {
+ /* Option requires an argument. */
+ /* We allow -l2 as equivalent to -l 2 */
+ if (lcurrent->word->word[sp+1] != '\0') {
+ list_optarg = &(lcurrent->word->word[sp+1]);
+ lcurrent = lcurrent->next;
+ } else if (lcurrent->next == NULL) {
+ ERR("option requires an argument: -", c);
+ sp = 1;
+ list_optarg = (char *)NULL;
+ return('?');
+ } else {
+ lcurrent = lcurrent->next;
+ list_optarg = lcurrent->word->word;
+ lcurrent = lcurrent->next;
+ }
+ sp = 1;
+ } else {
+ /* No argument, just return the option. */
+ if (lcurrent->word->word[++sp] == '\0') {
+ sp = 1;
+ lcurrent = lcurrent->next;
+ }
+ list_optarg = (char *)NULL;
+ }
+
+ return(c);
+}
+
+/*
+ * reset_internal_getopt -- force the in[ft]ernal getopt to reset
+ */
+
+void
+reset_internal_getopt ()
+{
+ lhead = lcurrent = loptend = (WORD_LIST *)NULL;
+ sp = 1;
+}
+
+void
+report_bad_option ()
+{
+ char s[3];
+
+ s[0] = '-';
+ s[1] = list_optopt;
+ s[2] = '\0';
+ bad_option (s);
+}
Index: bashgetopt.h
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/bashgetopt.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- bashgetopt.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ bashgetopt.h 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,37 +1,37 @@
-/* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.c. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* See getopt.h for the explanation of these variables. */
-
-#if !defined (__BASH_GETOPT_H)
-# define __BASH_GETOPT_H
-
-extern char *list_optarg;
-
-extern int list_optopt;
-
-extern WORD_LIST *lcurrent;
-extern WORD_LIST *loptend;
-
-extern int internal_getopt ();
-extern void reset_internal_getopt ();
-extern void report_bad_option ();
-
-#endif /* !__BASH_GETOPT_H */
+/* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.c. */
+
+/* Copyright (C) 1993 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* See getopt.h for the explanation of these variables. */
+
+#if !defined (__BASH_GETOPT_H)
+# define __BASH_GETOPT_H
+
+extern char *list_optarg;
+
+extern int list_optopt;
+
+extern WORD_LIST *lcurrent;
+extern WORD_LIST *loptend;
+
+extern int internal_getopt ();
+extern void reset_internal_getopt ();
+extern void report_bad_option ();
+
+#endif /* !__BASH_GETOPT_H */
Index: bind.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/bind.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- bind.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ bind.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,219 +1,219 @@
-This file is bind.def, from which is created bind.c.
-It implements the builtin "bind" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$PRODUCES bind.c
-
-$BUILTIN bind
-$DEPENDS_ON READLINE
-$FUNCTION bind_builtin
-$SHORT_DOC bind [-lvd] [-m keymap] [-f filename] [-q name] [keyseq:readline-function]
-Bind a key sequence to a Readline function, or to a macro. The
-syntax is equivalent to that found in ~/.inputrc, but must be
-passed as a single argument: bind '"\C-x\C-r": re-read-init-file'.
-Arguments we accept:
- -m keymap Use `keymap' as the keymap for the duration of this
- command. Acceptable keymap names are emacs,
- emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
- vi-command, and vi-insert.
- -l List names of functions.
- -v List function names and bindings.
- -d Dump functions and bindings such that they
- can be read back in.
- -f filename Read key bindings from FILENAME.
- -q function-name Query about which keys invoke the named function.
-$END
-
-#include <stdio.h>
-#include "../shell.h"
-#if defined (READLINE)
-#include <errno.h>
-#if !defined (errno)
-extern int errno;
-#endif /* !errno */
-#include <readline/readline.h>
-#include <readline/history.h>
-#include "bashgetopt.h"
-
-static int query_bindings ();
-
-extern int bash_readline_initialized;
-extern int no_line_editing;
-
-#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0)
-
-#define USAGE "usage: bind [-lvd] [-m keymap] [-f filename] [-q name] [keyseq:readline_func]"
-
-int
-bind_builtin (list)
- WORD_LIST *list;
-{
- int return_code = EXECUTION_SUCCESS;
- FILE *old_rl_outstream;
- Keymap kmap, saved_keymap;
- int lflag, dflag, fflag, vflag, qflag, mflag, opt;
- char *initfile, *map_name, *fun_name;
-
- if (no_line_editing)
- return (EXECUTION_FAILURE);
-
- kmap = saved_keymap = (Keymap) NULL;
- lflag = dflag = vflag = fflag = qflag = mflag = 0;
- initfile = map_name = fun_name = (char *)NULL;
-
- if (!bash_readline_initialized)
- initialize_readline ();
-
- /* Cannot use unwind_protect_pointer () on "FILE *", it is only
- guaranteed to work for strings. */
- /* XXX -- see if we can use unwind_protect here */
- old_rl_outstream = rl_outstream;
- rl_outstream = stdout;
-
- reset_internal_getopt ();
- while ((opt = internal_getopt (list, "lvdf:q:m:")) != EOF)
- {
- switch (opt)
- {
- case 'l':
- lflag++;
- break;
-
- case 'v':
- vflag++;
- break;
-
- case 'd':
- dflag++;
- break;
-
- case 'f':
- fflag++;
- initfile = list_optarg;
- break;
-
- case 'm':
- mflag++;
- map_name = list_optarg;
- break;
-
- case 'q':
- qflag++;
- fun_name = list_optarg;
- break;
-
- default:
- builtin_error (USAGE);
- BIND_RETURN (EX_USAGE);
- }
- }
-
- list = loptend;
-
- /* First, see if we need to install a special keymap for this
- command. Then start on the arguments. */
-
- if (mflag && map_name)
- {
- kmap = rl_get_keymap_by_name (map_name);
- if (!kmap)
- {
- builtin_error ("`%s': illegal keymap name", map_name);
- BIND_RETURN (EXECUTION_FAILURE);
- }
- }
-
- if (kmap)
- {
- saved_keymap = rl_get_keymap ();
- rl_set_keymap (kmap);
- }
-
- /* XXX - we need to add exclusive use tests here. It doesn't make sense
- to use some of these options together. */
- /* Now hack the option arguments */
- if (lflag)
- rl_list_funmap_names (0);
-
- if (vflag)
- rl_function_dumper (0);
-
- if (dflag)
- rl_function_dumper (1);
-
- if (fflag && initfile)
- {
- if (rl_read_init_file (initfile) != 0)
- {
- builtin_error ("cannot read %s: %s\n", initfile, strerror (errno));
- BIND_RETURN (EXECUTION_FAILURE);
- }
- }
-
- if (qflag && fun_name)
- return_code = query_bindings (fun_name);
-
- /* Process the rest of the arguments as binding specifications. */
- while (list)
- {
- rl_parse_and_bind (list->word->word);
- list = list->next;
- }
-
- if (saved_keymap)
- rl_set_keymap (saved_keymap);
-
- bind_exit:
- rl_outstream = old_rl_outstream;
- return (return_code);
-}
-
-static int
-query_bindings (name)
- char *name;
-{
- Function *function;
- char **keyseqs;
- int j;
-
- function = rl_named_function (name);
- if (!function)
- {
- builtin_error ("unknown function name `%s'", name);
- return EXECUTION_FAILURE;
- }
-
- keyseqs = rl_invoking_keyseqs (function);
-
- if (!keyseqs)
- {
- printf ("%s is not bound to any keys.\n", name);
- return EXECUTION_FAILURE;
- }
-
- printf ("%s can be invoked via ", name);
- for (j = 0; j < 5 && keyseqs[j]; j++)
- printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n");
- if (keyseqs[j])
- printf ("...\n");
- free_array (keyseqs);
- return EXECUTION_SUCCESS;
-}
-#endif /* READLINE */
+This file is bind.def, from which is created bind.c.
+It implements the builtin "bind" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES bind.c
+
+$BUILTIN bind
+$DEPENDS_ON READLINE
+$FUNCTION bind_builtin
+$SHORT_DOC bind [-lvd] [-m keymap] [-f filename] [-q name] [keyseq:readline-function]
+Bind a key sequence to a Readline function, or to a macro. The
+syntax is equivalent to that found in ~/.inputrc, but must be
+passed as a single argument: bind '"\C-x\C-r": re-read-init-file'.
+Arguments we accept:
+ -m keymap Use `keymap' as the keymap for the duration of this
+ command. Acceptable keymap names are emacs,
+ emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
+ vi-command, and vi-insert.
+ -l List names of functions.
+ -v List function names and bindings.
+ -d Dump functions and bindings such that they
+ can be read back in.
+ -f filename Read key bindings from FILENAME.
+ -q function-name Query about which keys invoke the named function.
+$END
+
+#include <stdio.h>
+#include "../shell.h"
+#if defined (READLINE)
+#include <errno.h>
+#if !defined (errno)
+extern int errno;
+#endif /* !errno */
+#include <readline/readline.h>
+#include <readline/history.h>
+#include "bashgetopt.h"
+
+static int query_bindings ();
+
+extern int bash_readline_initialized;
+extern int no_line_editing;
+
+#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0)
+
+#define USAGE "usage: bind [-lvd] [-m keymap] [-f filename] [-q name] [keyseq:readline_func]"
+
+int
+bind_builtin (list)
+ WORD_LIST *list;
+{
+ int return_code = EXECUTION_SUCCESS;
+ FILE *old_rl_outstream;
+ Keymap kmap, saved_keymap;
+ int lflag, dflag, fflag, vflag, qflag, mflag, opt;
+ char *initfile, *map_name, *fun_name;
+
+ if (no_line_editing)
+ return (EXECUTION_FAILURE);
+
+ kmap = saved_keymap = (Keymap) NULL;
+ lflag = dflag = vflag = fflag = qflag = mflag = 0;
+ initfile = map_name = fun_name = (char *)NULL;
+
+ if (!bash_readline_initialized)
+ initialize_readline ();
+
+ /* Cannot use unwind_protect_pointer () on "FILE *", it is only
+ guaranteed to work for strings. */
+ /* XXX -- see if we can use unwind_protect here */
+ old_rl_outstream = rl_outstream;
+ rl_outstream = stdout;
+
+ reset_internal_getopt ();
+ while ((opt = internal_getopt (list, "lvdf:q:m:")) != EOF)
+ {
+ switch (opt)
+ {
+ case 'l':
+ lflag++;
+ break;
+
+ case 'v':
+ vflag++;
+ break;
+
+ case 'd':
+ dflag++;
+ break;
+
+ case 'f':
+ fflag++;
+ initfile = list_optarg;
+ break;
+
+ case 'm':
+ mflag++;
+ map_name = list_optarg;
+ break;
+
+ case 'q':
+ qflag++;
+ fun_name = list_optarg;
+ break;
+
+ default:
+ builtin_error (USAGE);
+ BIND_RETURN (EX_USAGE);
+ }
+ }
+
+ list = loptend;
+
+ /* First, see if we need to install a special keymap for this
+ command. Then start on the arguments. */
+
+ if (mflag && map_name)
+ {
+ kmap = rl_get_keymap_by_name (map_name);
+ if (!kmap)
+ {
+ builtin_error ("`%s': illegal keymap name", map_name);
+ BIND_RETURN (EXECUTION_FAILURE);
+ }
+ }
+
+ if (kmap)
+ {
+ saved_keymap = rl_get_keymap ();
+ rl_set_keymap (kmap);
+ }
+
+ /* XXX - we need to add exclusive use tests here. It doesn't make sense
+ to use some of these options together. */
+ /* Now hack the option arguments */
+ if (lflag)
+ rl_list_funmap_names (0);
+
+ if (vflag)
+ rl_function_dumper (0);
+
+ if (dflag)
+ rl_function_dumper (1);
+
+ if (fflag && initfile)
+ {
+ if (rl_read_init_file (initfile) != 0)
+ {
+ builtin_error ("cannot read %s: %s\n", initfile, strerror (errno));
+ BIND_RETURN (EXECUTION_FAILURE);
+ }
+ }
+
+ if (qflag && fun_name)
+ return_code = query_bindings (fun_name);
+
+ /* Process the rest of the arguments as binding specifications. */
+ while (list)
+ {
+ rl_parse_and_bind (list->word->word);
+ list = list->next;
+ }
+
+ if (saved_keymap)
+ rl_set_keymap (saved_keymap);
+
+ bind_exit:
+ rl_outstream = old_rl_outstream;
+ return (return_code);
+}
+
+static int
+query_bindings (name)
+ char *name;
+{
+ Function *function;
+ char **keyseqs;
+ int j;
+
+ function = rl_named_function (name);
+ if (!function)
+ {
+ builtin_error ("unknown function name `%s'", name);
+ return EXECUTION_FAILURE;
+ }
+
+ keyseqs = rl_invoking_keyseqs (function);
+
+ if (!keyseqs)
+ {
+ printf ("%s is not bound to any keys.\n", name);
+ return EXECUTION_FAILURE;
+ }
+
+ printf ("%s can be invoked via ", name);
+ for (j = 0; j < 5 && keyseqs[j]; j++)
+ printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n");
+ if (keyseqs[j])
+ printf ("...\n");
+ free_array (keyseqs);
+ return EXECUTION_SUCCESS;
+}
+#endif /* READLINE */
Index: break.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/break.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- break.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ break.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,110 +1,110 @@
-This file is break.def, from which is created break.c.
-It implements the builtins "break" and "continue" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$PRODUCES break.c
-
-$BUILTIN break
-$FUNCTION break_builtin
-$SHORT_DOC break [n]
-Exit from within a FOR, WHILE or UNTIL loop. If N is specified,
-break N levels.
-$END
-
-#include "../shell.h"
-
-extern char *this_command_name;
-
-static int check_loop_level ();
-
-/* The depth of while's and until's. */
-int loop_level = 0;
-
-/* Non-zero when a "break" instruction is encountered. */
-int breaking = 0;
-
-/* Non-zero when we have encountered a continue instruction. */
-int continuing = 0;
-
-/* Set up to break x levels, where x defaults to 1, but can be specified
- as the first argument. */
-break_builtin (list)
- WORD_LIST *list;
-{
- int newbreak;
-
- if (!check_loop_level ())
- return (EXECUTION_FAILURE);
-
- newbreak = get_numeric_arg (list);
-
- if (newbreak <= 0)
- return (EXECUTION_FAILURE);
-
- if (newbreak > loop_level)
- newbreak = loop_level;
-
- breaking = newbreak;
-
- return (EXECUTION_SUCCESS);
-}
-
-$BUILTIN continue
-$FUNCTION continue_builtin
-$SHORT_DOC continue [n]
-Resume the next iteration of the enclosing FOR, WHILE or UNTIL loop.
-If N is specified, resume at the N-th enclosing loop.
-$END
-
-/* Set up to continue x levels, where x defaults to 1, but can be specified
- as the first argument. */
-continue_builtin (list)
- WORD_LIST *list;
-{
- int newcont;
-
- if (!check_loop_level ())
- return (EXECUTION_FAILURE);
-
- newcont = get_numeric_arg (list);
-
- if (newcont <= 0)
- return (EXECUTION_FAILURE);
-
- if (newcont > loop_level)
- newcont = loop_level;
-
- continuing = newcont;
-
- return (EXECUTION_SUCCESS);
-}
-
-/* Return non-zero if a break or continue command would be okay.
- Print an error message if break or continue is meaningless here. */
-static int
-check_loop_level ()
-{
-#if defined (BREAK_COMPLAINS)
- if (!loop_level)
- builtin_error ("Only meaningful in a `for', `while', or `until' loop");
-#endif /* BREAK_COMPLAINS */
-
- return (loop_level);
-}
+This file is break.def, from which is created break.c.
+It implements the builtins "break" and "continue" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES break.c
+
+$BUILTIN break
+$FUNCTION break_builtin
+$SHORT_DOC break [n]
+Exit from within a FOR, WHILE or UNTIL loop. If N is specified,
+break N levels.
+$END
+
+#include "../shell.h"
+
+extern char *this_command_name;
+
+static int check_loop_level ();
+
+/* The depth of while's and until's. */
+int loop_level = 0;
+
+/* Non-zero when a "break" instruction is encountered. */
+int breaking = 0;
+
+/* Non-zero when we have encountered a continue instruction. */
+int continuing = 0;
+
+/* Set up to break x levels, where x defaults to 1, but can be specified
+ as the first argument. */
+break_builtin (list)
+ WORD_LIST *list;
+{
+ int newbreak;
+
+ if (!check_loop_level ())
+ return (EXECUTION_FAILURE);
+
+ newbreak = get_numeric_arg (list);
+
+ if (newbreak <= 0)
+ return (EXECUTION_FAILURE);
+
+ if (newbreak > loop_level)
+ newbreak = loop_level;
+
+ breaking = newbreak;
+
+ return (EXECUTION_SUCCESS);
+}
+
+$BUILTIN continue
+$FUNCTION continue_builtin
+$SHORT_DOC continue [n]
+Resume the next iteration of the enclosing FOR, WHILE or UNTIL loop.
+If N is specified, resume at the N-th enclosing loop.
+$END
+
+/* Set up to continue x levels, where x defaults to 1, but can be specified
+ as the first argument. */
+continue_builtin (list)
+ WORD_LIST *list;
+{
+ int newcont;
+
+ if (!check_loop_level ())
+ return (EXECUTION_FAILURE);
+
+ newcont = get_numeric_arg (list);
+
+ if (newcont <= 0)
+ return (EXECUTION_FAILURE);
+
+ if (newcont > loop_level)
+ newcont = loop_level;
+
+ continuing = newcont;
+
+ return (EXECUTION_SUCCESS);
+}
+
+/* Return non-zero if a break or continue command would be okay.
+ Print an error message if break or continue is meaningless here. */
+static int
+check_loop_level ()
+{
+#if defined (BREAK_COMPLAINS)
+ if (!loop_level)
+ builtin_error ("Only meaningful in a `for', `while', or `until' loop");
+#endif /* BREAK_COMPLAINS */
+
+ return (loop_level);
+}
Index: builtin.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/builtin.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- builtin.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ builtin.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,67 +1,67 @@
-This file is builtin.def, from which is created builtin.c.
-It implements the builtin "builtin" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$PRODUCES builtin.c
-
-$BUILTIN builtin
-$FUNCTION builtin_builtin
-$SHORT_DOC builtin [shell-builtin [arg ...]]
-Run a shell builtin. This is useful when you wish to rename a
-shell builtin to be a function, but need the functionality of the
-builtin within the function itself.
-$END
-
-#include "../shell.h"
-
-#include "common.h"
-
-extern char *this_command_name;
-
-/* Run the command mentioned in list directly, without going through the
- normal alias/function/builtin/filename lookup process. */
-builtin_builtin (list)
- WORD_LIST *list;
-{
- Function *function;
- register char *command;
-
- if (!list)
- return (EXECUTION_SUCCESS);
-
- command = (list->word->word);
-#if defined (DISABLED_BUILTINS)
- function = builtin_address (command);
-#else /* !DISABLED_BUILTINS */
- function = find_shell_builtin (command);
-#endif /* !DISABLED_BUILTINS */
-
- if (!function)
- {
- builtin_error ("%s: not a shell builtin", command);
- return (EXECUTION_FAILURE);
- }
- else
- {
- this_command_name = command;
- list = list->next;
- return ((*function) (list));
- }
-}
+This file is builtin.def, from which is created builtin.c.
+It implements the builtin "builtin" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES builtin.c
+
+$BUILTIN builtin
+$FUNCTION builtin_builtin
+$SHORT_DOC builtin [shell-builtin [arg ...]]
+Run a shell builtin. This is useful when you wish to rename a
+shell builtin to be a function, but need the functionality of the
+builtin within the function itself.
+$END
+
+#include "../shell.h"
+
+#include "common.h"
+
+extern char *this_command_name;
+
+/* Run the command mentioned in list directly, without going through the
+ normal alias/function/builtin/filename lookup process. */
+builtin_builtin (list)
+ WORD_LIST *list;
+{
+ Function *function;
+ register char *command;
+
+ if (!list)
+ return (EXECUTION_SUCCESS);
+
+ command = (list->word->word);
+#if defined (DISABLED_BUILTINS)
+ function = builtin_address (command);
+#else /* !DISABLED_BUILTINS */
+ function = find_shell_builtin (command);
+#endif /* !DISABLED_BUILTINS */
+
+ if (!function)
+ {
+ builtin_error ("%s: not a shell builtin", command);
+ return (EXECUTION_FAILURE);
+ }
+ else
+ {
+ this_command_name = command;
+ list = list->next;
+ return ((*function) (list));
+ }
+}
Index: cd.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/cd.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cd.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ cd.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,693 +1,693 @@
-This file is cd.def, from which is created cd.c. It implements the
-builtins "cd", "pwd", "pushd", "popd", and "dirs" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
[...1355 lines suppressed...]
+ {
+ if (chdir (newdir) < 0)
+ return (0);
+ else
+ return (1);
+ }
+}
+
+/* Switch to the directory in NAME. This uses the cd_builtin to do the work,
+ so if the result is EXECUTION_FAILURE then an error message has already
+ been printed. */
+static int
+cd_to_string (name)
+ char *name;
+{
+ WORD_LIST *tlist = make_word_list (make_word (name), NULL);
+ int result = (cd_builtin (tlist));
+ dispose_words (tlist);
+ return (result);
+}
Index: colon.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/colon.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- colon.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ colon.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,37 +1,37 @@
-This file is colon.def, from which is created colon.c.
-It implements the builtin ":" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$PRODUCES colon.c
-
-$BUILTIN :
-$DOCNAME colon_builtin
-$FUNCTION colon_builtin
-$SHORT_DOC :
-No effect; the command does nothing. A zero exit code is returned.
-$END
-
-/* Do nothing. This command is a no-op. */
-int
-colon_builtin (ignore)
- char *ignore;
-{
- return (0);
-}
+This file is colon.def, from which is created colon.c.
+It implements the builtin ":" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES colon.c
+
+$BUILTIN :
+$DOCNAME colon_builtin
+$FUNCTION colon_builtin
+$SHORT_DOC :
+No effect; the command does nothing. A zero exit code is returned.
+$END
+
+/* Do nothing. This command is a no-op. */
+int
+colon_builtin (ignore)
+ char *ignore;
+{
+ return (0);
+}
Index: command.def
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/command.def,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- command.def 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ command.def 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,176 +1,176 @@
-This file is command.def, from which is created command.c.
-It implements the builtin "command" in Bash.
-
-Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
-This file is part of GNU Bash, the Bourne Again SHell.
-
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
-version.
-
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-$PRODUCES command.c
-
-$BUILTIN command
-$FUNCTION command_builtin
-$SHORT_DOC command [-pVv] [command [arg ...]]
-Runs COMMAND with ARGS ignoring shell functions. If you have a shell
-function called `ls', and you wish to call the command `ls', you can
-say "command ls". If the -p option is given, a default value is used
-for PATH that is guaranteed to find all of the standard utilities. If
-the -V or -v option is given, a string is printed describing COMMAND.
-The -V option produces a more verbose description.
-$END
-
-#if defined (HAVE_STRING_H)
-# include <string.h>
-#else /* !HAVE_STRING_H */
-# include <strings.h>
-#endif /* !HAVE_STRING_H */
-
-#include "../shell.h"
-#include "../nt_types.h"
-#include "bashgetopt.h"
-
-static void restore_path ();
-static char *get_standard_path ();
-
-/* Run the commands mentioned in LIST without paying attention to shell
- functions. */
-int
-command_builtin (list)
- WORD_LIST *list;
-{
- int result, verbose = 0, use_standard_path = 0, opt;
- char *old_path;
-
- reset_internal_getopt ();
- while ((opt = internal_getopt (list, "pvV")) != -1)
- {
- switch (opt)
- {
- case 'p':
- use_standard_path = 1;
- break;
- case 'V':
- verbose = 2;
- break;
- case 'v':
- verbose = 4;
- break;
-
- default:
- report_bad_option ();
- builtin_error ("usage: command [-pvV] [command [arg...]]");
- return (EX_USAGE);
- }
- }
- list = loptend;
-
- if (!list)
- return (EXECUTION_SUCCESS);
-
- if (verbose)
- {
- int found, any_found = 0;
-
- while (list)
- {
-
- found = describe_command (list->word->word, verbose, 0);
-
- if (!found)
- builtin_error ("%s: not found", list->word->word);
-
- any_found += found;
- list = list->next;
- }
- return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
- }
-
- begin_unwind_frame ("command_builtin");
-
- /* We don't want this to be reparsed (consider command echo 'foo &'), so
- just make a simple_command structure and call execute_command with it. */
- {
- COMMAND *command;
-
- if (use_standard_path)
- {
- char *standard_path;
-
- old_path = get_string_value ("PATH");
- if (old_path)
- old_path = savestring (old_path);
- else
- old_path = savestring ("");
- add_unwind_protect ((Function *)restore_path, old_path);
-
- standard_path = get_standard_path ();
- bind_variable ("PATH", standard_path);
- free (standard_path);
- }
- command = make_bare_simple_command ();
- command->value.Simple->words = (WORD_LIST *)copy_word_list (list);
- command->value.Simple->redirects = (REDIRECT *)NULL;
- command->flags |= (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION);
- 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)
- {
- command->flags |= CMD_NO_FORK;
- command->value.Simple->flags |= CMD_NO_FORK;
- }
- add_unwind_protect ((char *)dispose_command, command);
- result = execute_command (command);
- }
-
- run_unwind_frame ("command_builtin");
-
- return (result);
-}
-
-/* Restore the value of the $PATH variable after replacing it when
- executing `command -p'. */
-static void
-restore_path (var)
- char *var;
-{
- bind_variable ("PATH", var);
- free (var);
-}
-
-/* Return a value for PATH that is guaranteed to find all of the standard
- utilities. This uses Posix.2 configuration variables, if present. It
- uses a value defined in config.h as a last resort. */
-static char *
-get_standard_path ()
-{
-#if defined (_CS_PATH) && !defined (hpux_7) && !defined (NetBSD)
- char *p;
- size_t len;
-
- len = (size_t)confstr (_CS_PATH, (char *)NULL, (size_t)0);
- p = xmalloc ((int)len + 2);
- *p = '\0';
- confstr (_CS_PATH, p, len);
- return (p);
-#else /* !_CSPATH || hpux_7 || NetBSD */
-# if defined (CS_PATH)
- return (savestring (CS_PATH));
-# else
- return (savestring (STANDARD_UTILS_PATH));
-# endif /* !CS_PATH */
-#endif /* !_CS_PATH || hpux_7 */
-}
+This file is command.def, from which is created command.c.
+It implements the builtin "command" in Bash.
+
+Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 1, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+$PRODUCES command.c
+
+$BUILTIN command
+$FUNCTION command_builtin
+$SHORT_DOC command [-pVv] [command [arg ...]]
+Runs COMMAND with ARGS ignoring shell functions. If you have a shell
+function called `ls', and you wish to call the command `ls', you can
+say "command ls". If the -p option is given, a default value is used
+for PATH that is guaranteed to find all of the standard utilities. If
+the -V or -v option is given, a string is printed describing COMMAND.
+The -V option produces a more verbose description.
+$END
+
+#if defined (HAVE_STRING_H)
+# include <string.h>
+#else /* !HAVE_STRING_H */
+# include <strings.h>
+#endif /* !HAVE_STRING_H */
+
+#include "../shell.h"
+#include "../nt_types.h"
+#include "bashgetopt.h"
+
+static void restore_path ();
+static char *get_standard_path ();
+
+/* Run the commands mentioned in LIST without paying attention to shell
+ functions. */
+int
+command_builtin (list)
+ WORD_LIST *list;
+{
+ int result, verbose = 0, use_standard_path = 0, opt;
+ char *old_path;
+
+ reset_internal_getopt ();
+ while ((opt = internal_getopt (list, "pvV")) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ use_standard_path = 1;
+ break;
+ case 'V':
+ verbose = 2;
+ break;
+ case 'v':
+ verbose = 4;
+ break;
+
+ default:
+ report_bad_option ();
+ builtin_error ("usage: command [-pvV] [command [arg...]]");
+ return (EX_USAGE);
+ }
+ }
+ list = loptend;
+
+ if (!list)
+ return (EXECUTION_SUCCESS);
+
+ if (verbose)
+ {
+ int found, any_found = 0;
+
+ while (list)
+ {
+
+ found = describe_command (list->word->word, verbose, 0);
+
+ if (!found)
+ builtin_error ("%s: not found", list->word->word);
+
+ any_found += found;
+ list = list->next;
+ }
+ return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+ }
+
+ begin_unwind_frame ("command_builtin");
+
+ /* We don't want this to be reparsed (consider command echo 'foo &'), so
+ just make a simple_command structure and call execute_command with it. */
+ {
+ COMMAND *command;
+
+ if (use_standard_path)
+ {
+ char *standard_path;
+
+ old_path = get_string_value ("PATH");
+ if (old_path)
+ old_path = savestring (old_path);
+ else
+ old_path = savestring ("");
+ add_unwind_protect ((Function *)restore_path, old_path);
+
+ standard_path = get_standard_path ();
+ bind_variable ("PATH", standard_path);
+ free (standard_path);
+ }
+ command = make_bare_simple_command ();
+ command->value.Simple->words = (WORD_LIST *)copy_word_list (list);
+ command->value.Simple->redirects = (REDIRECT *)NULL;
+ command->flags |= (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION);
+ 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)
+ {
+ command->flags |= CMD_NO_FORK;
+ command->value.Simple->flags |= CMD_NO_FORK;
+ }
+ add_unwind_protect ((char *)dispose_command, command);
+ result = execute_command (command);
+ }
+
+ run_unwind_frame ("command_builtin");
+
+ return (result);
+}
+
+/* Restore the value of the $PATH variable after replacing it when
+ executing `command -p'. */
+static void
+restore_path (var)
+ char *var;
+{
+ bind_variable ("PATH", var);
+ free (var);
+}
+
+/* Return a value for PATH that is guaranteed to find all of the standard
+ utilities. This uses Posix.2 configuration variables, if present. It
+ uses a value defined in config.h as a last resort. */
+static char *
+get_standard_path ()
+{
+#if defined (_CS_PATH) && !defined (hpux_7) && !defined (NetBSD)
+ char *p;
+ size_t len;
+
+ len = (size_t)confstr (_CS_PATH, (char *)NULL, (size_t)0);
+ p = xmalloc ((int)len + 2);
+ *p = '\0';
+ confstr (_CS_PATH, p, len);
+ return (p);
+#else /* !_CSPATH || hpux_7 || NetBSD */
+# if defined (CS_PATH)
+ return (savestring (CS_PATH));
+# else
+ return (savestring (STANDARD_UTILS_PATH));
+# endif /* !CS_PATH */
+#endif /* !_CS_PATH || hpux_7 */
+}
Index: common.c
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/common.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- common.c 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ common.c 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,835 +1,835 @@
-/* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
[...1639 lines suppressed...]
+ {
+ case '"':
+ case '$':
+ case '`':
+#if defined (__NT_VC__)
+ case '\n':
+#endif /* __NT_VC__ */
+ case '\\':
+ result[j++] = '\\';
+ default:
+ result[j++] = c;
+ break;
+ }
+ }
+
+ result[j++] = '"';
+ result[j] = '\0';
+
+ return (result);
+}
Index: common.h
===================================================================
RCS file: /cvsroot/winbash/winbash/builtins/common.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- common.h 9 Mar 2002 03:39:12 -0000 1.1.1.1
+++ common.h 9 Mar 2002 04:20:36 -0000 1.2
@@ -1,69 +1,69 @@
-/* common.h -- extern declarations for functions defined in common.c. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (__COMMON_H)
-# define __COMMON_H
-
-#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
-
-extern void builtin_error ();
-extern void bad_option ();
-
-extern int get_numeric_arg ();
-
-extern void remember_args ();
-
-extern void no_args ();
-
-extern int read_octal ();
-
-extern char *find_hashed_filename ();
-extern void remove_hashed_filename ();
-extern void remember_filename ();
-
-extern void push_context (), pop_context ();
-extern void push_dollar_vars (), pop_dollar_vars ();
-extern void dispose_saved_dollar_vars ();
-extern int dollar_vars_changed ();
-extern void set_dollar_vars_unchanged (), set_dollar_vars_changed ();
-
-/* Keeps track of the current working directory. */
-__declspec (thread) extern char *the_current_working_directory;
-extern char *get_working_directory ();
-extern void set_working_directory ();
-
-#if defined (JOB_CONTROL)
-extern int get_job_spec ();
-#endif
-
-extern int parse_and_execute ();
-extern void parse_and_execute_cleanup ();
-
-extern void initialize_shell_builtins ();
-
-/* It's OK to declare a function as returning a Function * without
- providing a definition of what a `Function' is. */
-extern Function *find_shell_builtin ();
-extern Function *builtin_address ();
-
-extern char *single_quote ();
-extern char *double_quote ();
-
-#endif /* !__COMMON_H */
+/* common.h -- extern declarations for functions defined in common.c. */
+
+/* Copyright (C) 1993 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free soft...
[truncated message content] |