Re: Crash in hashlib.c

2009-04-18 Thread Chet Ramey
Bernd Eggink wrote:
> Version: GNU bash, Version 4.0.17(1)-release (i686-pc-linux-gnu)
> (plus newline-shellmeta patch).
> 
> A script which uses, among other things, 3 associative arrays and a
> coprocess, crashes reproducibly with an allocation error:
> 
>malloc: hashlib.c:306: assertion botched
>free: called with unallocated block argument
>Abbruch...
>Program received signal SIGABRT, Aborted.
>0xe424 in __kernel_vsyscall ()
> 
> Appended is a stack trace. Hope it helps.

Unfortunately not much.  If you could post a portion of the script that
reproduces the error, that would be better.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: passing arrays as parameters to functions

2009-04-18 Thread Chris F.A. Johnson

On Fri, 17 Apr 2009, sharkura wrote:



I am looking for a way to pass an array variable as an argument to a
function.  The only remotely similar post I found dealt with spaces in
arguments, which is not my problem.

I want to pass three arguments to a function.  I want to receive them as
three positional parameters, $1 (an array), $2 (a scalar integer), and $3
(another scalar integer).  The integers are optional.

Currently, if I pass my array argument as ${arraya...@]}, the contents
actually expand to positional parameters $1, $2, ... $N.  I could just
assume that the last two positional parameters are my two integer arguments,
but I'd like them to be optional.  The size of the array is not fixed.


func()
{
  local f_array
  eval "f_array=( \"\${...@]}\" )"

  printf "%s\n" "${f_arr...@]}"
}

a=( qw er ty ui op )
func a

--
   Chris F.A. Johnson, webmaster 
   ===
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)




Re: passing arrays as parameters to functions

2009-04-18 Thread Mike Frysinger
On Friday 17 April 2009 12:29:29 sharkura wrote:
> I am looking for a way to pass an array variable as an argument to a
> function.  The only remotely similar post I found dealt with spaces in
> arguments, which is not my problem.
>
> I want to pass three arguments to a function.  I want to receive them as
> three positional parameters, $1 (an array), $2 (a scalar integer), and $3
> (another scalar integer).  The integers are optional.
>
> Currently, if I pass my array argument as ${arraya...@]}, the contents
> actually expand to positional parameters $1, $2, ... $N.  I could just
> assume that the last two positional parameters are my two integer
> arguments, but I'd like them to be optional.  The size of the array is not
> fixed.
>
> I've googled and searched this forum, but all the examples I've found use a
> global array that is not passed as an argument, but defined prior to the
> function that uses it.   Kind of ugly to me, but a solution if no other
> exists.

other options:
 - rebuild array using $@
 - pass var by reference and duplicate it manually in the function:
do_something arrayArg

otherwise, what you mention is best i could think of real quick ...
-mike


signature.asc
Description: This is a digitally signed message part.


passing arrays as parameters to functions

2009-04-18 Thread sharkura

I am looking for a way to pass an array variable as an argument to a
function.  The only remotely similar post I found dealt with spaces in
arguments, which is not my problem.

I want to pass three arguments to a function.  I want to receive them as
three positional parameters, $1 (an array), $2 (a scalar integer), and $3
(another scalar integer).  The integers are optional.

Currently, if I pass my array argument as ${arraya...@]}, the contents
actually expand to positional parameters $1, $2, ... $N.  I could just
assume that the last two positional parameters are my two integer arguments,
but I'd like them to be optional.  The size of the array is not fixed.

I've googled and searched this forum, but all the examples I've found use a
global array that is not passed as an argument, but defined prior to the
function that uses it.   Kind of ugly to me, but a solution if no other
exists.

Any suggestions?

Thanks

¦ {Þ
-- 
View this message in context: 
http://www.nabble.com/passing-arrays-as-parameters-to-functions-tp23101104p23101104.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.