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

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



> So doesn't that just mean you need space *and* newline in IFS?

Yes, it does.  I had thought that multiple characters in IFS would
logically "and" together, rather than "or"

>
> I think you should also be able to use:
>
>    TABS=(${(ps:\n: :)"$(sqlite3 $DB .tables)"})

Hehe... I can't say that really appeals to me in terms of grace and
simplicity....

> Either way, you'll have a problem if table names contain spaces.

I would have a bigger problem if I wrote databases with tables that
contain spaces...  Not that it doesn't happen...

Here is the (so far) working function:

pop-colnames () {
    local IFS=$' \t\n'    # both spaces
    setopt errreturn
    TABS=($(sqlite3 $DB .tables))
    for TAB in $TABS; do
        echo \"$TAB\"
        for COL in $COLS; do
            echo $COL
            #sqlite3 $DB "insert into row_meta (tname, colname) values
($TAB, ${COL//\"/});"
        done
    done
}

Thanks everyone!



Messages sorted by: Reverse Date, Date, Thread, Author