Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Problem with arrays -- "unknown file attribute"



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