Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 611)
+++ CMT/HEAD/ChangeLog	(revision 612)
@@ -1,2 +1,30 @@
+2012-04-25    <rybkin@lal.in2p3.fr> 487
+
+	* source/cmt_commands.cxx: In class ArgParser function do_show, introduce
+	commands "cmt show alias", "cmt show alias_names", "cmt show alias_value",
+	"cmt show aliases", in class CommandHelp constructor, document new commands
+	and document use of optional <regexp> argument for "cmt show" commands
+	{action,macro,set}{s,_names}
+	* source/cmt.h: In class Cmt, declare functions do_show_alias,
+	do_show_alias_names, do_show_alias_value, do_show_aliases
+	* source/cmt_parser.h: In enum ActionType, introduce members
+	action_show_alias, action_show_alias_value, action_show_alias_names,
+	action_show_aliases
+	* source/cmt_parser.cxx: In class Cmt, implement functions do_show_alias,
+	do_show_alias_names, do_show_alias_value, do_show_aliases, in function
+	do_show_macro, implement function do_show_action via do_show_macro, enhance
+	function do_show_macro to show actions and aliases, in function parser,
+	make use of new alias related functions, in function print_symbol_names,
+	add case of action_show_alias_names, in function print_macros, add case of
+	action_show_aliases
+	* source/cmt_symbol.cxx: In class Symbol function show_macro, add case of
+	action_show_aliases, action_show_alias, action_show_alias_value
+	* src/setup.csh: Fix case of unset environment variable CLASSPATH, optimise
+	tcsh shell is identification
+	* src/setup.bash: Implement command completion for alias related commands
+	* src/setup.zsh: idem
+	* src/setup.tcsh: idem, optimise by removing redundant sed utility
+	invocations
+	
 2012-04-24    <rybkin@lal.in2p3.fr> 486
 
Index: CMT/HEAD/source/cmt.h
===================================================================
--- CMT/HEAD/source/cmt.h	(revision 611)
+++ CMT/HEAD/source/cmt.h	(revision 612)
@@ -160,4 +160,8 @@
   static void do_show_action_value (const ArgParser& ap);
   static void do_show_actions (const ArgParser& ap);
+  static void do_show_alias (const ArgParser& ap);
+  static void do_show_alias_names (const ArgParser& ap);
+  static void do_show_alias_value (const ArgParser& ap);
+  static void do_show_aliases (const ArgParser& ap);
   static void do_show_all_tags (const ArgParser& ap);
   static void do_show_applied_patterns (const ArgParser& ap);
Index: CMT/HEAD/source/cmt_commands.cxx
===================================================================
--- CMT/HEAD/source/cmt_commands.cxx	(revision 611)
+++ CMT/HEAD/source/cmt_commands.cxx	(revision 612)
@@ -1408,4 +1408,53 @@
 
 	  cmt.m_action = action_show_actions;
+	}
+      else if (arg == "alias")
+	{
+	  if (argc > 0)
+	    {
+	      cmt.m_current_target = fill_one_argument ();
+	      cmt.m_action = action_show_alias;
+	    }
+	  else
+	    {
+	      CmtError::set (CmtError::syntax_error, "alias name missing");
+	      //CmtMessage::error ("syntax: alias name missing");
+	      help_action = action_help;
+	      cmt.m_action = action_show_alias;
+	    }
+	}
+      else if (arg == "alias_names")
+	{
+	  if (argc > 0)
+	    {
+	      fill_one_argument ();
+	    }
+
+	  cmt.m_action = action_show_alias_names;
+	}
+      else if (arg == "alias_value")
+	{
+	  cmt.m_quiet = true;
+	  if (argc > 0)
+	    {
+	      cmt.m_current_target = fill_one_argument ();
+	      cmt.m_action = action_show_alias_value;
+	    }
+	  else
+	    {
+	      CmtError::set (CmtError::syntax_error, "alias name missing");
+	      //CmtMessage::error ("syntax: alias name missing");
+	      help_action = action_help;
+	      cmt.m_action = action_show_alias_value;
+	    }
+	}
+      else if (arg == "aliases")
+	{
+	  if (argc > 0)
+	    {
+	      fill_one_argument ();
+	    }
+
+	  cmt.m_action = action_show_aliases;
 	}
       else if (arg == "all_tags")
@@ -2473,6 +2522,10 @@
   help_texts.add () =  "show  action <name>     :  a formatted action definition";
   help_texts.add () =  "show  action_value <name> :  a raw action definition";
