Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivien/2883502 to your computer and use it in GitHub Desktop.
Save vivien/2883502 to your computer and use it in GitHub Desktop.
From 2ac63f597648408c225ea43a447363f7b913a035 Mon Sep 17 00:00:00 2001
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Wed, 6 Jun 2012 12:24:47 -0400
Subject: [PATCH] io: use system() if a command contains a pipe
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/io.c b/io.c
index 0c1a8f7..5c46e2a 100644
--- a/io.c
+++ b/io.c
@@ -309,9 +309,13 @@ io_run(struct io *io, enum io_type type, const char *dir, const char *argv[], ..
{
int pipefds[2] = { -1, -1 };
va_list args;
+ char cmd[SIZEOF_STR];
io_init(io);
+ if (argv_to_string(argv, cmd, sizeof(cmd), " ") && strchr(cmd, '|'))
+ return !!system(cmd);
+
if (dir && !strcmp(dir, argv[0]))
return io_open(io, "%s%s", dir, argv[1]);
--
1.7.10.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment