我創建了一個小的unix shell,execve與sed
有個問題。當我執行sed -e 's/Roses/Turnips/'
命令失敗與execve。execve與sed失敗
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
int main(int ac, char **av, char **envp)
{
char *argv[] = { "/usr/bin/sed", "-e", "'s/Roses/Turnips/'", 0 };
execve(argv[0], &argv[0], envp);
fprintf(stderr, "Failed!\n");
return -1;
}
錯誤:
/usr/bin/sed: -e expression #1, char 1: unknown command: `''
您是否試過轉義單引號? – t0mm13b