Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 1 | This file is bind.def, from which is created bind.c. |
| 2 | It implements the builtin "bind" in Bash. |
| 3 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 4 | Copyright (C) 1987-2009 Free Software Foundation, Inc. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 5 | |
| 6 | This file is part of GNU Bash, the Bourne Again SHell. |
| 7 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 8 | Bash is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 12 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 13 | Bash is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 17 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 18 | You should have received a copy of the GNU General Public License |
| 19 | along with Bash. If not, see <http://www.gnu.org/licenses/>. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 20 | |
| 21 | $PRODUCES bind.c |
| 22 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 23 | #include <config.h> |
| 24 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 25 | $BUILTIN bind |
| 26 | $DEPENDS_ON READLINE |
| 27 | $FUNCTION bind_builtin |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 28 | $SHORT_DOC bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command] |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 29 | Set Readline key bindings and variables. |
| 30 | |
| 31 | Bind a key sequence to a Readline function or a macro, or set a |
| 32 | Readline variable. The non-option argument syntax is equivalent to |
| 33 | that found in ~/.inputrc, but must be passed as a single argument: |
| 34 | e.g., bind '"\C-x\C-r": re-read-init-file'. |
| 35 | |
| 36 | Options: |
| 37 | -m keymap Use KEYMAP as the keymap for the duration of this |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 38 | command. Acceptable keymap names are emacs, |
| 39 | emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, |
| 40 | vi-command, and vi-insert. |
| 41 | -l List names of functions. |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 42 | -P List function names and bindings. |
| 43 | -p List functions and bindings in a form that can be |
| 44 | reused as input. |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 45 | -S List key sequences that invoke macros and their values |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 46 | -s List key sequences that invoke macros and their values |
| 47 | in a form that can be reused as input. |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 48 | -V List variable names and values |
| 49 | -v List variable names and values in a form that can |
| 50 | be reused as input. |
| 51 | -q function-name Query about which keys invoke the named function. |
| 52 | -u function-name Unbind all keys which are bound to the named function. |
| 53 | -r keyseq Remove the binding for KEYSEQ. |
| 54 | -f filename Read key bindings from FILENAME. |
| 55 | -x keyseq:shell-command Cause SHELL-COMMAND to be executed when |
| 56 | KEYSEQ is entered. |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 57 | -X List key sequences bound with -x and associated commands |
| 58 | in a form that can be reused as input. |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 59 | |
| 60 | Exit Status: |
| 61 | bind returns 0 unless an unrecognized option is given or an error occurs. |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 62 | $END |
| 63 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 64 | #if defined (READLINE) |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 65 | |
| 66 | #if defined (HAVE_UNISTD_H) |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 67 | # ifdef _MINIX |
| 68 | # include <sys/types.h> |
| 69 | # endif |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 70 | # include <unistd.h> |
| 71 | #endif |
| 72 | |
| 73 | #include <stdio.h> |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 74 | #include <errno.h> |
| 75 | #if !defined (errno) |
| 76 | extern int errno; |
| 77 | #endif /* !errno */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 78 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 79 | #include <readline/readline.h> |
| 80 | #include <readline/history.h> |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 81 | |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 82 | #include "../bashintl.h" |
| 83 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 84 | #include "../shell.h" |
| 85 | #include "../bashline.h" |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 86 | #include "bashgetopt.h" |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 87 | #include "common.h" |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 88 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 89 | static int query_bindings __P((char *)); |
| 90 | static int unbind_command __P((char *)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 91 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 92 | extern int no_line_editing; |
| 93 | |
| 94 | #define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0) |
| 95 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 96 | #define LFLAG 0x0001 |
| 97 | #define PFLAG 0x0002 |
| 98 | #define FFLAG 0x0004 |
| 99 | #define VFLAG 0x0008 |
| 100 | #define QFLAG 0x0010 |
| 101 | #define MFLAG 0x0020 |
| 102 | #define RFLAG 0x0040 |
| 103 | #define PPFLAG 0x0080 |
| 104 | #define VVFLAG 0x0100 |
| 105 | #define SFLAG 0x0200 |
| 106 | #define SSFLAG 0x0400 |
| 107 | #define UFLAG 0x0800 |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 108 | #define XFLAG 0x1000 |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 109 | #define XXFLAG 0x2000 |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 110 | |
| 111 | int |
| 112 | bind_builtin (list) |
| 113 | WORD_LIST *list; |
| 114 | { |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 115 | int return_code; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 116 | Keymap kmap, saved_keymap; |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 117 | int flags, opt; |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 118 | char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 119 | |
| 120 | if (no_line_editing) |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 121 | { |
| 122 | #if 0 |
| 123 | builtin_error (_("line editing not enabled")); |
| 124 | return (EXECUTION_FAILURE); |
| 125 | #else |
| 126 | builtin_warning (_("line editing not enabled")); |
| 127 | #endif |
| 128 | } |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 129 | |
| 130 | kmap = saved_keymap = (Keymap) NULL; |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 131 | flags = 0; |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 132 | initfile = map_name = fun_name = unbind_name = remove_seq = (char *)NULL; |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 133 | return_code = EXECUTION_SUCCESS; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 134 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 135 | if (bash_readline_initialized == 0) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 136 | initialize_readline (); |
| 137 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 138 | begin_unwind_frame ("bind_builtin"); |
| 139 | unwind_protect_var (rl_outstream); |
| 140 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 141 | rl_outstream = stdout; |
| 142 | |
| 143 | reset_internal_getopt (); |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 144 | while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != EOF) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 145 | { |
| 146 | switch (opt) |
| 147 | { |
| 148 | case 'l': |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 149 | flags |= LFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 150 | break; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 151 | case 'v': |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 152 | flags |= VFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 153 | break; |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 154 | case 'p': |
| 155 | flags |= PFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 156 | break; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 157 | case 'f': |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 158 | flags |= FFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 159 | initfile = list_optarg; |
| 160 | break; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 161 | case 'm': |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 162 | flags |= MFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 163 | map_name = list_optarg; |
| 164 | break; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 165 | case 'q': |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 166 | flags |= QFLAG; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 167 | fun_name = list_optarg; |
| 168 | break; |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 169 | case 'u': |
| 170 | flags |= UFLAG; |
| 171 | unbind_name = list_optarg; |
| 172 | break; |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 173 | case 'r': |
| 174 | flags |= RFLAG; |
| 175 | remove_seq = list_optarg; |
| 176 | break; |
| 177 | case 'V': |
| 178 | flags |= VVFLAG; |
| 179 | break; |
| 180 | case 'P': |
| 181 | flags |= PPFLAG; |
| 182 | break; |
| 183 | case 's': |
| 184 | flags |= SFLAG; |
| 185 | break; |
| 186 | case 'S': |
| 187 | flags |= SSFLAG; |
| 188 | break; |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 189 | case 'x': |
| 190 | flags |= XFLAG; |
| 191 | cmd_seq = list_optarg; |
| 192 | break; |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 193 | case 'X': |
| 194 | flags |= XXFLAG; |
| 195 | break; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 196 | default: |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 197 | builtin_usage (); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 198 | BIND_RETURN (EX_USAGE); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | list = loptend; |
| 203 | |
| 204 | /* First, see if we need to install a special keymap for this |
| 205 | command. Then start on the arguments. */ |
| 206 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 207 | if ((flags & MFLAG) && map_name) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 208 | { |
| 209 | kmap = rl_get_keymap_by_name (map_name); |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 210 | if (kmap == 0) |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 211 | { |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 212 | builtin_error (_("`%s': invalid keymap name"), map_name); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 213 | BIND_RETURN (EXECUTION_FAILURE); |
Jari Aalto | 28ef6c3 | 2001-04-06 19:14:31 +0000 | [diff] [blame] | 214 | } |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | if (kmap) |
| 218 | { |
| 219 | saved_keymap = rl_get_keymap (); |
| 220 | rl_set_keymap (kmap); |
| 221 | } |
| 222 | |
| 223 | /* XXX - we need to add exclusive use tests here. It doesn't make sense |
| 224 | to use some of these options together. */ |
| 225 | /* Now hack the option arguments */ |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 226 | if (flags & LFLAG) |
| 227 | rl_list_funmap_names (); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 228 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 229 | if (flags & PFLAG) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 230 | rl_function_dumper (1); |
| 231 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 232 | if (flags & PPFLAG) |
| 233 | rl_function_dumper (0); |
| 234 | |
| 235 | if (flags & SFLAG) |
| 236 | rl_macro_dumper (1); |
| 237 | |
| 238 | if (flags & SSFLAG) |
| 239 | rl_macro_dumper (0); |
| 240 | |
| 241 | if (flags & VFLAG) |
| 242 | rl_variable_dumper (1); |
| 243 | |
| 244 | if (flags & VVFLAG) |
| 245 | rl_variable_dumper (0); |
| 246 | |
| 247 | if ((flags & FFLAG) && initfile) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 248 | { |
| 249 | if (rl_read_init_file (initfile) != 0) |
| 250 | { |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 251 | builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 252 | BIND_RETURN (EXECUTION_FAILURE); |
| 253 | } |
| 254 | } |
| 255 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 256 | if ((flags & QFLAG) && fun_name) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 257 | return_code = query_bindings (fun_name); |
| 258 | |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 259 | if ((flags & UFLAG) && unbind_name) |
| 260 | return_code = unbind_command (unbind_name); |
| 261 | |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 262 | if ((flags & RFLAG) && remove_seq) |
| 263 | { |
Chet Ramey | 0001803 | 2011-11-21 20:51:19 -0500 | [diff] [blame] | 264 | if (rl_bind_keyseq (remove_seq, (rl_command_func_t *)NULL) != 0) |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 265 | { |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 266 | builtin_error (_("`%s': cannot unbind"), remove_seq); |
Jari Aalto | ccc6cda | 1996-12-23 17:02:34 +0000 | [diff] [blame] | 267 | BIND_RETURN (EXECUTION_FAILURE); |
| 268 | } |
| 269 | } |
| 270 | |
Jari Aalto | bb70624 | 2000-03-17 21:46:59 +0000 | [diff] [blame] | 271 | if (flags & XFLAG) |
| 272 | return_code = bind_keyseq_to_unix_command (cmd_seq); |
| 273 | |
Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame^] | 274 | if (flags & XXFLAG) |
| 275 | return_code = print_unix_command_map (); |
| 276 | |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 277 | /* Process the rest of the arguments as binding specifications. */ |
| 278 | while (list) |
| 279 | { |
| 280 | rl_parse_and_bind (list->word->word); |
| 281 | list = list->next; |
| 282 | } |
| 283 | |
| 284 | bind_exit: |
| 285 | if (saved_keymap) |
| 286 | rl_set_keymap (saved_keymap); |
| 287 | |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 288 | run_unwind_frame ("bind_builtin"); |
| 289 | |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 290 | return (sh_chkwrite (return_code)); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | static int |
| 294 | query_bindings (name) |
| 295 | char *name; |
| 296 | { |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 297 | rl_command_func_t *function; |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 298 | char **keyseqs; |
| 299 | int j; |
| 300 | |
| 301 | function = rl_named_function (name); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 302 | if (function == 0) |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 303 | { |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 304 | builtin_error (_("`%s': unknown function name"), name); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 305 | return EXECUTION_FAILURE; |
| 306 | } |
| 307 | |
| 308 | keyseqs = rl_invoking_keyseqs (function); |
| 309 | |
| 310 | if (!keyseqs) |
| 311 | { |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 312 | printf (_("%s is not bound to any keys.\n"), name); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 313 | return EXECUTION_FAILURE; |
| 314 | } |
| 315 | |
Jari Aalto | b80f644 | 2004-07-27 13:29:18 +0000 | [diff] [blame] | 316 | printf (_("%s can be invoked via "), name); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 317 | for (j = 0; j < 5 && keyseqs[j]; j++) |
| 318 | printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n"); |
| 319 | if (keyseqs[j]) |
| 320 | printf ("...\n"); |
Jari Aalto | 7117c2d | 2002-07-17 14:10:11 +0000 | [diff] [blame] | 321 | strvec_dispose (keyseqs); |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 322 | return EXECUTION_SUCCESS; |
| 323 | } |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 324 | |
| 325 | static int |
| 326 | unbind_command (name) |
| 327 | char *name; |
| 328 | { |
Jari Aalto | f73dda0 | 2001-11-13 17:56:06 +0000 | [diff] [blame] | 329 | rl_command_func_t *function; |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 330 | |
| 331 | function = rl_named_function (name); |
| 332 | if (function == 0) |
| 333 | { |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 334 | builtin_error (_("`%s': unknown function name"), name); |
Jari Aalto | cce855b | 1998-04-17 19:52:44 +0000 | [diff] [blame] | 335 | return EXECUTION_FAILURE; |
| 336 | } |
| 337 | |
| 338 | rl_unbind_function_in_map (function, rl_get_keymap ()); |
| 339 | return EXECUTION_SUCCESS; |
| 340 | } |
Jari Aalto | 726f638 | 1996-08-26 18:22:31 +0000 | [diff] [blame] | 341 | #endif /* READLINE */ |