【发布时间】:2015-04-05 20:21:29
【问题描述】:
我正在为班级分配一项作业,其中我们必须为 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;
}
【问题讨论】:
-
输入
which osh,可能你没有运行你想要的osh -
返回 /usr/bin/osh