diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-07 23:35:41 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-07 23:35:41 -0800 |
commit | 5f686ebb478b461c3044261a84fc347072c1ff07 (patch) | |
tree | b362f4609c405cd62e734ef926ee6dc92df5a66b /exec.cpp | |
parent | 6a31457c6d764425f8039a6159e92b5f84a2a0c5 (diff) |
Clean up exec_subshell, removing al_list from it
Diffstat (limited to 'exec.cpp')
-rw-r--r-- | exec.cpp | 32 |
1 files changed, 13 insertions, 19 deletions
@@ -1705,23 +1705,8 @@ void exec( parser_t &parser, job_t *j ) } -int exec_subshell2( const wcstring &cmd, std::vector<wcstring> &outputs ) -{ - array_list_t lst; - al_init(&lst); - int result = exec_subshell(cmd.c_str(), &lst); - int i, max = al_get_count(&lst); - for (i=0; i < max; i++) { - wchar_t *tmp = (wchar_t *)al_get(&lst, i); - outputs.push_back(tmp); - free(tmp); - } - al_destroy(&lst); - return result; -} -int exec_subshell( const wchar_t *cmd, - array_list_t *lst ) +static int exec_subshell_internal( const wcstring &cmd, wcstring_list_t *lst ) { char *begin, *end; char z=0; @@ -1730,7 +1715,6 @@ int exec_subshell( const wchar_t *cmd, io_data_t *io_buffer; char sep=0; - CHECK( cmd, -1 ); const env_var_t ifs = env_get_string(L"IFS"); if( ! ifs.missing_or_empty() ) @@ -1783,7 +1767,7 @@ int exec_subshell( const wchar_t *cmd, wchar_t *el = str2wcs( begin ); if( el ) { - al_push( lst, el ); + lst->push_back(el); } else { @@ -1801,7 +1785,7 @@ int exec_subshell( const wchar_t *cmd, el = str2wcs( begin ); if( el ) { - al_push( lst, el ); + lst->push_back(el); } else { @@ -1817,3 +1801,13 @@ int exec_subshell( const wchar_t *cmd, return status; } + +int exec_subshell( const wcstring &cmd, std::vector<wcstring> &outputs ) +{ + return exec_subshell_internal(cmd, &outputs); +} + +__warn_unused int exec_subshell( const wcstring &cmd ) +{ + return exec_subshell_internal(cmd, NULL); +} |