package

simple and robust package manager
Log | Files | Refs | README

commit bd6163e1cb319b01958a621ae4755fc0accf0010
parent 138f73da6d29fefb2f814e308fed8ca9137b6aee
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 13 Jan 2019 14:23:58 +0100

fix fs.c redirection

Diffstat:
Mfs.c | 8++++----
Mpack-get.c | 3++-
Mpack.c | 2+-
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs.c b/fs.c @@ -38,7 +38,7 @@ fs_redir_read(int fd, char const *path) { int newfd = open_read(path); if (newfd == -1) return 0; - if (dup2(fd, newfd) == -1) return 0; + if (dup2(newfd, fd) == -1) return 0; return 1; } @@ -47,7 +47,7 @@ fs_redir_write(int fd, char const *path) { int newfd = open_write(path); if (newfd == -1) return 0; - if (dup2(fd, newfd) == -1) return 0; + if (dup2(newfd, fd) == -1) return 0; return 1; } @@ -56,7 +56,7 @@ fs_redir_append(int fd, char const *path) { int newfd = open_append(path); if (newfd == -1) return 0; - if (dup2(fd, newfd) == -1) return 0; + if (dup2(newfd, fd) == -1) return 0; return 1; } @@ -65,7 +65,7 @@ fs_redir_trunc(int fd, char const *path) { int newfd = open_trunc(path); if (newfd == -1) return 0; - if (dup2(fd, newfd) == -1) return 0; + if (dup2(newfd, fd) == -1) return 0; return 1; } diff --git a/pack-get.c b/pack-get.c @@ -45,6 +45,7 @@ main(int argc, char **argv) char *log; char *def; char *tar; + char *cmd; int fd = -1; size_t n; size_t r; @@ -86,7 +87,7 @@ main(int argc, char **argv) buffer_init(&b, &read, fd, buf, sizeof buf); while (stralloc_zero(&sa), (r = buffer_getline(&b, &sa)) > 0) { - char *cmd = NULL; + cmd = NULL; if (sa.x[sa.n - 1] == '\n') --sa.n; if (!stralloc_cat0(&sa)) die_nomem(); diff --git a/pack.c b/pack.c @@ -293,7 +293,7 @@ pack_patch(pack const *p, char *def) path.n = m; if (!stralloc_cats(&path, de->d_name)) goto err; if (!stralloc_cat0(&path)) goto err; - if (fs_redir_read(0, path.x) == -1) goto err; + if (!fs_redir_read(0, path.x)) goto err; if (forkexec_wait(argv) != 0) goto err; close(fd); }