anchor.diff:  	{'DOWN', Ref, process, CPid, {error, Reason}} ->
   	    {error, Reason}
       after Timeout ->
  -	    {error, timeout}
  +	    {error, toerl_server_timeout}
       end.
   
   get_progs() ->
  +    try
  +        do_get_progs()
  +    catch
  +        throw:Thrown ->
  +            {error, Thrown}
  +    end.
  +
  +do_get_progs() ->
       case os:type() of
   	{unix,freebsd} ->
  -	    {error,"cant use run_erl on freebsd"};
  +	    throw("Can't use run_erl on FreeBSD");
   	{unix,openbsd} ->
  -	    {error,"cant use run_erl on openbsd"};
  +	    throw("Can't use run_erl on OpenBSD");
   	{unix,_} ->
  -	    case os:find_executable("run_erl") of
  -		RE when is_list(RE) ->
  -		    case  os:find_executable("to_erl") of
  -			TE when is_list(TE) ->
  -			    case os:find_executable("erl") of
  -				E when is_list(E) ->
  -				    {RE,TE,E};
  -				_ ->
  -				    {error, "Could not find erl command"}
  -			    end;
  -			_ ->
  -			    {error, "Could not find to_erl command"}
  -		    end;
  -		_ ->
  -		    {error, "Could not find run_erl command"}
  -	    end;
  +            RunErl = find_executable("run_erl"),
  +            ToErl = find_executable("to_erl"),
  +            Erl = find_executable("erl"),
  +            {RunErl, ToErl, Erl};
   	_ ->
  -	    {error, "Not a unix OS"}
  +	    throw("Not a Unix OS")
  +    end.
  +
  +find_executable(Name) ->
  +    case os:find_executable(Name) of
  +        Prog when is_list(Prog) ->
  +            Prog;
  +        false ->
  +            throw("Could not find " ++ Name)
       end.
   
   create_tempdir() ->
  
positive.code:          shell_history_custom/1, shell_history_custom_errors/1,
  	 job_control_remote_noshell/1,ctrl_keys/1,
           get_columns_and_rows_escript/1,
           remsh/1, remsh_longnames/1, remsh_no_epmd/1]).
  
  -export([init_per_testcase/2, end_per_testcase/2]).
  %% For spawn
  -export([toerl_server/3]).
  %% Exports for custom shell history module
  -export([load/0, add/1]).
  
  init_per_testcase(_Func, Config) ->
      Config.
  
  end_per_testcase(_Func, _Config) ->
      ok.
  
  suite() ->
      [{ct_hooks,[ts_install_cth]},
       {timetrap,{minutes,3}}].
  
  all() -> 
      [get_columns_and_rows_escript,get_columns_and_rows,
       exit_initial, job_control_local,
       job_control_remote, job_control_remote_noshell,
       ctrl_keys, stop_during_init, {group, shell_history},
       remsh, remsh_longnames, remsh_no_epmd].
  
  groups() -> 
      [{shell_history, [],
        [shell_history,
         shell_history_resize,
  
negative.code: 
  %% Test that the shell can access columns and rows.
  get_columns_and_rows(Config) when is_list(Config) ->
      case proplists:get_value(default_shell, Config) of
  	old ->
              test_columns_and_rows(old, []);
  	new ->
              test_columns_and_rows(old, ["-oldshell"]),
              test_columns_and_rows(new, [])
      end,
      ok.
  
  test_columns_and_rows(old, Args) ->
      rtnode([{putline, ""},
              {putline, "2."},
              {expect, "2\r\n"},
              {putline, "io:columns()."},
              {expect, "{error,enotsup}\r\n"},
              {putline, "io:rows()."},
              {expect, "{error,enotsup}\r\n"}
             ], [], [], Args),
  
      rtnode([{putline, ""},
              {putline, "2."},
              {expect, "2\r\n"},
              {putline, "io:columns()."},
              {expect, "{ok,90}\r\n"},
              {putline,"io:rows()."},
              {expect, "{ok,40}\r\n"}],
             [],
             "stty rows 40; stty columns 90; ",
             Args);
  test_columns_and_rows(new, _Args) ->
      rtnode([{putline, ""},
              {expect, "1> $"},
              {putline, "2."},
              {expect, "\r\n2\r\n"},
              {expect, "> $"},
              {putline, "io:columns()."},
              {expect, "{ok,80}\r\n"},
              {expect, "> $"},
              {putline, "io:rows()."},
              {expect, "\r\n{ok,24}\r\n"}
             ]),
  
      rtnode([{putline, ""},
              {expect, "1> $"},
              {putline, "2."},
              {expect,  "\r\n2\r\n"},
              {expect, "> $"},
              {putline, "io:columns()."},
              {expect, "\r\n{ok,90}\r\n"},
              {expect, "> $"},
              {putline, "io:rows()."},
              {expect, "\r\n{ok,40}\r\n"}],
             [],
             "stty rows 40; stty columns 90; ").
  
  %% Tests that exit of initial shell restarts shell.
  exit_initial(Config) when is_list(Config) ->
      case proplists:get_value(default_shell, Config) of
  	old ->
              test_exit_initial(old);
          new ->
              test_exit_initial(old),
              test_exit_initial(new)
      end,
      ok.
  
  test_exit_initial(old) ->
      rtnode([{putline, ""},
              {putline, "2."},
              {expect, "2\r\n"},
              {putline, "exit()."},
              {expect, "Eshell"},
              {putline, ""},
              {putline, "35."},
              {expect, "35\r\n"}],
             [], [], ["-oldshell"]);
  test_exit_initial(new) ->
      rtnode([{putline, ""},
              {expect, "1> $"},
              {putline, "2."},
              {expect, "2"},
              {putline,"exit()."},
              {expect, "Eshell"},
              {expect, "1> $"},
              {putline, "35."},
              {expect, "35\r\n"}]).
  
  stop_during_init(Config) when is_list(Config) ->
      {RunErl,_ToErl,Erl} = get_progs(),
      case create_tempdir() of
          {error, Reason} ->
              {skip, Reason};
          Tempdir ->
              XArg = " -kernel shell_history enabled -s init stop",
              start_runerl_command(RunErl, Tempdir, "\\\""++Erl++"\\\""++XArg),
              Logs = rtnode_read_logs(Tempdir),
              rtnode_dump_logs(Logs),
              nomatch = binary:match(map_get("erlang.log.1", Logs),
                                     <<"*** ERROR: Shell process terminated! ***">>),
              ok
      end.
  
  %% This testcase tests that shell_history works as it should.
  %% We use Ctrl + P = Cp=[$\^p] in order to navigate up
  