How are both of these things possible at the same time

Challenge: #NI6

how is both of these supposed to work, I made it so it removes the extra spaces, but the it again supposed to keep the extra spaces.

Can anyone point out what am I missing

the log

[tester::#NI6] ✓ Received expected response
[your-program] $ echo test     script
[your-program] test script
[tester::#NI6] ✓ Received expected response
[your-program] $ echo 'example     hello' 'script''world'
[your-program] example hello scriptworld
[tester::#NI6] Output does not match expected value.
[tester::#NI6] Expected: "example     hello scriptworld"
[tester::#NI6] Received: "example hello scriptworld"
[your-program] $ 
[tester::#NI6] Assertion failed.
[tester::#NI6] Test failed

Hey @logan1o1

  • Spaces inside quotes should be preserved.
  • If two quoted strings have no space between them, they’re treated as one token.

Expected: "example     hello scriptworld"

Let me know if you’d like further clarification!

1 Like

Even I had the same doubt that you’re mentioning, and it helped me to realize the more general rule that bash shells follow: end of a quoted string does not necessarily mean end of a token. You should only end a token when you recieve either:

  • A whitespace
  • A tab
  • End of input
    (Goes without say that these should be in an unquoted string and not escaped)
1 Like

Yeah, solved, it took a while but got it

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.