-  help_texts.add () =  "show  action_names      :  all action names";
-  help_texts.add () =  "show  actions           :  all action definitions";
+  help_texts.add () =  "show  action_names [<regexp>] :  all action names [matching <regexp>]";
+  help_texts.add () =  "show  actions [<regexp>] :  all action definitions [for names matching <regexp>]";
+  help_texts.add () =  "show  alias <name>      :  a formatted alias definition";
+  help_texts.add () =  "show  alias_value <name> :  a raw alias definition";
+  help_texts.add () =  "show  alias_names [<regexp>] :  all alias names [matching <regexp>]";
+  help_texts.add () =  "show  aliases [<regexp>] :  all alias definitions [for names matching <regexp>]";
   help_texts.add () =  "show  all_tags          :  all defined tags";
   help_texts.add () =  "show  applied_patterns  :  all patterns actually applied";
@@ -2494,6 +2547,6 @@
   help_texts.add () =  "show  macro <name>      :  a formatted macro definition";
   help_texts.add () =  "show  macro_value <name>  :  a raw macro definition";
-  help_texts.add () =  "show  macro_names       :  all macro names";
-  help_texts.add () =  "show  macros            :  all macro definitions";
+  help_texts.add () =  "show  macro_names [<regexp>] :  all macro names [matching <regexp>]";
+  help_texts.add () =  "show  macros [<regexp>] :  all macro definitions [for names matching <regexp>]";
   help_texts.add () =  "show  manager           :  package manager";
   help_texts.add () =  "show  packages [<path>]... :  packages reachable from the current context [or <path>s]";
@@ -2507,7 +2560,7 @@
   help_texts.add () =  "show  pwd               :  filtered current directory";
   help_texts.add () =  "show  set <name>        :  a formatted set definition";
-  help_texts.add () =  "show  set_names         :  set names";
+  help_texts.add () =  "show  set_names [<regexp>] :  set names [matching <regexp>]";
   help_texts.add () =  "show  set_value <name>  :  a raw set definition";
-  help_texts.add () =  "show  sets              :  set definitions";
+  help_texts.add () =  "show  sets [<regexp>]   :  set definitions [for names matching <regexp>]";
   help_texts.add () =  "show  strategies        :  all strategies (build & version)";
   help_texts.add () =  "show  tags              :  all currently active tags";
@@ -2577,4 +2630,8 @@
   help.add (action_show_action_names, help_texts[action_show_action_names]);
   help.add (action_show_actions, help_texts[action_show_actions]);
+  help.add (action_show_alias, help_texts[action_show_alias]);
+  help.add (action_show_alias_value, help_texts[action_show_alias_value]);
+  help.add (action_show_alias_names, help_texts[action_show_alias_names]);
+  help.add (action_show_aliases, help_texts[action_show_aliases]);
   help.add (action_show_all_tags, help_texts[action_show_all_tags]);
   help.add (action_show_applied_patterns, help_texts[action_show_applied_patterns]);
Index: CMT/HEAD/source/cmt_parser.cxx
===================================================================
--- CMT/HEAD/source/cmt_parser.cxx	(revision 611)
+++ CMT/HEAD/source/cmt_parser.cxx	(revision 612)
@@ -4353,58 +4353,5 @@
 void Cmt::do_show_action (const ArgParser& ap)
 {
-  cmt_string target;
-
-  if (ap.arguments.size () > 0) target = ap.arguments[0];
-
-  Symbol* symbol;
-
-  set_standard_macros ();
-
-  symbol = Symbol::find (target);
-
-  if (symbol == 0) 
-    {
-      cmt_string t (target);
-      t += " is not defined";
-
-      CmtError::set (CmtError::symbol_not_found, t);
-
-      return;
-    }
-  else
-    {
-      cmt_string t = target;
-      t += " is a ";
-
-      if ((Me.m_action == action_show_action) ||
-          (Me.m_action == action_show_action_value))
-	{
-	  if (symbol->type != Symbol::SymbolAction)
-	    {
-	      if (symbol->type == Symbol::SymbolMacro)
-		{
-		  t += "macro";
-		}
-	      else if (symbol->type == Symbol::SymbolSet)
-		{
-		  t += "set";
-		}
-	      else if (symbol->type == Symbol::SymbolPath)
-		{
-		  t += "path";
-		}
-	      else if (symbol->type == Symbol::SymbolAlias)
-		{
-		  t += "alias";
-		}
-
-	      CmtError::set (CmtError::wrong_symbol_type, t);
-	    }
-        }
-    }
-
-  if (symbol->value_lists.size () < 1) return;
-
-  symbol->show_macro (ap.mode);
+  do_show_macro (ap);
 }
 
