$calias » History » Version 2
Per Amundsen, 01/29/2017 11:11 PM
1 | 1 | Per Amundsen | _Added in 2.4_ |
---|---|---|---|
2 | |||
3 | *$calias* |
||
4 | |||
5 | Returns the calling alias for the current script, |
||
6 | |||
7 | <pre> |
||
8 | alias test1 { |
||
9 | echo -ag Calling alias is $calias |
||
10 | noop $test2 |
||
11 | } |
||
12 | |||
13 | alias test2 { |
||
14 | echo -ag Calling alias is still $calias |
||
15 | noop $test3 |
||
16 | } |
||
17 | |||
18 | alias test3 { |
||
19 | echo -ag Calling alias is still $calias |
||
20 | } |
||
21 | </pre> |
||
22 | 2 | Per Amundsen | |
23 | --- |
||
24 | |||
25 | _Added in 2.7_ |
||
26 | |||
27 | *$calias(N)* |
||
28 | |||
29 | Returns the Nth alias or identifier in the scripting stack. |
||
30 | |||
31 | *Parameters* |
||
32 | |||
33 | N - The Nth alias or identifier. |
||
34 | |||
35 | *Properties* |
||
36 | |||
37 | .alias - Returns the name of the alias or identifier. |
||
38 | .fname - Returns the filename of the script containing the alias or identifier. |
||
39 | .line - Returns the line in the script containing the alias or identifier. |
||
40 | .isid - Returns [[$true]] if the alias was called as a identifier, otherwise [[$false]]. |
||
41 | |||
42 | *Example* |
||
43 | |||
44 | <pre> |
||
45 | alias alias1 { |
||
46 | alias2 |
||
47 | } |
||
48 | |||
49 | alias alias2 { |
||
50 | noop $alias3 |
||
51 | } |
||
52 | |||
53 | alias alias3 { |
||
54 | var %s 0 |
||
55 | while (%s < $calias(0)) { |
||
56 | inc %s |
||
57 | echo -ag alias = $calias(%s).alias |
||
58 | echo -ag filename = $calias(%s).fname |
||
59 | echo -ag line = $calias(%s).line |
||
60 | echo -ag isid = $calias(%s).isid |
||
61 | } |
||
62 | } |
||
63 | </pre> |