ref: e1fc03c875e12e40be5ac70f244ef19ce1fb6339
parent: 26d7e6a759780a68f3993cd6497ea7f5b2e75b96
author: cinap_lenrek <cinap_lenrek@felloff.net>
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;
--
⑨