/usr/share/epic5/script/functions is in epic5 2.0.1-1build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | if (word(2 $loadinfo()) != [pf]) { load -pf $word(1 $loadinfo()); return; };
#
# Some misc functions.. for 2.2 and beyond.
# Originally this file contained aliases written by:
# by: Ian Frechette (frechett@spot.colorado.edu)
# Most of which have been subsumed into epic itself.
# There are a great many new aliases written by crazyeddy,
#
#
# These have been updated to handle multiple words.
# format and lformat differ from $[-num]var and $[num]var in that
# They don't chop off the string if it is too long.
# These are obsoleted by the built in $pad() function.
#
alias format {
@ IRCII.word = [$1-];
if (@IRCII.word < [$0])
{ @ function_return = [$([-$0]IRCII.word)]; }
{ @ function_return = IRCII.word; };
};
alias lformat {
@ IRCII.word = [$1-];
if (@IRCII.word < [$0])
{ @ function_return = [$([$0]IRCII.word)]; }
{ @ function_return = IRCII.word; };
};
# pluck a word from a list.
# eg. $blah == "one two three four five"
# $pluck(blah three) returns "one two four five"
#
alias pluck { @ function_return = $0 = $remw($1 $($0)); };
# These map some of the original functions to their EPIC names. */
alias notword { @ function_return = notw($*); };
alias remove { @ function_return = remw($*); };
# $min() $max().
fe (min leftw max rightw) foo bar {
alias $foo return \$$bar\(1 \$numsort($*)\);
};
# $regpattern() and $regfilter() work exactly like $pattern()
# and $filter except that they use regexes rather than wildcards.
stack push alias alias.x;
alias alias.x (args) fe (filter ! pattern "") func cond {
alias $msar(gr/\${func}/$func/\${cond}/$cond/args);
};
alias.x reg${func} (ret) {
@:reg=regcomp($shift(ret));
fe ret foo {
@ foo = ${cond}regexec($reg $foo) ? [] : foo=~[* *] ? ["\$foo"] : foo;
};
@regfree($reg);
return $ret;
};
stack pop alias alias.x;
# A version of $indextoword() that ignores double quoting.
alias indextowword {return $indextoword($tr(/"/_/$*));};
alias wwordtoindex {return $wordtoindex($tr(/"/_/$*));};
# Character jot.
# $jotc(afWZ) returns abcdefWXYZ.
alias jotc {return $chr($jotm($ascii($*)));};
alias jotm (ret) {
fe ret foo bar {
@ foo = jot($foo $bar);
@ bar = [];
};
return $ret;
};
# A version of $mask() that operates with multiple args.
alias maskm (mask,args) {
fe args arg {
@ arg = mask($mask $arg);
};
return $args;
};
# $randn( rep val ) returns rep random numbers up to val.
alias randn (args) {
@ :rep = isnumber(b10 $args) ? shift(args) : 1;
@ :val = isnumber(b10 $args) ? shift(args) : 0;
eval return$repeat($rep \$rand\($val\));
};
# $replace(#x# x $jot(0 3)) returns #0# #1# #2# #3#.
alias replace (args) {
@ :in = shift(args);
@ :rep = shift(args);
fe args arg {
@ arg = sar(g/$rep/$arg/$in);
};
return $args;
};
# Shuffle functions shuffle their args.
# The s in shuffles stands for "slow".
# The f in shufflef stands for "fast".
# The c in shufflec stands for "char".
# The slow version is actually faster than the fast for smaller arg lists.
alias shufflec { return $chr($shufflef($ascii($*))); };
alias shufflef (args) {
@ :foo = randn($#args 2);
if (#args < 1000) {
return $shuffles($copattern(0 foo args)) $shuffles($copattern(1 foo args));
} else {
return $shufflef($copattern(0 foo args)) $shufflef($copattern(1 foo args));
};
};
alias shuffles {
@ :w = 0;
@ :ret = [];
if (xdebug(extractw) =~ [-*]) {
fe ($*) foo {
@ splice(ret $rand(${++w}) 0 $foo);
};
} else {
@ :space = chr($jot(1 32));
fe ($*) foo {
@ splice(ret $rand(${++w}) 0 ${0>index("$space" $foo)?foo:["$foo"]});
};
};
return $ret;
};
# A lot more like the shell version of "uniq -d" than $uniq().
# $uniqd() removes unique items in a list.
alias uniqd (ret) {
fe ret foo {
if (last!=foo) {
@ :last = foo;
@ :foo = [];
};
};
return $ret;
};
# $wordn(0.9.2,9.0.2 $jot(0 9)) returns "0 2 4 6 8 9 7 5 3 1".
alias wordn (num,args) {
@ :num = split(, $num);
fe num foo {
@ :foo = foo =~ [*.*] ? jot($split(. $foo)) : foo;
};
fe num foo {
@ foo = word($foo $args);
};
return $num;
};
# $cut(0.9.2,9.0.2 : $unsplit(: $jot(0 9))) returns "0:2:4:6:8:9:7:5:3:1".
alias cut (num,sep,args) {
switch ($num) {
(*,*) {
@ :mid = (count(, $num) + 1) / 2;
return $cut($before($mid , $num) $sep $args)$sep$cut($after($mid , $num) $sep $args);
}
(*.*) {
return $cut($unsplit(, $jot($split(. $num))) $sep $args);
}
(*) {
return $before(1 $sep ${num ? after($num $sep $args) : args}$sep);
}
};
};
# Splice characters. The bless is so it can be called on local vars.
alias splicec (var,start,count,replace) {
bless;
^assign $var $ascii($($var));
@ function_return = chr($splice($var $start $count $ascii($replace)));
^assign $var $chr($($var));
};
# Bit of a hack here. Return all args with spacing removed.
alias words { return $unsplit(" " $*); };
# $chvoices() returns the voiced users on a channel.
# $chnovoices() is the compliment.
stack push alias alias.x;
alias alias.x (args) {
fe (chhops 0 ishalfop nochhops 1 ishalfop chvoices 0 ischanvoice chnovoices 1 ischanvoice) cmd val fn {
@ :argz = args;
//alias $msar(gr/\$cmd/$cmd/\$val/$val/\$fn/$fn/argz);
};
};
alias.x \$cmd (args) {
@ :chan = shift(args);
@ :ret = chanusers($chan);
fe ret user {
@ user = $val != $fn($user $chan) ? user : [];
};
return $ret;
};
stack pop alias alias.x;
alias mychats (args) {
@ :function_return = dccctl(typematch chat);
fe function_return dcc {@ :dcc = [=]##dccctl(get $dcc user)};
};
|