Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
9736728d
Commit
9736728d
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
cleanup main
parent
7d4aef6c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sh.c
+18
-12
18 additions, 12 deletions
sh.c
with
18 additions
and
12 deletions
sh.c
+
18
−
12
View file @
9736728d
...
@@ -29,10 +29,11 @@ struct cmd cmdlist[MAXCMD];
...
@@ -29,10 +29,11 @@ struct cmd cmdlist[MAXCMD];
struct
cmd
*
cmd
;
struct
cmd
*
cmd
;
char
buf
[
BUFSIZ
];
char
buf
[
BUFSIZ
];
int
debug
=
0
;
int
debug
;
int
parse
(
char
*
s
);
int
parse
(
char
*
s
);
void
runcmd
(
void
);
void
runcmd
(
void
);
int
getcmd
(
char
*
buf
,
int
nbuf
);
int
ioredirection
(
struct
ionode
*
iolist
,
int
nio
);
int
ioredirection
(
struct
ionode
*
iolist
,
int
nio
);
int
gettoken
(
char
*
s
,
char
**
token
);
int
gettoken
(
char
*
s
,
char
**
token
);
int
_gettoken
(
char
*
s
,
char
**
p1
,
char
**
p2
);
int
_gettoken
(
char
*
s
,
char
**
p1
,
char
**
p2
);
...
@@ -40,19 +41,24 @@ int _gettoken(char *s, char **p1, char **p2);
...
@@ -40,19 +41,24 @@ int _gettoken(char *s, char **p1, char **p2);
int
int
main
(
void
)
main
(
void
)
{
{
while
(
1
){
while
(
getcmd
(
buf
,
sizeof
buf
)
>=
0
)
{
puts
(
"$ "
);
if
(
parse
(
buf
)
>=
0
)
memset
(
buf
,
0
,
sizeof
buf
);
runcmd
();
gets
(
buf
,
sizeof
buf
);
if
(
buf
[
0
]
==
0
)
// EOF
break
;
if
(
parse
(
buf
)
<
0
)
continue
;
runcmd
();
}
}
exit
();
exit
();
}
}
int
getcmd
(
char
*
buf
,
int
nbuf
)
{
puts
(
"$ "
);
memset
(
buf
,
0
,
nbuf
);
gets
(
buf
,
nbuf
);
if
(
buf
[
0
]
==
0
)
// EOF
return
-
1
;
return
0
;
}
int
int
parse
(
char
*
s
)
parse
(
char
*
s
)
{
{
...
@@ -61,13 +67,13 @@ parse(char *s)
...
@@ -61,13 +67,13 @@ parse(char *s)
gettoken
(
s
,
0
);
gettoken
(
s
,
0
);
cmd
=
&
cmdlist
[
0
];
;
cmd
=
&
cmdlist
[
0
];
for
(
i
=
0
;
i
<
MAXCMD
;
i
++
)
{
for
(
i
=
0
;
i
<
MAXCMD
;
i
++
)
{
cmdlist
[
i
].
argc
=
0
;
cmdlist
[
i
].
argc
=
0
;
cmdlist
[
i
].
token
=
0
;
cmdlist
[
i
].
token
=
0
;
cmdlist
[
i
].
io
=
cmdlist
[
i
].
iolist
;
cmdlist
[
i
].
io
=
cmdlist
[
i
].
iolist
;
}
}
while
(
1
)
{
for
(;;)
{
switch
((
c
=
gettoken
(
0
,
&
t
)))
{
switch
((
c
=
gettoken
(
0
,
&
t
)))
{
case
'w'
:
// Add an argument
case
'w'
:
// Add an argument
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment