我正在做一个类的赋值,在这个赋值中,我们必须为C中的Unix系统构建一个简单的shell接口。我正在使用Ubuntu,当我运行这个命令提供的源代码时:
osh> cat shell.c
我得到一个错误:
*** omake error: File /home/cameron/cs426/Project1/shell.c: line 11, characters 20-24
unexpected token: string: {
这是我第一次使用osh,那么有人知道问题是什么吗?
还有,这是密码,以防万一。
#include<stdio.h>
#include<unistd.h>
#define MAX_LINE 80 /* 80 chars per line, per command */
int main(void)
{
char *args[MAX_LINE/2 + 1]; /* command line (of 80) has max of 40 arguments */
int should_run = 1;
while(should_run){
printf("osh>");
fflush(stdout);
/**
* After reading user input, the steps are:
* (1) fork a child process
* (2) the child process will invoke execvp()
* (3) if command included &, parent will invoke wait()
*/
}
return 0;
}
最佳答案
看起来这段代码是用来作为shell的。你需要做的是:
打开一个运行真正shell的终端。osh
是OMake外壳,可能与此赋值无关。你给的密码印着“osh”,但不是osh。
使用gcc -o shell-that-calls-itself-osh shell.c
编译时,-o
标志告诉gcc
将编译的二进制文件放在哪里。
使用./shell-that-calls-itself-osh
运行./
将在当前目录中运行代码。
关于c - (Osh)Omake错误:意外 token :字符串:{,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28353114/