@@ -4431,4 +4378,44 @@
 //----------------------------------------------------------
 void Cmt::do_show_actions (const ArgParser& ap)
+{
+  if (ap.arguments.size () > 0)
+    {
+      const cmt_string& pattern = ap.arguments[0];
+      print_macros (ap.mode, pattern);
+    }
+  else
+    {
+      print_macros (ap.mode);
+    }
+}
+
+//----------------------------------------------------------
+void Cmt::do_show_alias (const ArgParser& ap)
+{
+  do_show_macro (ap);
+}
+
+//----------------------------------------------------------
+void Cmt::do_show_alias_names (const ArgParser& ap)
+{
+  if (ap.arguments.size () > 0)
+    {
+      const cmt_string& pattern = ap.arguments[0];
+      print_symbol_names (ap.mode, pattern);
+    }
+  else
+    {
+      print_symbol_names (ap.mode);
+    }
+}
+
+//----------------------------------------------------------
+void Cmt::do_show_alias_value (const ArgParser& ap)
+{
+  do_show_macro (ap);
+}
+
+//----------------------------------------------------------
+void Cmt::do_show_aliases (const ArgParser& ap)
 {
   if (ap.arguments.size () > 0)
@@ -4717,5 +4704,5 @@
     {
       cmt_string t = target;
-      t += " is a ";
+      t += " is ";
 
       if ((Me.m_action == action_show_macro) ||
@@ -4759,4 +4746,47 @@
 	    }
         }
+      else if (
+	       ((Me.m_action == action_show_action ||
+		 Me.m_action == action_show_action_value) &&
+		symbol->type != Symbol::SymbolAction)
+	       ||
+	       ((Me.m_action == action_show_alias ||
+		 Me.m_action == action_show_alias_value) &&
+		symbol->type != Symbol::SymbolAlias)
+	       )
+	{
+	  switch (symbol->type)
+	    {
+	    case Symbol::SymbolUndefined:
+	      t += "undefined";
+	      break;
+	    case Symbol::SymbolAction:
+	      t += "action";
+	      break;
+	    case Symbol::SymbolAlias:
+	      t += "alias";
+	      break;
+	    case Symbol::SymbolMacro:
+	      t += "macro";
+	      break;
+	    case Symbol::SymbolSetupScript:
+	      t += "setup_script";
+	      break;
+	    case Symbol::SymbolCleanupScript:
+	      t += "cleanup_script";
+	      break;
+	    case Symbol::SymbolSet:
+	      t += "set";
+	      break;
+	    case Symbol::SymbolPath:
+	      t += "path";
+	      break;
+	    default:
+	      t += "unknown";
+	      break;
+	    }
+	  
+	  CmtError::set (CmtError::wrong_symbol_type, t);
+	}
     }
 
@@ -6605,4 +6635,8 @@
     case action_show_action_value :
     case action_show_actions :
+    case action_show_alias :
+    case action_show_alias_names :
+    case action_show_alias_value :
+    case action_show_aliases :
     case action_show_all_tags :
     case action_show_applied_patterns :
@@ -6724,4 +6758,8 @@
     case action_show_action_value :
     case action_show_actions :
+    case action_show_alias :
+    case action_show_alias_names :
+    case action_show_alias_value :
+    case action_show_aliases :
     case action_show_all_tags :
     case action_show_applied_patterns :
@@ -6832,4 +6870,8 @@
     case action_show_action_value :
     case action_show_actions :
+    case action_show_alias :
+    case action_show_alias_names :
+    case action_show_alias_value :
+    case action_show_aliases :
     case action_show_all_tags :
     case action_show_applied_patterns :
@@ -6980,4 +7022,8 @@
           // case action_show_action_value :
           // case action_show_actions :
+	  // case action_show_alias :
+	  // case action_show_alias_names :
+	  // case action_show_alias_value :
+	  // case action_show_aliases :
           // case action_show_all_tags :
           // case action_show_applied_patterns :
@@ -7193,4 +7239,16 @@
 	  do_show_actions (ap);
 	  break;
+	case action_show_alias :
+	  do_show_alias (ap);
+	  break;
+	case action_show_alias_names :
+	  do_show_alias_names (ap);
+	  break;
+	case action_show_alias_value :
+	  do_show_alias_value (ap);
+	  break;
+	case action_show_aliases :
+	  do_show_aliases (ap);
+	  break;
 	case action_show_all_tags :
 	  do_show_all_tags (ap);
