C (Osh)Omake错误:意外标记:字符串:{

C (Osh)Omake错误:意外标记:字符串:{,c,shell,ubuntu,C,Shell,Ubuntu,我正在处理一个类的赋值,在这个类中,我们必须用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,那么有没有人知道这

我正在处理一个类的赋值,在这个类中,我们必须用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;
}
#包括
#包括
#定义每行、每命令的最大行80/*80个字符*/
内部主(空)
{
char*args[MAX_-LINE/2+1];/*命令行(共80个)最多有40个参数*/
int应该运行=1;
while(应该运行){
printf(“osh>”);
fflush(stdout);
/**
*读取用户输入后,步骤如下:
*(1)fork子进程
*(2)子进程将调用execvp()
*(3)如果包含命令&,则父级将调用wait()
*/
}
返回0;
}

这段代码看起来像是一个shell。您需要做的是:

  • 打开运行真实外壳的终端。
    osh
    是外壳,可能与此任务无关。您提供的代码打印“osh”,但不是osh
  • 使用名为osh shell.c的
    gcc-o shell编译
    -o
    标志告诉
    gcc
    将编译的二进制文件放在哪里
  • 使用名为osh的
    /shell运行
    /
    将在当前目录中运行代码

  • 键入
    哪个osh
    ,可能您没有运行
    osh
    ,您想要返回/usr/bin/osh谢谢。说明中使用了
    osh
    作为说明,但现在您提到了它,我认为您是对的。