Re: Patch for autoload.v3 to allow export of function

2017-07-02 Thread Chet Ramey
On 7/1/17 5:50 PM, Matthew Persico wrote:
> Greetings!
> 
> I have finally gotten around to working on autoload again to ensure that
> there are no issues. But I have a question about the _AUTOLOADS array,
> which is used to track what has been autoloaded and is the source of
> information for the -p command.
> 
> The code executes a linear scan of the array _AUTOLOADS each time it has to
> find and element for removal or to make sure it is not about to add a
> duplicate entry. This is hardly very efficient. Would it be OK to convert
> that to an associative array (hash to us Perlers) indexed on function name?
> 
> I ask before submitting the patch because I am worried about backward
> compatibility; I do not know when hashes were added to bash nor do I know
> what the policy is about how far back compatibility has to be maintained.

Go ahead and submit the patch; if backwards compatibility is an issue, just
name it `autoload.v4'.  Associative arrays have been in bash since
bash-4.0, which was released in 2009, so including an updated version with
future bash distributions should not limit its usefulness.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: How to run bash test suite

2017-07-02 Thread Chet Ramey
On 7/2/17 3:30 AM, Phi Debian wrote:

> I grabed the latest source code available with my ubunto distro and
> made a bash build. All is fine. I'd like to run the test suite, and I
> found no docco about it. Did a brute "make test" from the build src
> dir, but I don't understand how to decipher all the output there,
> should I trust it and place it in a reference output before doing
> shell hacks experiments and rerun and compare outputs ? Or does the
> test self sufficient, i.e produce errors in its outputs ? I can see
> warning: may be errors will shows up as error: and then a simple make
> test >out 2>&1 is enough then grep error: out

`make tests' (or `test' or `check') from the build directory runs the
bash test suite.  The first thing it displays is intended to explain the
output:

"Any output from any test, unless otherwise noted, indicates a possible
anomaly"

The only output should be the name of the test (e.g., run-exp) and any
warnings that test displays about the expected output, e.g.

"warning: the text of a system error message may vary between systems and
warning: produce diff output."

If you get diff output (lines prefixed by `<' or `>') and there isn't a
warning associated with the test telling you it's expected, that's a
problem.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: Very minor fixes thanks to cppcheck

2017-07-02 Thread Nicola Spanti

Le 05/06/2017 14:06, Eric Blake a écrit :

On 06/04/2017 11:39 AM, Nicola Spanti wrote:

Hi.

I used that:
cppcheck --verbose --quiet --enable=all --force --language=c --std=c89 .

I fixed some errors that were reported by cppcheck. I published that on
GitLab.com.
https://gitlab.com/RyDroid/bash

The git remote is: https://rydr...@gitlab.com/RyDroid/bash.git
The branch is cppcheck-fix

Can you also post the patches directly to this list, rather than making
us chase a URL to see what the patch includes?
I attached it. I dit it on top of commit 
"bc007799f0e1362100375bb95d952d28de4c62fb".

Feel to merge it upstream. I don't ask credit for this tiny thing. Of
course, I give the copyright to the FSF.

Copyright assignment is more formal than that, if your patch is deemed
significant (small patches can be taken without assignment, but large
patches require actual paperwork and signatures, although these days
there are various countries where the paperwork is all electronic).

