PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 11ms RepoModel.GetById 0ms app.codeStats 0ms

/TeXmacs-1.0.7.11-src/src/Plugins/Unix/unix_sys_utils.cpp

#
C++ | 36 lines | 22 code | 5 blank | 9 comment | 1 complexity | 7bf8a51b9d3a8259d7a97adbde3b93a0 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception
 1
 2/******************************************************************************
 3* MODULE     : unix_sys_utils.cpp
 4* DESCRIPTION: external command handling
 5* COPYRIGHT  : (C) 2009  David MICHEL
 6*******************************************************************************
 7* This software falls under the GNU general public license version 3 or later.
 8* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 9* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10******************************************************************************/
11
12#include "unix_sys_utils.hpp"
13#include "file.hpp"
14#include <stdlib.h>
15
16int
17unix_system (string s) {
18  char* _s = as_charp (s * " > /dev/null 2>&1");
19  int ret = system (_s);
20  tm_delete_array (_s);  
21  return ret;
22}
23
24int
25unix_system (string cmd, string& result) {
26  url temp= url_temp ();
27  string temp_s= escape_sh (concretize (temp));
28  char* _cmd = as_charp (cmd * " > " * temp_s * " 2>&1");
29  int ret = system (_cmd);
30  tm_delete_array (_cmd);
31  bool flag= load_string (temp, result, false);
32  remove (temp);
33  if (flag) result= "";
34  return ret;
35}
36