@@ -7760,5 +7818,5 @@
       else if (Me.m_action == action_show_set_names)
         {
-          // Exclude macros.
+          // Exclude macros, actions.
           if ((symbol.type == Symbol::SymbolMacro) ||
               (symbol.type == Symbol::SymbolAction)) continue;
@@ -7766,6 +7824,11 @@
       else if (Me.m_action == action_show_action_names)
         {
-          // Exclude macros.
+          // Only keep actions.
           if (symbol.type != Symbol::SymbolAction) continue;
+        }
+      else if (Me.m_action == action_show_alias_names)
+        {
+          // Only keep aliases.
+          if (symbol.type != Symbol::SymbolAlias) continue;
         }
 
@@ -7827,4 +7890,8 @@
         {
           if (symbol.type != Symbol::SymbolAction) continue;
+        }
+      else if (Me.m_action == action_show_aliases)
+        {
+          if (symbol.type != Symbol::SymbolAlias) continue;
         }
 
Index: CMT/HEAD/source/cmt_parser.h
===================================================================
--- CMT/HEAD/source/cmt_parser.h	(revision 611)
+++ CMT/HEAD/source/cmt_parser.h	(revision 612)
@@ -281,4 +281,8 @@
   action_show_action_names,
   action_show_actions,
+  action_show_alias,
+  action_show_alias_value,
+  action_show_alias_names,
+  action_show_aliases,
   action_show_all_tags,
   action_show_applied_patterns,
Index: CMT/HEAD/source/cmt_symbol.cxx
===================================================================
--- CMT/HEAD/source/cmt_symbol.cxx	(revision 611)
+++ CMT/HEAD/source/cmt_symbol.cxx	(revision 612)
@@ -1943,4 +1943,5 @@
       (action != action_show_macros) &&
       (action != action_show_actions) &&
+      (action != action_show_aliases) &&
       (action != action_show_sets))
     {
@@ -1957,4 +1958,6 @@
           (action == action_show_actions) ||
           (action == action_show_action) ||
+          (action == action_show_alias) ||
+          (action == action_show_aliases) ||
           (action == action_build_tag_makefile) ||
           (action == action_build_constituents_config) ||
@@ -1976,5 +1979,6 @@
       if ((action == action_show_macro_value) ||
           (action == action_show_set_value) ||
-          (action == action_show_action_value))
+          (action == action_show_action_value) ||
+          (action == action_show_alias_value))
         {
           expand (value);
@@ -2004,4 +2008,6 @@
           (action == action_show_actions) ||
           (action == action_show_action) ||
+          (action == action_show_alias) ||
+          (action == action_show_aliases) ||
           (action == action_build_tag_makefile) ||
           (action == action_build_constituents_config) ||
Index: CMT/HEAD/src/setup.bash
===================================================================
--- CMT/HEAD/src/setup.bash	(revision 611)
+++ CMT/HEAD/src/setup.bash	(revision 612)
@@ -25,5 +25,5 @@
     local build_subcmds=(CMT_pacman constituent_makefile constituents_makefile dependencies library_links make_setup msdev os9_makefile prototype readme tag_makefile temporary_name triggers win_makefile)
     local check_subcmds=(configuration files version)
-    local show_subcmds=(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)
+    local show_subcmds=(action action_names action_value actions alias alias_names alias_value aliases all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)
 
     local cur _IFS="${IFS}"
@@ -122,4 +122,9 @@
 			if (( isubcommand + 1 == COMP_CWORD )); then
 			    COMPREPLY=($(compgen -W "$(cmt -quiet show action_names)" -- "$cur"))
+			fi
+			;;
+		    alias|alias_value)
+			if (( isubcommand + 1 == COMP_CWORD )); then
+			    COMPREPLY=($(compgen -W "$(cmt -quiet show alias_names)" -- "$cur"))
 			fi
 			;;
Index: CMT/HEAD/src/setup.csh
===================================================================
--- CMT/HEAD/src/setup.csh	(revision 611)
+++ CMT/HEAD/src/setup.csh	(revision 612)
@@ -13,5 +13,7 @@
 
 if ( $?0 == 0 ) then
