Skip to content

Commit

Permalink
Ported the support for files with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
salman-abedin committed Aug 2, 2020
1 parent b58aea6 commit 6303688
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions devour.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <stdlib.h>
#include <string.h>

char *str;

void fixpath(int argc, char *argv[], int i) {
void fixpath(int argc, char *argv[], int i, char *str) {
while (i < argc) {
strcat(str, argv[i]);
if (i != argc - 1)
Expand All @@ -21,6 +19,7 @@ void fixpath(int argc, char *argv[], int i) {
}

void runcommand(int argc, char *argv[]) {
char *str;
int arglen = 1;
char *head = "$SHELL -i -c \"", *tail = "> /dev/null 2>&1; exit\"";

Expand All @@ -32,7 +31,7 @@ void runcommand(int argc, char *argv[]) {
strcpy(str, head);
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--")) {
fixpath(argc, argv, ++i);
fixpath(argc, argv, ++i, str);
break;
}
strcat(str, argv[i]);
Expand Down

0 comments on commit 6303688

Please sign in to comment.