Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problem with arrays -- "unknown file attribute"
- X-seq: zsh-users 13639
- From: "Webb Sprague" <webb.sprague@xxxxxxxxx>
- To: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- Subject: Re: Problem with arrays -- "unknown file attribute"
- Date: Mon, 5 Jan 2009 01:13:27 -0800
- Cc: "Zsh Users" <zsh-users@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=NFGOAW+Zh8/TZqY10eZH4TX3E8gfboVWgNfQ2DVYrMY=; b=KrvtQ+TMz3nF0Ism6lVUoy/D1SJ/+4SI5jnb+nkoGmikG+c2XrCrTTjLsGSl1D0anT FdW9bUVqrGwoeZ+Z+ROfihZ0H2uksmBycTFW8dt8TZT8o6PCYRACK1M4KDyCkp4r2ZUP UugvTeuev9Cz18q6OVH2SgskB9TiIhIXHOcJg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=s+mxpgZP06tjwS+Yd6lSlP4qas64ZHzh0vM6aLViAeLOwk/oS/NPeZOBGpG7moGu64 YeTl6Z46ZBQHfjVALKZhGNduPlTu0FRviMu5/DYlssSSievUyKcRdNSx5p5ytMuyMYCa Nw4QGZXdqvDlcWKAlJwsqfGOXIILnXWooO3t4=
- In-reply-to: <alpine.LNX.2.00.0901050308270.17470@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0901050004h4f1825egc01d39c1f74c0ef0@xxxxxxxxxxxxxx> <alpine.LNX.2.00.0901050308270.17470@xxxxxxxxxxxxxxx>
Hi Ben and all,
> TABS=( ${=$(sqlite3 $DB .tables)} )
> for TAB in $TABS ; do
> ...
>
This doesn't work. (Is there a simple way to assign an array,
something like "zsplit ARRAYVAR $STRINGVAR"; I had high hopes for
"set", but it doesn't split on anything.)
Here is a new function:
pop-colnames () {
IFS=
setopt errreturn
TABS=( ${=$(sqlite3 $DB .tables)} ) # your change
for TAB in $TABS; do # no longer a funky error message
echo \"$TAB\"
for COL in $COLS; do
echo $COL
#sqlite3 $DB "insert into row_meta (tname, colname) values
($TAB, ${COL//\"/});"
done
done
}
Here is the result (should be each table name on its own line):
(0) foobar:NLSY [0]% pop-colnames
<1123>
"DS0001 DS0003 DS0005 DS0007 DS0009 DS0011 DS0013 DS0015 DS0017 DS0019
DS0002 DS0004 DS0006 DS0008 DS0010 DS0012 DS0014 DS0016 DS0018 DS0020"
(0) foobar:NLSY [0]% zsh --version
<1124>
zsh 4.2.7 (i386-apple-darwin8.11.1)
Thanks Ben, for sustaining compulsive shell programmer during a late
night (though I am off to sleep...)!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author