Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problem with arrays -- "unknown file attribute"
- X-seq: zsh-users 13648
- From: "Webb Sprague" <webb.sprague@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Problem with arrays -- "unknown file attribute"
- Date: Mon, 5 Jan 2009 10:42:09 -0800
- 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:in-reply-to:mime-version:content-type         :content-transfer-encoding:content-disposition:references;        bh=i1mE4D32MYpQGRUaSYPas0FeIY7bFo7EGis0NEQmB2E=;        b=C9sCdZ4+lu5bKyolO7rm20vZ7sok0h5L+IW06gZXDvADXKnUWM2ujhQh3LsfVVroRU         mKNLoxbRd+aRZsISmh1H35qBn3AO4HWtz9vEt6XcnF48ZOOdyq8o8KlDvWXLZP2x/cai         AXrZvMegRTfvVl8jH4I/6mdBkA4YqrZoPUj7A=
- Domainkey-signature: a=rsa-sha1; c=nofws;        d=gmail.com; s=gamma;        h=message-id:date:from:to:subject:in-reply-to:mime-version         :content-type:content-transfer-encoding:content-disposition         :references;        b=IIZif8O7NKdWdRALC8sifK6JmpN2YJ9QQfKCZmfvO3h1uKve2sljHwyKTY7ntYPvWo         LRP43FGfZn0sIc9ptB91RPlqVcVPjor+NYEwr6Rp5tKhbuilCRU173q5XHGmWCyKIKQa         SeuI1uVHBHxd2X0R8/ENoOX+yXkEvzipiZFok=
- In-reply-to: <20090105181731.GA4857@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0901050004h4f1825egc01d39c1f74c0ef0@xxxxxxxxxxxxxx>	 <alpine.LNX.2.00.0901050308270.17470@xxxxxxxxxxxxxxx>	 <20090105092403.GA7733@xxxxxxxxxxxxxxx>	 <alpine.LNX.2.00.0901050426390.17470@xxxxxxxxxxxxxxx>	 <m3fxjxenta.fsf@xxxxxxxxxxxxxx>	 <b11ea23c0901050931q790f8804tdbc8807c0c51a086@xxxxxxxxxxxxxx>	 <20090105181731.GA4857@xxxxxxxxxxxxxxx>
Thanks Stephane for all your comments on zsh scripting.  I just have
one question below...
> Or you could keep the default value of IFS which in zsh is
> $' \t\n\0' (in other shells it's $' \t\n' as they don't support
> the NUL character anyway).
What does the dollar do in IFS?  I actually have to get rid of it in
order to make the script work.  I think it might be part of the reason
all of my array conversions have been giving me hell, actually.
Here is a working function (so far -- the inserts might have something lurking):
pop-colnames () {
    setopt localoptions errreturn
    local IFS=' \t\n'
    TABS=($(sqlite3 $DB .tables))
    for TAB in $TABS; do
        echo $TAB 2>&1
        COLS=($(sqlite3 $DB "select * from $TAB where ROWID=1;"| sed
's/\"//g' | sed 's/|/\\t/g'))
        for COL in $COLS; do
            echo sqlite3 $DB "insert into row_meta (tname, colname)
values ('$TAB', '$COL');"
        done
    done
}
>>     TABS=($(sqlite3 $DB .tables))
>
> Note that in other shells, you would need to disable globbing as
> well to avoid problems with characters like *, ? or [. You don't
> need that with zsh as zsh doesn't perform filename generation
> upon command substitution.
Yeah, I try to keep silly characters out of my table names ....
>
>>     for TAB in $TABS; do
>>         echo \"$TAB\
> Note that the echo command expands the \n, \a... sequences. You
> may prefer the print -r --  or printf commands instead (or echo
> -E - which is zsh specific).
Yeah, old habits, but it is just for debugging (I am a printf maniac
when I need to be....)
Thanks again!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author