Thread: psql -F problems
hi according to docs -F parameter given to psql is equivalent to \f or \pset fieldset in psql itself. this is usually true, but if i'll try to use "tab" as field separator, i cannot enter it like this: psql -c "something" -A -t -F '\t' it just returns fields separated by literally '\t', and not by tab-space character. yet, entering the same in psql as \f '\t' works great. i belive this is just simple ommision in argument parsing, but i belive it should be corrected to maintain uniform way of communication with user. best regards hubert depesz lubaczewski --=20 hubert depesz lubaczewski http://www.depesz.pl/ najwspanialsz=B1 rzecz=B1 jak=B1 da=B3o nam nowoczesne spo=B3ecze=F1st= wo, jest niesamowita wr=EAcz =B3atwo=B6=E6 unikania kontakt=F3w z nim ...
Hubert depesz Lubaczewski writes: > this is usually true, but if i'll try to use "tab" as field separator, i > cannot enter it like this: > psql -c "something" -A -t -F '\t' > it just returns fields separated by literally '\t', and not by tab-space > character. This command is parsed by the shell, so psql cannot do anything about it. Maybe -F $'\t' works in your shell. -- Peter Eisentraut peter_e@gmx.net
Peter Eisentraut <peter_e@gmx.net> writes: > Hubert depesz Lubaczewski writes: >> this is usually true, but if i'll try to use "tab" as field separator, i >> cannot enter it like this: >> psql -c "something" -A -t -F '\t' >> it just returns fields separated by literally '\t', and not by tab-space >> character. > This command is parsed by the shell, so psql cannot do anything about it. I think Hubert is right: psql is treating command-line -F strings differently from the argument of \f. Seems like a bug to me too. regards, tom lane
Hubert depesz Lubaczewski writes: > i belive this kind of information - given from command line - should be > parsed again in psql itself - just like it is parsed when you enter > something at psql prompt. The command line parser inside psql works pretty much like a Unix shell. That means quoting and escaping is resolved *before* the arguments are passed to the command. So when you enter \f '\t' then the parser resolves this as two tokens: the first is <backslash><f> and the second is <tab character>. The \f command and ultimately the routine that sets the field separator have nothing to do with that. I believe this design is ok, even though it creates apparent inconsistencies. If you make it behave like you appear to imagine, then you need to double-escape certain characters in situations where other users might not expect it. -- Peter Eisentraut peter_e@gmx.net
Most shells allow you to enter in a tab easily. In bash, you need to type control-V followed by a tab. I.e. type -F ", followed by the Control-V/tab key sequence and the closing double quote. Llew
> > Most shells allow you to enter in a tab easily. In bash, > you need to > > type control-V followed by a tab. I.e. type -F ", followed by the > > Control-V/tab key sequence and the closing double quote. > > i know. i can even do: > psql -c "something" -F "something_weird" | sed > 's/something_weird/ /g' yet Very curious now. So how would you enter the tab on the command line for sed? > depesz > > -- > hubert depesz lubaczewski > http://www.depesz.pl/ Leo
On Thu, Feb 27, 2003 at 05:35:56PM -0000, Llew Sion Goodstadt wrote: > Very curious now. So how would you enter the tab on the command line for > sed? with ctrl-v ctrl-tab. YES. i know it is possible to enter tab character itself. and yes - i can work without it. yet - i still belive that allowing \t in psql and not allowing \t from commandline is bug and should be fixed. depesz -- hubert depesz lubaczewski http://www.depesz.pl/ i choose to hate people when they're not polite; bruise me; that's allright. bananafishbones "pow wow"
On Mon, Feb 24, 2003 at 11:19:18AM -0000, Llew Sion Goodstadt wrote: > Most shells allow you to enter in a tab easily. In bash, you need to > type control-V followed > by a tab. I.e. type -F ", followed by the Control-V/tab key sequence and > the closing double quote. i know. i can even do: psql -c "something" -F "something_weird" | sed 's/something_weird/ /g' yet - this is inconsistency - between different methods of setting particular parameter. depesz -- hubert depesz lubaczewski http://www.depesz.pl/ i choose to hate people when they're not polite; bruise me; that's allright. bananafishbones "pow wow"