Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment Mini Shell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
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
Dana-Maria CĂRUNTU
Assignment Mini Shell
Commits
fcde7d21
Commit
fcde7d21
authored
3 months ago
by
Dana-Maria CĂRUNTU
Browse files
Options
Downloads
Patches
Plain Diff
add sequential command execution (25p)
parent
c55097ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#98734
passed
3 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cmd.c
+2
-17
2 additions, 17 deletions
src/cmd.c
with
2 additions
and
17 deletions
src/cmd.c
+
2
−
17
View file @
fcde7d21
...
...
@@ -31,8 +31,6 @@
static
bool
sanity_check_simple_command
(
simple_command_t
*
s
);
static
bool
sanity_check_command
(
command_t
*
c
);
static
void
clean_resources
(
int
count
,
...);
/**
* Internal change-directory command.
*/
...
...
@@ -80,8 +78,6 @@ static void handle_input_redirection(word_t *in)
DIE
(
dup2
(
fd_in
,
STDIN_FILENO
)
==
-
1
,
"Failed to duplicate file descriptor for input redirection"
);
// close(fd_in);
// free(input_file);
clean_resources
(
1
,
fd_in
,
input_file
);
}
...
...
@@ -101,9 +97,6 @@ static void handle_output_redirection(word_t *out, int io_flags, word_t *err)
DIE
(
dup2
(
fd
,
STDOUT_FILENO
)
==
-
1
,
"Failed to redirect stdout"
);
DIE
(
dup2
(
fd
,
STDERR_FILENO
)
==
-
1
,
"Failed to redirect stderr"
);
// close(fd);
// free(output_file);
// free(error_file);
clean_resources
(
1
,
fd
,
output_file
);
if
(
error_file
!=
output_file
)
{
free
(
error_file
);
...
...
@@ -112,7 +105,6 @@ static void handle_output_redirection(word_t *out, int io_flags, word_t *err)
}
// if stdout and stderr are redirected to different files
// initialise with -1 to indicate that file descriptors are not yet opened
int
fd_out
=
-
1
,
fd_err
=
-
1
;
...
...
@@ -122,9 +114,6 @@ static void handle_output_redirection(word_t *out, int io_flags, word_t *err)
DIE
(
fd_out
==
-
1
,
"Failed to open output file"
);
DIE
(
dup2
(
fd_out
,
STDOUT_FILENO
)
==
-
1
,
"Failed to redirect stdout"
);
// close(fd_out);
// free(output_file);
}
if
(
error_file
)
{
...
...
@@ -133,9 +122,6 @@ static void handle_output_redirection(word_t *out, int io_flags, word_t *err)
DIE
(
fd_err
==
-
1
,
"Failed to open error file"
);
DIE
(
dup2
(
fd_err
,
STDERR_FILENO
)
==
-
1
,
"Failed to redirect stderr"
);
// close(fd_err);
// free(error_file);
}
clean_resources
(
2
,
fd_out
,
output_file
,
fd_err
,
error_file
);
...
...
@@ -149,7 +135,6 @@ static void handle_redirections(simple_command_t *s)
handle_output_redirection
(
s
->
out
,
s
->
io_flags
,
s
->
err
);
}
/**
* Parse a simple command (internal, environment variable assignment,
* external command).
...
...
@@ -277,9 +262,9 @@ int parse_command(command_t *c, int level, command_t *father)
switch
(
c
->
op
)
{
case
OP_SEQUENTIAL
:
parse_command
(
c
->
cmd1
,
level
,
c
);
return
parse_command
(
c
->
cmd2
,
level
,
c
);
/* TODO: Execute the commands one after the other. */
break
;
case
OP_PARALLEL
:
/* TODO: Execute the commands simultaneously. */
break
;
...
...
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