// Copyright (c) 2005-2008 Andre Merzky // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "saga-shell.hpp" // change the working directory int shell::c_cd (std::vector & args, props & p) { // have a nice default if ( args.empty () ) { cwd_.change_dir (home_); set_prompt (); return SUCCESS; } if ( args.size () > 1 ) { carp ("format: cd ", p); return FAILURE; } // we actually try a real cd. If that fails, we try to create a new dir // instance with the arg, in case its switching to another namespace... // That's also why we don't bother about sanity checks at the moment. try { // do! :-) cwd_.change_dir (args[0]); } catch ( const saga::exception & /*e*/ ) { // lets try the fallback saga::name_space::directory new_cwd (args[0], saga::name_space::ReadWrite); cwd_ = new_cwd; } set_prompt (); return SUCCESS; }