【问题标题】:(Osh) Omake Error: Unexpected Token: String: {(Osh)Omake 错误:意外令牌:字符串:{
【发布时间】: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

标签: c shell ubuntu


【解决方案1】:

看起来这段代码是为了成为一个shell。你需要做的是:

  1. 打开一个运行真实 shell 的终端。 oshOMake shell,可能与此分配无关。您提供的代码打印“osh”,但不是 osh。
  2. 使用gcc -o shell-that-calls-itself-osh shell.c 编译-o 标志告诉gcc 将编译后的二进制文件放在哪里。
  3. ./shell-that-calls-itself-osh运行./是在当前目录运行代码。

【讨论】:

  • 谢谢。说明使用osh作为说明,但现在你提到它,我认为你是对的。
猜你喜欢
  • 1970-01-01
  • 2014-12-04
  • 2023-03-23
  • 2023-04-03
  • 2011-12-20
  • 2015-11-19
  • 2018-08-27
  • 2014-12-07
  • 2016-08-10
相关资源
最近更新 更多