[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parse error running builtins from array

From: Chris F.A. Johnson
Subject: Re: parse error running builtins from array
Date: Wed, 29 Jul 2009 01:29:23 -0400 (EDT)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

On Tue, 28 Jul 2009, mk27 wrote:

> cc=('who' 'bash -c "time ls -l"' 'date')
> for e in 0 1 2; do ${cc[$e]}; done
> produces an error:
> ls: -c: line 0: unexpected EOF while looking for matching `"'
> ls: -c: line 1: syntax error: unexpected end of file
> well, there isn't a missing " AFAICT, and playing around with them has not
> helped.  Does anyone have a way out of this?

   Take a look at the arguments you are actually using:

printf "%s\n" ${cc[1]}

   Use eval:

for e in 0 1 2
  eval "${cc[$e]}"

   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]