It is noting significant in the patch.
diff --git a/array.c b/array.c
index 6a6db77..4a930d0 100644
--- a/array.c
+++ b/array.c
@@ -391,7 +391,6 @@ array_remove_quoted_nulls(array)
 ARRAY  *array;
 {
ARRAY_ELEMENT   *a;
-   char*t;
 
if (array == 0 || array_head(array) == 0 || array_empty(array))
return (ARRAY *)NULL;
diff --git a/arrayfunc.c b/arrayfunc.c
index 47c595e..76db4b6 100644
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -258,9 +258,6 @@ bind_assoc_variable (entry, name, key, value, flags)
  char *value;
  int flags;
 {
-  SHELL_VAR *dentry;
-  char *newval;
-
   if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
 {
   if (readonly_p (entry))
@@ -280,7 +277,7 @@ assign_array_element (name, value, flags)
 {
   char *sub, *vname;
   int sublen;
-  SHELL_VAR *entry, *nv;
+  SHELL_VAR *entry;
 
   vname = array_variable_name (name, &sub, &sublen);
 
@@ -450,7 +447,6 @@ expand_compound_array_assignment (var, value, flags)
  int flags;
 {
   WORD_LIST *list, *nlist;
-  WORD_LIST *hd, *tl, *t, *n;
   char *val;
   int ni;
 
diff --git a/bashline.c b/bashline.c
index 0275844..e2951e2 100644
--- a/bashline.c
+++ b/bashline.c
@@ -751,14 +751,14 @@ snarf_hosts_from_file (filename)
  char *filename;
 {
   FILE *file;
-  char *temp, buffer[256], name[256];
+  char buffer[256], name[256];
   register int i, start;
 
   file = fopen (filename, "r");
   if (file == 0)
 return;
 
-  while (temp = fgets (buffer, 255, file))
+  while (fgets (buffer, 255, file))
 {
   /* Skip to first character. */
   for (i = 0; buffer[i] && cr_whitespace (buffer[i]); i++)
@@ -1056,7 +1056,7 @@ bash_forward_shellword (count, key)
  int count, key;
 {
   size_t slen;
-  int sindex, c, p;
+  int c, p;
   DECLARE_MBSTATE;
 
   if (count < 0)
@@ -1165,7 +1165,7 @@ bash_backward_shellword (count, key)
  int count, key;
 {
   size_t slen;
-  int sindex, c, p;
+  int c, p;
   DECLARE_MBSTATE;
   
   if (count < 0)
@@ -2705,9 +2705,10 @@ shell_expand_line (count, ignore)
   char *new_line;
   WORD_LIST *expanded_string;
 
-  new_line = 0;
 #if defined (BANG_HISTORY)
   new_line = history_expand_line_internal (rl_line_buffer);
+#else
+  new_line = 0;
 #endif
 
 #if defined (ALIAS)
@@ -3138,7 +3139,6 @@ bash_filename_stat_hook (dirname)
   int should_expand_dirname, return_value;
   int global_nounset;
   WORD_LIST *wl;
-  struct stat sb;
 
   local_dirname = *dirname;
   should_expand_dirname = return_value = 0;
@@ -3216,10 +3216,9 @@ bash_directory_completion_hook (dirname)
  char **dirname;
 {
   char *local_dirname, *new_dirname, *t;
-  int return_value, should_expand_dirname, nextch, closer, changed;
+  int return_value, should_expand_dirname, nextch, closer;
   size_t local_dirlen;
   WORD_LIST *wl;
-  struct stat sb;
 
   return_value = should_expand_dirname = nextch = closer = 0;
   local_dirname = *dirname;
@@ -4059,8 +4058,11 @@ static int
 putx(c)
  int c;
 {
+#ifndef _MINIX
   int x;
-  x = putc (c, rl_outstream);
+  x =
+#endif
+putc (c, rl_outstream);
 #ifndef _MINIX
   return x;
 #endif
@@ -4071,9 +4073,6 @@ bash_execute_unix_command (count, key)
  int count;/* ignored */
  int key;
 {
-  Keymap ckmap;/* current keymap */
-  Keymap xkmap;/* unix command executing keymap */
-  rl_command_func_t *func;
   int type;
   register int i, r;
   intmax_t mi;
diff --git a/braces.c b/braces.c
index 7f31dd5..8744da5 100644
--- a/braces.c
+++ b/braces.c
@@ -383,7 +383,7 @@ mkseq (start, end, incr, type, width)
  int type, width;
 {
   intmax_t n, prevn;
-  int i, j, nelem;
+  int i, nelem;
   char **result, *t;
 
   if (incr == 0)
@@ -494,7 +494,7 @@ expand_seqterm (text, tlen)
  size_t tlen;
 {
   char *t, *lhs, *rhs;
-  int i, lhs_t, rhs_t, lhs_l, rhs_l, width;
+  int lhs_t, rhs_t, lhs_l, rhs_l, width;
   intmax_t lhs_v, rhs_v, incr;
   intmax_t tl, tr;
   char **result, *ep, *oep;
diff --git a/examp

How to run bash test suite

2017-07-02 Thread Phi Debian
Hi All,
I tried to subscribe to bug-bash but never got the confirmation mail.

I grabed the latest source code available with my ubunto distro and
made a bash build. All is fine. I'd like to run the test suite, and I
found no docco about it. Did a brute "make test" from the build src
dir, but I don't understand how to decipher all the output there,
should I trust it and place it in a reference output before doing
shell hacks experiments and rerun and compare outputs ? Or does the
test self sufficient, i.e produce errors in its outputs ? I can see
warning: may be errors will shows up as error: and then a simple make
test >out 2>&1 is enough then grep error: out

Any help appreciated.
Cheers,
Phi