Skip to content

Commit

Permalink
continue findthebug exercice
Browse files Browse the repository at this point in the history
  • Loading branch information
romaincarlier4 committed Oct 17, 2023
1 parent 84989a8 commit dd1ffb8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ScriptBash/buggy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

n=$1

if [[ $# -eq 0 ]]; then
touch args_err.txt
exit 0
fi

if [[ $n -eq 42 ]]; then
exit 1
exit 1
fi

exit 0
8 changes: 7 additions & 1 deletion ScriptBash/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

getinput findthebug > student/student_code.sh

if grep -q 'cd|ls|cat' student/student_code.sh; then
if grep -q -E 'cd|ls|cat' student/student_code.sh; then
feedback-result failed
feedback-msg -em "Vous n'avez pas besoin d'utiliser la commande `cd`, `ls` ou `cat`"
fi

chmod +x buggy.sh
output=$(sh student/student_code.sh)

if find args_err.txt; then
feedback-result failed
feedback-msg -em "Attention, le script buggy.sh prend comme argument un nombre entier"
exit 0
fi

if [ "$output" = "42" ]; then
feedback-result success
else
Expand Down
4 changes: 4 additions & 0 deletions ScriptBash/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ environment: default
evaluate: best
context: |-
Vous avez décidé d'écrire un script bash qui vous permet de faire certains calculs à partir d'un seul nombre.
limits:
time: '3'
output: '2'
memory: '100'
problems:
findthebug:
language: bash
Expand Down

0 comments on commit dd1ffb8

Please sign in to comment.