User defined pipe and redirection operators: Difference between revisions
Content added Content deleted
m (moved Define pipe and redirection operators to User defined pipe and redirection operators: Objective of the task to to see if this is achievable, or can be closely achieved in a specific languages.) |
(For bonus Kudos: Implement the shell "&" concept as a dyadic operator in the specific language.) |
||
Line 9: | Line 9: | ||
If the language supports operator definition, then: |
If the language supports operator definition, then: |
||
* create "user defined" the equivalents of the Unix shell "<", "|", ">", "<<", ">>" and $(cmd) operators. |
* create "user defined" the equivalents of the Unix shell "<", "|", ">", "<<", ">>" and $(cmd) operators. |
||
* Provide simple equivalents of: cat, tee, grep, uniq, wc, head & tail, but as procedures native to the specific language. |
* Provide simple equivalents of: cat, tee, grep, uniq, wc, head & tail, but as filters/procedures native to the specific language. |
||
* Replicate the below sample shell script, but in the specific language |
* Replicate the below sample shell script, but in the specific language |
||
* Specifically ''do not'' cache the entire stream before the subsequent filter/procedure starts. Pass each record on as soon possible running all filters/procedures concurrently. |
|||
For bonus Kudos: Implement the shell "&" concept as a dyadic operator in the specific language. e.g.: <lang sh>( head x & tail x & wait ) | grep test</lang> |
|||
'''Alternately:''' if the language does not support operator definition then replace with: |
'''Alternately:''' if the language does not support operator definition then replace with: |
||
Line 18: | Line 21: | ||
'''Sample shell script:''' ''¢ draft - pending a better (more interesting) suggestion ¢'' |
'''Sample shell script:''' ''¢ draft - pending a better (more interesting) suggestion ¢'' |
||
<lang sh> |
<lang sh>aa="$( |
||
aa="$( |
|||
( |
( |
||
head -4 < List_of_computer_scientists.lst; |
head -4 < List_of_computer_scientists.lst; |
||
Line 27: | Line 29: | ||
); |
); |
||
echo "Pioneer: $aa" |
echo "Pioneer: $aa" |
||
</lang> |
</lang> |
||
'''Input File:''' |
'''Input File:''' |