File: ambig

package info (click to toggle)
epic5 3.0.3-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: ansic: 75,810; makefile: 648; ruby: 227; python: 215; sh: 78; perl: 13
file content (24 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };

on ?unknown_command "*" (cmd, args) {
  @ :bonly = 0;
  if (left(2 $cmd) == [//]) {
    @ :bonly = 1;
    @ :cmd = rest(2 $cmd);
  };
  @ :matches = symbolctl(pmatch builtin_command $cmd*);
  if (!bonly) {
    push matches $symbolctl(pmatch alias $cmd*);
  };
  @ :matches = uniq($matches);
  @ :num = #matches;
  if (num > 1) {
    xecho -b Ambiguous ${bonly ? [builtin ] : []}command $cmd. Matches \($num\): $unsplit(", " $leftw(5 $matches))${num > 5 ? [, ...] : []};
    return 1;
  };
  if (num == 1) {
    xeval -n {$matches $args};
    return 1;
  };
  return 0;
};