Project

General

Profile

$calias » History » Revision 8

Revision 7 (Per Amundsen, 02/03/2020 11:47 PM) → Revision 8/9 (Per Amundsen, 10/19/2022 08:39 PM)

_Added in 2.4_ 

 *$calias* 

 Returns the calling alias for the current script, 

 <pre> 
 alias test1 { 
   echo -ag Calling alias is $calias 
   noop $test2 
 } 

 alias test2 { 
   echo -ag Calling alias is still $calias 
   noop $test3 
 } 

 alias test3 { 
   echo -ag Calling alias is still $calias 
 } 
 </pre> 

 --- 

 _Added in 2.7_ 

 *$calias(N)* 

 Returns the Nth calling alias in the scripting stack. 

 *Parameters* 

 N - If N = 0, number of aliases in the stack, otherwise the The Nth calling alias. 

 *Properties* 

 .alias - Returns the name of the alias. 
 .fname - Returns the filename of the script calling the alias. 
 .line - Returns the line number in the script calling the alias. 
 .isid - Returns [[$true]] if the alias was called as a identifier, otherwise [[$false]]. 

 *Example* 

 <pre> 
 alias alias1 { 
   alias2 
 } 

 alias alias2 { 
   noop $alias3 
 } 

 alias alias3 { 
   var %s 0 
   while (%s < $calias(0)) { 
     inc %s 
     linesep 
    
     var %alias $calias(%s).alias 
     echo -ag alias = %alias 
     echo -ag calling filename = $calias(%s).fname 
     echo -ag caling line = $calias(%s).line 
     echo -ag isid = $calias(%s).isid 
    
     if ($isalias(%alias)) { 
       echo -ag alias filename = $isalias(%alias).fname 
       echo -ag alias line = $isalias(%alias).fline 
       echo -ag alias type = $isalias(%alias).ftype 
     } 
    
     linesep 
   } 
 } 
 </pre>