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

Script interpreting a command strangely



#!/usr/bin/env zsh
PGOPT=' -q -A -t -U mkn_f -h xxx.yyy.pdx.edu zzz' # command for DB
PG="psql $PGOPT "
psql $PGOPT
$PG
echo psql $PGOPT

If I run I get this I get

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Then:

./stupid.zsh:6: command not found: psql  -q -A -t -U mkn_f -h
xxx.yyy.pdx.edu zzz

But if I run the echoed command it works just fine (the database and
host names have been changed to protect...)  I guess zsh is first
running psql without passing it the options in $PGOPT, and then trying
to run a file name 'psql -A blah blah blah'.  Neither of these seems
very sensical behaviors for a shell scripting language.  Come someone
help me make it stop?  Or tell me how to cope with it in a more
zsh-idiom? I find myself often putting a command with a bunch of
command switches.  I am sure this has to do with wordsplitting, but I
am to stupid to figure it out.  It seems that setopt shwordsplit is a
little drastic, too.

zsh --version:  4.2.6

If I run the script from bash I get

(0) dkar:~/MKN/importdata/bea-2008-01-07-CA-1-3 [0]% bash stupid.zsh
                                                           <861>
psql: could not translate host name "xxx.yyy.pdx.edu" to address: Name
or service not known
psql: could not translate host name "xxx.yyy.pdx.edu" to address: Name
or service not known
psql -q -A -t -U mkn_f -h xxx.yyy.pdx.edu zzz

This means that it understands the options and is trying to resolve xxx.yyy....



Tx
-W



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