I`m encountered with bug(?) in test case

I’m doing Two Fer task for Bash and my 4 test failed. Next i’ll atach my code:

main () {
    if [ $# -ge 1 ]
    then
        echo "One for $1, one for me." 
    else
        echo "One for you, one for me."
    fi
}

main $@

and i facing on with the next test case:

-- output differs --
expected : One for John Smith, one for me.
actual   : One for John, one for me.
--
entry parametrs:
"John Smith" "Mary Ann"

What i`m doing wrong?

This is why it’s so important to quote your variables. As some double quotes on the last line.

1 Like

but I use double quotes in line 4…
My interpreter outputs the answer that is expected, but the one used on the site prints only the first word in the first parameter

I realized my mistake, I forgot to use double quotes in the condition :man_facepalming:

No, you forgot to put quotes here:

main $@

When your program receives 2 arguments, “John Smith” and “Mary Ann”, you are sending 4 arguments to the main function: John, Smith, Mary, Ann.

My top-voted answer on StackOverflow gives a quick demonstration about the importance of quotes.