(Osh) Omake Error: Unexpected Token: String: {
(Osh) Omake Error: Unexpected Token: String: {
我正在为 class 做作业,其中我们必须用 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 shell,可能与此分配无关。您提供的代码 prints "osh",但不是 the osh.
- 用
gcc -o shell-that-calls-itself-osh shell.c
编译 -o
标志告诉 gcc
将编译后的二进制文件放在哪里。
- 运行和
./shell-that-calls-itself-osh
./
是当前目录下的运行代码。
我正在为 class 做作业,其中我们必须用 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 shell,可能与此分配无关。您提供的代码 prints "osh",但不是 the osh. - 用
gcc -o shell-that-calls-itself-osh shell.c
编译-o
标志告诉gcc
将编译后的二进制文件放在哪里。 - 运行和
./shell-that-calls-itself-osh
./
是当前目录下的运行代码。