path.begin(),
boost::prior(path.end())),
dir);
+ // For auto-cd support we need to check against '.' and '..' here too
+ Token const & tok (*boost::prior(path.end()));
+ if (tok == WordToken("..")) {
+ if (dir.size() > 1)
+ dir.pop_back();
+ return *dir.back().lock();
+ }
DirectoryNode & base (*dir.back().lock());
- std::string const & name (complete(base, boost::prior(path.end())->value()));
+ if (tok == WordToken("."))
+ return base;
+ std::string const & name (complete(base, tok.value()));
if (policy_)
policy_( base, name );
return dir.back().lock()->get(name);
BOOST_AUTO_UNIT_TEST(executorAuto)
{
- senf::console::root().mkdir("dir1").mkdir("dir3");
+ senf::console::root().mkdir("tdir1").mkdir("dir3");
senf::console::root().mkdir("dir2").doc("Helptext").add("test",&testCommand);
senf::console::Executor executor;
BOOST_CHECK_EQUAL( executor.cwdPath(), "/dir2" );
BOOST_CHECK_EQUAL( os.str(), "" );
}
+
+ {
+ std::stringstream os;
+ parser.parse("..", &setCommand);
+ executor(os, commands.back());
+ BOOST_CHECK_EQUAL( executor.cwdPath(), "/" );
+ BOOST_CHECK_EQUAL( os.str(), "" );
+ }
+
+ {
+ std::stringstream os;
+ parser.parse("d", &setCommand);
+ executor(os, commands.back());
+ BOOST_CHECK_EQUAL( executor.cwdPath(), "/dir2" );
+ BOOST_CHECK_EQUAL( os.str(), "" );
+ }
{
std::stringstream os;
commands.clear();
- senf::console::root().remove("dir1");
+ senf::console::root().remove("tdir1");
senf::console::root().remove("dir2");
}