when input has "|" the string splits normally, when str does not have "|" it seg faults
char **cmds;
if (strchr(input, '|'))
cmds = split(input,'|');
else
cmds[0] = strdup(input);
when input has "|" the string splits normally, when str does not have "|" it seg faults
char **cmds;
if (strchr(input, '|'))
cmds = split(input,'|');
else
cmds[0] = strdup(input);
You need to allocate an array to store the pointer:
cmds = malloc(sizeof(*cmds));
cmds[0] = strdup(input);