| 937 | } |
| 938 | |
| 939 | function runcmd(cmd) { |
| 940 | var pieces = breakcmd(cmd); |
| 941 | if (pieces[0] === '') |
| 942 | return undefined; |
| 943 | |
| 944 | var first = pieces[0], rest = pieces[1]; |
| 945 | if (!Object.hasOwn(commands, first)) { |
| 946 | print(`unrecognized command '${first}'`); |
| 947 | return undefined; |
| 948 | } |
| 949 | |
| 950 | cmd = commands[first]; |
| 951 | if (cmd.length === 0 && rest !== '') { |
| 952 | print('this command cannot take an argument'); |
| 953 | return undefined; |
| 954 | } |
| 955 | |
| 956 | return cmd(rest); |
| 957 | } |
| 958 | |
| 959 | function preReplCleanups() { |
| 960 | while (replCleanups.length > 0) |