Project

General

Profile

$calias » History » Version 5

Per Amundsen, 07/23/2017 10:24 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 3 Per Amundsen
Returns the Nth alias in the scripting stack.
30 2 Per Amundsen
31
*Parameters*
32
33 3 Per Amundsen
N - The Nth alias.
34 2 Per Amundsen
35
*Properties*
36
37 3 Per Amundsen
.alias - Returns the name of the alias.
38 4 Per Amundsen
.fname - Returns the filename of the script calling the alias.
39
.line - Returns the line in the script calling the alias.
40 2 Per Amundsen
.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 5 Per Amundsen
    linesep
58
    
59
    var %alias $calias(%s).alias
60
    echo -ag alias = %alias
61
    echo -ag calling filename = $calias(%s).fname
62
    echo -ag caling line = $calias(%s).line
63 1 Per Amundsen
    echo -ag isid = $calias(%s).isid
64 5 Per Amundsen
    
65
    if ($isalias(%alias)) {
66
      echo -ag alias filename = $isalias(%alias).fname
67
      echo -ag alias line = $isalias(%alias).fline
68
      echo -ag alias type = $isalias(%alias).ftype
69
    }
70
    
71
    linesep
72 2 Per Amundsen
  }
73
}
74
</pre>