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"
|