Skip to content

Fix conditions for handling `&`, `< file` and `> file` arguments.

Dirk Doesburg requested to merge ddoesburg/assignment1:patch-1 into master

The parser in the template fails to remove the > file , < file, and & from the arguments when a command has only 3 parts, but it does work when there are more arguments. This is solved by decrementing the required number of arguments in the conditions in parseCommand.

$ cat < test-dir/1
doing `cat` with arguments: 
- `cat`
- `<`
- `test-dir/1`
cat: <: No such file or directory
line 1
line 2
line 3
line 4
$ cat > hi.txt
doing `cat` with arguments: 
- `cat`
- `>`
- `hi.txt`
cat: >: No such file or directory
$ cat 1 > hi.txt
doing `cat` with arguments: 
- `cat`
- `1`
cat: 1: No such file or directory
$

Merge request reports