![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
which gives prompt> echo "\x \\ select * from foo;" | psql Expanded display is on. invalid command \ i.e. doesn't work on bash. With bash the command should be: echo -e "\x \n select * from foo;" | psql which gives prompt> echo -e "\x \n select * from foo;" | psql Expanded display is on. ERROR: relation "foo" does not exist Does this mean there are multiple forms of the echo command, or is this example just wrong? |
#3
| |||
| |||
|
|
On the psql man page there is an example of how to perform multiple line psql script as part of the -c option description. The example given is echo "\x \\ select * from foo;" | psql which gives prompt> echo "\x \\ select * from foo;" | psql Expanded display is on. invalid command \ i.e. doesn't work on bash. With bash the command should be: echo -e "\x \n select * from foo;" | psql which gives prompt> echo -e "\x \n select * from foo;" | psql Expanded display is on. ERROR: relation "foo" does not exist Does this mean there are multiple forms of the echo command, or is this example just wrong? |
#4
| |||
| |||
|
|
I think the proper fix is: application>psql</application>, like this: <literal>echo -e "\\x\nSELECT * FROM foo;" | psql</literal>. I think all modern operating systems understand echo -e at this point. |
#5
| |||
| |||
|
|
Bruce Momjian <bruce (AT) momjian (DOT) us> writes: I think the proper fix is: application>psql</application>, like this: <literal>echo -e "\\x\nSELECT * FROM foo;" | psql</literal>. I think all modern operating systems understand echo -e at this point. No, they don't, and neither does the Single Unix Spec: http://www.opengroup.org/onlinepubs/.../xcu/echo.html So your version of the example depends on non-standards-compliant echo behavior, which is not better than before. |
#6
| |||
| |||
|
|
Bruce Momjian <bruce (AT) momjian (DOT) us> writes: I think the proper fix is: application>psql</application>, like this: <literal>echo -e "\\x\nSELECT * FROM foo;" | psql</literal>. I think all modern operating systems understand echo -e at this point. No, they don't, and neither does the Single Unix Spec: http://www.opengroup.org/onlinepubs/.../xcu/echo.html So your version of the example depends on non-standards-compliant echo behavior, which is not better than before. |
#7
| |||
| |||
|
|
Tom Lane wrote: Bruce Momjian <bruce (AT) momjian (DOT) us> writes: I think the proper fix is: application>psql</application>, like this: <literal>echo -e "\\x\nSELECT * FROM foo;" | psql</literal>. I think all modern operating systems understand echo -e at this point. No, they don't, and neither does the Single Unix Spec: http://www.opengroup.org/onlinepubs/.../xcu/echo.html So your version of the example depends on non-standards-compliant echo behavior, which is not better than before. Well, at least my example works on _some_ operating systems, while the previous worked on none of them, so it is _better_. I can't think of a good way to do this except converting the example to a <programlisting> block that will not change newlines: echo '\x SELECT * FROM foo;' | psql Is that what people want? |
#8
| |||
| |||
|
|
On Tue, 2006-12-05 at 18:16 -0500, Bruce Momjian wrote: Tom Lane wrote: Bruce Momjian <bruce (AT) momjian (DOT) us> writes: I think the proper fix is: application>psql</application>, like this: <literal>echo -e "\\x\nSELECT * FROM foo;" | psql</literal>. I think all modern operating systems understand echo -e at this point. No, they don't, and neither does the Single Unix Spec: http://www.opengroup.org/onlinepubs/.../xcu/echo.html So your version of the example depends on non-standards-compliant echo behavior, which is not better than before. Well, at least my example works on _some_ operating systems, while the previous worked on none of them, so it is _better_. I can't think of a good way to do this except converting the example to a <programlisting> block that will not change newlines: echo '\x SELECT * FROM foo;' | psql Is that what people want? Well, it works, but IMHO its not as clear. |
#9
| |||
| |||
|
|
Well, it is even worse because some versions of echo automatically interpret backslashes, so it would have to be \\x. I am thinking we should just leave it as I have it now, unless we want to use 'awk' or 'perl' where we know the backslash behavior. |
#10
| |||
| |||
|
|
application>psql</application>, like this: <literal>echo "\x \\ select * from foo;" | psql</literal>. and I suppose the asumption was that the \\ would be at the end of the output line, but in fact both HTML and manual pages just put the \\ anywhere on the line. |
![]() |
| Thread Tools | |
| Display Modes | |
| |