aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/readcons.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-13 18:03:41 +0000
committerrsc <devnull@localhost>2005-02-13 18:03:41 +0000
commitea77b9ce7c579a2e625806dc01104d5f6929cc43 (patch)
treec34a39f114225352ba989dd7738ddf6b73987ef2 /src/cmd/readcons.c
parent6e527fbc4d8f404a7eec934e5c9efaaaa92ffdff (diff)
downloadplan9port-ea77b9ce7c579a2e625806dc01104d5f6929cc43.tar.gz
plan9port-ea77b9ce7c579a2e625806dc01104d5f6929cc43.tar.bz2
plan9port-ea77b9ce7c579a2e625806dc01104d5f6929cc43.zip
new program readcons
Diffstat (limited to 'src/cmd/readcons.c')
-rw-r--r--src/cmd/readcons.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/cmd/readcons.c b/src/cmd/readcons.c
new file mode 100644
index 00000000..f0f8397f
--- /dev/null
+++ b/src/cmd/readcons.c
@@ -0,0 +1,39 @@
+#include <u.h>
+#include <libc.h>
+
+void
+usage(void)
+{
+ fprint(2, "usage: readcons [-s] [-d default] prompt\n");
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ char *def, *p;
+ int secret;
+
+ def = nil;
+ secret = 0;
+ ARGBEGIN{
+ case 's':
+ secret = 1;
+ break;
+ case 'd':
+ def = EARGF(usage());
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ if(argc != 1)
+ usage();
+
+ p = readcons(argv[0], def, secret);
+ if(p == nil)
+ exits("readcons");
+ print("%s\n", p);
+ exits(0);
+}
+