Why when I run this code with any other commands (like “date” “pwd” or “ls”) in gives output on screen, but with env not? Path is correct, what exactly is the issue? It is a part of Minishell project which consists in replicating part of the functionality of bash shell.
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
char *argv[] = {"env", NULL};
if (execve("/usr/bin/env", argv, NULL) == -1) {
perror("execve");
return 1;
}
// This line will only be reached if execve fails
printf("This won't be printed if execve succeeds.n");
return 0;
}
New contributor
Ekaterina Mikhailova is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.