ref: 4b9ccb2de0466dd3cabc50b2e8e9d709b94d9bb9
parent: a6fde3edc5ec390d23e50110c93492d42f1e23e1
author: cinap_lenrek <[email protected]>
date: Fri Aug 30 16:17:19 EDT 2019
ndb/dnsquery, ndb/csquery: write ">" prompt to stderr (thanks kvik) kvik writes: dnsquery(8) prints the interactive prompt on stdout together with query results, making scripted usage unnecessarily difficult. A straightforward solution is prompting on stderr instead: as practiced by rc(1), among many others -- promptly taking care of the issue: ; echo 9front.org mx | ndb/dnsquery >[2]/dev/null
--- a/sys/src/cmd/ndb/csquery.c
+++ b/sys/src/cmd/ndb/csquery.c
@@ -68,7 +68,7 @@
Binit(&in, 0, OREAD);
for(;;){
- print("> ");
+ fprint(2, "> ");
p = Brdline(&in, '\n');
if(p == 0)
break;
--- a/sys/src/cmd/ndb/dnsquery.c
+++ b/sys/src/cmd/ndb/dnsquery.c
@@ -58,7 +58,7 @@
Biobuf in;
Binit(&in, 0, OREAD);
- for(print("> "); lp = Brdline(&in, '\n'); print("> ")){
+ for(fprint(2, "> "); lp = Brdline(&in, '\n'); fprint(2, "> ")){
n = Blinelen(&in) -1;
while(isspace(lp[n]))
lp[n--] = 0;