anchor.diff:          error -> Def
       end.
   
  -%% (defmacro safe_fetch (key d def)
  -%%   `(case (find ,key ,d)
  -%%      ((tuple 'ok val) val)
  -%%      ('error ,def)))
  -
   %% The LFE shell command functions.
   %%  These are callable from outside the shell as well.
   
  
positive.code: %% Copyright (c) 2008-2014 Robert Virding
  %%
  %% Licensed under the Apache License, Version 2.0 (the "License");
  %% you may not use this file except in compliance with the License.
  
negative.code:     %% io:fwrite("asm: ~p\n", [Env1]),
      Env1.
  
  %% start_eval(State) -> Evaluator.
  %%  Start an evaluator process.
  
  start_eval(St) ->
      Self = self(),
      spawn_link(fun () -> evaluator(Self, St) end).
  
  evaluator(Shell, St) ->
      eval_loop(Shell, St).
  
  eval_loop(Shell, St0) ->
      receive
  	{eval_expr,Shell,Form} ->
  	    St1 = eval_form(Form, Shell, St0),
  	    eval_loop(Shell, St1)
      end.
  
  %% eval_form(Form, ShellPid, State) -> State.
  %%  Evaluate a form, print is reurn value and send updated state back
  %%  to the shell manager process. Unfortunately we can't just let it
  %%  crash as an error here causes the emulator to generate an error
  %%  report. Being cunning and building our own error return value and
  %%  doing exit on it seem to fix the problem.
  
  eval_form(Form, Shell, St0) ->
      try
  	Ce1 = add_vbinding('-', Form, St0#state.curr),
  	%% Macro expand and evaluate it.
  	{Value,St1} = eval_form(Form, St0#state{curr=Ce1}),
  	%% Print the result, but only to depth 30.
  	VS = lfe_io:prettyprint1(Value, 30),
  	io:requests([{put_chars,VS},nl]),
  	%% Update bindings.
  	Ce2 = update_shell_vars(Form, Value, St1#state.curr),
  	St2 = St1#state{curr=Ce2},
  	%% Return value and updated state.
  	Shell ! {eval_value,self(),Value,St2},
  	St2
      catch
  	exit:normal -> exit(normal);
  	Class:Reason ->
  	    Stk = erlang:get_stacktrace(),
  	    %% We don't want the ERROR REPORT generated by the
  	    %% emulator. Note: exit(kill) needs nothing special.
  	    %% {links,Ps} = process_info(self(), links),
  	    %% E = nocatch(Class, {Reason,Stk}),
  	    %% foreach(fun (P) -> exit(P, E) end, Ps -- [Shell]),
  	    %% Shell ! {eval_exit,self(),Class,{Reason,Stk}},
  	    %% exit(normal)
  	    E = nocatch(Class, {Reason,Stk}),
  	    exit(E)
      end.
  
  nocatch(throw, {Term,Stack}) ->
      {{nocatch,Term},Stack};
  nocatch(_, Reason) -> Reason.
  
  %% eval_form(Form, State) -> {Value,State}.
  %%  Macro expand the the top form then treat special case top-level
  