void fn_exit (inode_state& state, const wordvec& words){ DEBUGF ('c', state); DEBUGF ('c', words); wordvec vec(&words[1], &words[words.size()]); string exit_stat_str = ""; for(const auto& wrd : vec) exit_stat_str += wrd; if(vec.size() == 0){ state.endprog(); throw ysh_exit_exn(); } else { try { int exit_stat_int = stoi(exit_stat_str); exit_status::set(exit_stat_int); state.endprog(); throw ysh_exit_exn(); } catch (invalid_argument&) { exit_status::set(127); state.endprog(); throw ysh_exit_exn(); } } }
void fn_exit (inode_state& state, const wordvec& words){ DEBUGF ('c', state); DEBUGF ('c', words); if(words.size() == 0){ exit_status::set(0); }else{ try{ int k = stoi(words.at(1), nullptr); exit_status::set(k); }catch (const std::invalid_argument& ia){ exit_status::set(127); } } throw ysh_exit_exn(); }
void fn_exit (inode_state& state, const wordvec& words){ DEBUGF ('c', state); DEBUGF ('c', words); throw ysh_exit_exn(); }
void cmd::fn_exit(inode_state& state, const util::wordvec& args) { DEBUGF('c', state); DEBUGF('c', args); throw ysh_exit_exn(stoi(args[0])); }