-if ( $?tcsh == 1 || `basename "$shell"` == "tcsh" ) then
+if ( $?tcsh == 1 ) then
+  source ${CMTROOT}/src/setup.tcsh
+else if ( `basename "$shell"` == "tcsh" ) then
   source ${CMTROOT}/src/setup.tcsh
 endif
@@ -33,5 +35,7 @@
 unset newpath
 
-if ( $?CLASSPATH == 0 || "${CLASSPATH}" == "" ) then
+if ( $?CLASSPATH == 0 ) then
+  setenv CLASSPATH ${CMTROOT}/java/cmt.jar
+else if ( "${CLASSPATH}" == "" ) then
   setenv CLASSPATH ${CMTROOT}/java/cmt.jar
 else if ( "${CLASSPATH}" !~ "*/CMT/*" ) then
Index: CMT/HEAD/src/setup.tcsh
===================================================================
--- CMT/HEAD/src/setup.tcsh	(revision 611)
+++ CMT/HEAD/src/setup.tcsh	(revision 612)
@@ -14,15 +14,17 @@
  n/check_files/f/ \
  n/expand/'(model)'/ \
- n/show/'(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
+ n/show/'(action action_names action_value actions alias alias_names alias_value aliases all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
  n/constituents_makefile/n/ \
  n/constituent/'`cmt -quiet show constituent_names`'/ \
- n/fragment/'`cmt -quiet show fragments | sed -e "s#.*fragments.##" `'/ \
- n/action/'`cmt -quiet show action_names | sed -e "s#=.*##" `'/ \
- n/action_value/'`cmt -quiet show action_names | sed -e "s#=.*##" `'/ \
- n/macro/'`cmt -quiet show macro_names | sed -e "s#=.*##" `'/ \
- n/macro_value/'`cmt -quiet show macro_names | sed -e "s#=.*##" `'/ \
+ n@fragment@'`cmt -quiet show fragments | sed -e "s#.*/fragments/##"`'@ \
+ n/action/'`cmt -quiet show action_names`'/ \
+ n/action_value/'`cmt -quiet show action_names`'/ \
+ n/alias/'`cmt -quiet show alias_names`'/ \
+ n/alias_value/'`cmt -quiet show alias_names`'/ \
+ n/macro/'`cmt -quiet show macro_names`'/ \
+ n/macro_value/'`cmt -quiet show macro_names`'/ \
  n/pattern/'`cmt -quiet show pattern_names`'/ \
- n/set/'`cmt -quiet show set_names | sed -e "s#=.*##" `'/ \
- n/set_value/'`cmt -quiet show set_names | sed -e "s#=.*##" `'/ \
+ n/set/'`cmt -quiet show set_names`'/ \
+ n/set_value/'`cmt -quiet show set_names`'/ \
  n/triggers/'`cmt -quiet show constituent_names`'/ \
  'n/c{o,heckout}/(-l -R -r -C -i -vd -d -o -requirements -no_config -rs --help)/' \
Index: CMT/HEAD/src/setup.zsh
===================================================================
--- CMT/HEAD/src/setup.zsh	(revision 611)
+++ CMT/HEAD/src/setup.zsh	(revision 612)
@@ -10,4 +10,5 @@
 function cmt_macros { reply=(`cmt -quiet show macro_names`)}; \
    function cmt_actions { reply=(`cmt -quiet show action_names`)}; \
+   function cmt_aliases { reply=(`cmt -quiet show alias_names`)}; \
    function cmt_sets { reply=(`cmt -quiet show set_names`)}; \
    function cmt_constituents { reply=(`cmt -quiet show constituent_names`) }; \
@@ -32,9 +33,11 @@
    'w[1,remove] p[3]' -X '> give version tag' - \
    'w[1,remove] p[4]' -X '> give a path if not located from the current path ' - \
-   's[show],c[-1,show]' -k '(action,action_names,action_value,actions,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,container,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
+   's[show],c[-1,show]' -k '(action,action_names,action_value,actions,alias,alias_names,alias_value,aliases,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,container,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
    'w[1,show] c[-1,constituent]' -K cmt_constituents - \
    'w[1,show] c[-1,fragment]' -K cmt_fragments - \
    'w[1,show] c[-1,action]' -K cmt_actions - \
    'w[1,show] c[-1,action_value]' -K cmt_actions - \
+   'w[1,show] c[-1,alias]' -K cmt_aliases - \
+   'w[1,show] c[-1,alias_value]' -K cmt_aliases - \
    'w[1,show] c[-1,macro]' -K cmt_macros - \
    'w[1,show] c[-1,macro_value]' -K cmt_macros - \
