cmd.c
changeset 34 5b818c7467ad
parent 33 5052c1200b68
child 35 7ee07b3cc5f9
equal deleted inserted replaced
33:5052c1200b68 34:5b818c7467ad
   244 
   244 
   245 		if (!res) {
   245 		if (!res) {
   246 			
   246 			
   247 			close (fd[0]);
   247 			close (fd[0]);
   248 			dup2 (fd[1], STDOUT_FILENO);
   248 			dup2 (fd[1], STDOUT_FILENO);
   249 			if (settings_opt_get_int ("cmd_redirect_stderr"))
   249 			if (settings_opt_get_int ( OPT_CMD_REDIRECT_STDERR ))
   250 				dup2 (fd[1], STDERR_FILENO);
   250 				dup2 (fd[1], STDERR_FILENO);
   251 			else
   251 			else
   252 				close (STDERR_FILENO);
   252 				close (STDERR_FILENO);
   253 			close (STDIN_FILENO);
   253 			close (STDIN_FILENO);
   254 			close (fd[1]);
   254 			close (fd[1]);
   255 
   255 
   256 			{
   256 			{
   257 				const char *shell = settings_opt_get ("cmd_shell");
   257 				const char *shell = settings_opt_get ( OPT_CMD_SHELL );
   258 				if (!shell)
   258 				if (!shell)
   259 					shell = getenv ("SHELL");
   259 					shell = getenv ("SHELL");
   260 				if (!shell)
   260 				if (!shell)
   261 					shell = "sh";
   261 					shell = "sh";
   262 				execl (shell, shell, "-c", arg, NULL);
   262 				execl (shell, shell, "-c", arg, NULL);
   292 		}
   292 		}
   293 
   293 
   294 		{
   294 		{
   295 			cmd_cb_t *cb = g_slice_new (cmd_cb_t);
   295 			cmd_cb_t *cb = g_slice_new (cmd_cb_t);
   296 
   296 
   297 			if (settings_opt_get_int ("cmd_header")) {
   297 			if (settings_opt_get_int ( OPT_CMD_HEADER )) {
   298 				if (settings_opt_get_int ("cmd_header_inline") || is_room (jid)) {
   298 				if (settings_opt_get_int ( OPT_CMD_HEADER_INLINE ) || is_room (jid)) {
   299 					gchar *mesg = g_strdup_printf ("$ %s", arg);
   299 					gchar *mesg = g_strdup_printf ("$ %s", arg);
   300 					gchar *utf  = to_utf8 (mesg);
   300 					gchar *utf  = to_utf8 (mesg);
   301 					g_free (mesg);
   301 					g_free (mesg);
   302 					cmd_send_msg (jid, NULL, utf);
   302 					cmd_send_msg (jid, NULL, utf);
   303 					g_free (utf);
   303 					g_free (utf);