-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBQ.html
134 lines (134 loc) · 6.71 KB
/
BQ.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type"
content="text/html; charset=UTF-8">
<meta name="description"
content="sweave generated">
</head><body><font face="Sorts Mill Goudy">
<p align="justify"><font face="Sorts Mill Goudy">
<h1>BQ - Execute a shell command line and capture stdout</h1>
</font></p>
<p align="justify"><font face="Sorts Mill Goudy">
Like <font face="Source Code Pro">SHELL</font> backquotes (hence the name). Optional second arg is
string to use to separate lines.
</font></p>
<p align="justify"><font face="Sorts Mill Goudy">
This doesn't work when <font face="Source Code Pro">DDT</font> is used. The <font face="Source Code Pro">INPUT()</font> fails
when traced. Previously, it failed when garbage collect occurred,
but that has been fixed. To fix this, <font face="Source Code Pro">BQ()</font> is a wrapper which
disables <font face="Source Code Pro">DDT</font> and then calls the 'real' function <font face="Source Code Pro">BQ2()</font>.
</font></p>
<p align="justify"><font face="Sorts Mill Goudy">
<h2>Uses</h2>
</font></p>
<p align="justify"><font face="Sorts Mill Goudy">
<h2>See Also</h2>
<a href="DDT.html">DDT</a>
</font></p>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«INCLUDES»≡</b>
<b>@</b>
</font></pre></div>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«BQ»≡</b>
-WEAK DDT_ACTIVE, DDT_SUSPEND(), DDT_RESUME()
-PUBLIC BQ()
<font color="#818181"><i>*</i></font>
DEFINE('BQ(COMMAND,OFS)DDTF')
DEFINE('BQ2(COMMAND,OFS)X,UNIT') <b>:(BQ_END)</b>
<font color="#818181"><i>*</i></font>
<b>@</b>
</font></pre></div>
<p align="justify"><font face="Sorts Mill Goudy">
<font face="Source Code Pro">DDT_ACTIVE</font> is set if <font face="Source Code Pro">DDT</font> is active. If <font face="Source Code Pro">DDT</font> is not
active, or hasn't been loaded at all, <font face="Source Code Pro">DDT_ACTIVE</font> will evaluate to
<font face="Source Code Pro">NULL</font>. Note that SNOBOL4 will not complain about a missing function
unless we actually try to execute it. Thus, this works whether or not
<font face="Source Code Pro">DDT</font> is actually in use. <font face="Source Code Pro">BQ2()</font> may succeed or fail. In both
cases, we want to re-enable <font face="Source Code Pro">DDT</font> if it was loaded and active,
and pass the success or failure to the caller of <font face="Source Code Pro">BQ()</font>.
</font></p>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«BQ»≡</b>
BQ DDTF = DDT_ACTIVE
NE(DDTF) DDT_SUSPEND()
BQ = BQ2(COMMAND, OFS) <b>:F(BQ3)</b>
NE(DDTF) DDT_RESUME() <b>:(RETURN)</b>
BQ3 NE(DDTF) DDT_RESUME() <b>:(FRETURN)</b>
<b>@</b>
</font></pre></div>
<p align="justify"><font face="Sorts Mill Goudy">
The actual <font face="Source Code Pro">BQ</font> implementation. Open the command using <font face="Source Code Pro">PIPE open</font>.
Read lines and assemble the response. Use space <font face="Source Code Pro">' '</font> as a separator
if no explicit separator was provided.
</font></p>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«BQ»≡</b>
BQ2 UNIT = IO_FINDUNIT() <b>:F(FRETURN)</b>
INPUT(.X, UNIT,, '|' COMMAND) <b>:F(FRETURN)</b>
OFS = IDENT(OFS) ' '
BQ2 = X <b>:S(BQ4)</b>
ENDFILE(UNIT)
DETACH(.X) <b>:(FRETURN)</b>
BQ4 BQ2 = BQ2 OFS X <b>:S(BQ4)</b>
ENDFILE(UNIT)
DETACH(.X) <b>:(RETURN)</b>
<font color="#818181"><i>*</i></font>
BQ_END
<b>@</b>
</font></pre></div>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«unit_test»≡</b>
<font color="#818181"><i>#!/usr/bin/bash</i></font>
exec "snobol4" "-b" "$0" "$@"
-INCLUDE 'BQ.INC'
&CODE = 1
&CODE = 0
END
<b>@</b>
</font></pre></div>
<div style="background-image: url(greenbar.gif)">
<pre><font face="Source Code Pro">
<b>«»≡</b>
-MODULE BQ
<b>«INCLUDES»</b>
-IN72
-STITL BQ
-EJECT
<font color="#818181"><i>*</i></font>
<font color="#818181"><i>************************************************************************</i></font>
<font color="#818181"><i>* *</i></font>
<font color="#818181"><i>* ###### ##### *</i></font>
<font color="#818181"><i>* # # # # *</i></font>
<font color="#818181"><i>* # # # # *</i></font>
<font color="#818181"><i>* ###### # # *</i></font>
<font color="#818181"><i>* # # # # # *</i></font>
<font color="#818181"><i>* # # # # *</i></font>
<font color="#818181"><i>* ###### #### # *</i></font>
<font color="#818181"><i>* *</i></font>
<font color="#818181"><i>* BQ EXECUTE A SHELL COMMAND LINE AND CAPTURE STDOUT *</i></font>
<font color="#818181"><i>* *</i></font>
<font color="#818181"><i>* P BUDNE, JUNE 20, 1994 *</i></font>
<font color="#818181"><i>* *</i></font>
<font color="#818181"><i>************************************************************************</i></font>
<font color="#818181"><i>*</i></font>
<font color="#818181"><i>* BQ.lss</i></font>
<font color="#818181"><i>*</i></font>
<b>«BQ»</b>
<font color="#818181"><i>*</i></font>
<font color="#818181"><i>* CE: .MSNOBOL4;</i></font>
<b>@</b>
</font></pre></div>
<footer><hr><table width="100%" border="0">
<tr><td><p align=left>
Produced by <code>sweave</code>
</p></td><td><p align=center>
Sun Aug 31 15:19:21 EDT 2014</p></td><td><p align=right>
Return to <a href="index.html">index</a>
</p></td></table></footer>
</font></body></html>