We need the "source" command to support standard out so that I can execute ...
"echo ls > source" or ...
"cat sqlfile.sql | source" or ... can I do a
"source < sqlfile.sql"?
Future pipeline possibility (pipeing ddl from one server to execute on another server without waiting for one command to stream to file before beginning) :
sqldump -k other_connection | source
"echo ls > source" or ...
"cat sqlfile.sql > source" or ... can I do a
I think you meant pipelining through standard I/O. The above commands would output the result to the file named "source", and Bash does the same way.
"source < sqlfile.sql"?
There is no need for the "<" standard input redirector as you can pass the file as an argument directly to the \source command.
Modified \source to support reading input from standard input, man page is updated as well. Syntax to execute \source now is one of the followings:
(1) \source [OPTION...] FILE [ARGUMENT...]
(2) \source [OPTION...]
The second form above will read input from standard input, note that ARGUMENT is not applied in this case. In fact, even for (1) above, ARGUMENTs would not take effect when sourcing a file containing fluid shell commands; this is because fluid shell does not support shell positional parameters ($0, $1, etc).
After this fix is applied, the following 2 commands should generate the same result:
prompt$ \source test.sh
prompt$ cat test.sh | \source
Note that you can execute \source as the case shown below and then start typing in commands for source to execute:
prompt$ \source
However, don't expect \source would execute the command you just typed once <Enter> key is pressed. You likely won't see commands get executed until you hit Control-D. This is because there is a 8K buffer involved which will buffer your input.
By the way, on UNIX, source is one of shell's builtin commands. Its syntax is one of the followings (. is the synonym for source):
source filename [argument...]
. filename [argument...]
As you can see, UNIX source command does not support reading input from standard input.
Modified \source to support reading input from standard input, man page is updated as well. Syntax to execute \source now is one of the followings:
(1) \source [OPTION...] FILE [ARGUMENT...]
(2) \source [OPTION...]
The second form above will read input from standard input, note that ARGUMENT is not applied in this case. In fact, even for (1) above, ARGUMENTs would not take effect when sourcing a file containing fluid shell commands; this is because fluid shell does not support shell positional parameters ($0, $1, etc).
After this fix is applied, the following 2 commands should generate the same result:
prompt$ \source test.sh
prompt$ cat test.sh | \source
Note that you can execute \source as the case shown below and then start typing in commands for source to execute:
prompt$ \source
However, don't expect \source would execute the command you just typed once <Enter> key is pressed. You likely won't see commands get executed until you hit Control-D. This is because there is a 8K buffer involved which will buffer your input.
By the way, on UNIX, source is one of shell's builtin commands. Its syntax is one of the followings (. is the synonym for source):
source filename [argument...]
. filename [argument...]
As you can see, UNIX source command does not support reading input from standard input.
Verified using ADStudio 12 Beta 38 the changes mentioned by Fung.
Also added regression tests for:
* output redirect
source file > out
* output redirect append
source file >> out
* output via pipe
source file | cat
* input redirect
source < file
* input via pipe
cat file | source
Closed.
Verified using ADStudio 12 Beta 38 the changes mentioned by Fung.
Also added regression tests for:
* output redirect
source file > out
* output redirect append
source file >> out
* output via pipe
source file | cat
* input redirect
source < file
* input via pipe
cat file | source
Closed.
Issue #7556 |
| Closed |
| Fixed |
| Resolved |
Completion |
| No due date |
| Fixed Build trunk/29227 |
| No time estimate |
I think you meant pipelining through standard I/O. The above commands would output the result to the file named "source", and Bash does the same way.
There is no need for the "<" standard input redirector as you can pass the file as an argument directly to the \source command.