summaryrefslogtreecommitdiff
path: root/bin/ksh/exec.c
diff options
context:
space:
mode:
authorCamiel Dobbelaar <camield@cvs.openbsd.org>2001-02-19 09:49:55 +0000
committerCamiel Dobbelaar <camield@cvs.openbsd.org>2001-02-19 09:49:55 +0000
commit147724caa4166bbf864e69d7c6009148b51da7db (patch)
treeb2581b725dcb21de1157fade3ca9cb9f23fd0d71 /bin/ksh/exec.c
parentdf3bcfa4b92155daf478bb54bc1b87efa61f5b18 (diff)
bash-like 'double-tab' completion
- bind TAB (^I) to complete-list by default - complete-list now lists 'ls style' not 'menu style' - complete-list first completes; if that does not work, it lists - fix a memleak in emacs.c, do_complete - completion now works after '=' (dd), and ':' (ssh) and ` (backtick) - a command can now start with a subdir from the current dir
Diffstat (limited to 'bin/ksh/exec.c')
-rw-r--r--bin/ksh/exec.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index 68443e8c521..ca696aa54bc 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.21 1999/07/15 20:35:33 millert Exp $ */
+/* $OpenBSD: exec.c,v 1.22 2001/02/19 09:49:52 camield Exp $ */
/*
* execute command tree
@@ -1595,7 +1595,39 @@ pr_menu(ap)
smi.arg_width = nwidth;
smi.num_width = dwidth;
print_columns(shl_out, n, select_fmt_entry, (void *) &smi,
- dwidth + nwidth + 2);
+ dwidth + nwidth + 2, 1);
+
+ return n;
+}
+
+/* XXX: horrible kludge to fit within the framework */
+
+static char *plain_fmt_entry ARGS((void *arg, int i, char *buf, int buflen));
+
+static char *
+plain_fmt_entry(arg, i, buf, buflen)
+ void *arg;
+ int i;
+ char *buf;
+ int buflen;
+{
+ shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
+ return buf;
+}
+
+int
+pr_list(ap)
+ char *const *ap;
+{
+ char *const *pp;
+ int nwidth;
+ int i, n;
+
+ for (n = 0, nwidth = 0, pp = ap; *pp; n++, pp++) {
+ i = strlen(*pp);
+ nwidth = (i > nwidth) ? i : nwidth;
+ }
+ print_columns(shl_out, n, plain_fmt_entry, (void *) ap, nwidth + 1, 0);
return n;
}