42_EXAM icon indicating copy to clipboard operation
42_EXAM copied to clipboard

[exax 06] Issue with `test_eof.sh` script

Open nicolasgasco opened this issue 1 year ago • 1 comments

Hello! I noticed something in the exam 06 that doesn't look quite right to me.

You're executing a test_eof.sh script that prints what I think it's supposed to be every line of the eof_test file:

// test_eof.sh

for x in `cat eof_test`; do
  printf $x
  sleep 0.1
done
// eof_test

Ceci est un test de Ctrl+D dans ton programme ici:\04Si tu ne passes pas ce test, tu devrais verifier le fonctionnement du ctrl+d.
voici
un
nouveau
test

At least on my setup (M1 MacBook Pro with Ventura), that script actually prints each word separately and not one line at a time.

Looking at the output of the trace I get when I'm graded, you're expecting the whole first sentence to be printed in one statement by the server.

Given that the subject says we shouldn't do any unnecessary buffering, I think something is not working right with your script. It would produce the right output if your test_eof.sh wouldn't print one word at the time.

Thank you!

nicolasgasco avatar Jun 25 '23 13:06 nicolasgasco

I think something like this would work:

while read p; do
    printf "$p"
    sleep 0.1
done <eof_test | nc localhost $1

nicolasgasco avatar Jun 25 '23 13:06 nicolasgasco