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

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



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