how can I handle ls to pass this test case:
I assume if ls with no arguments I will list everything inside current working directory if there is an argument , I will check if it is a directory then list its content ,if it is a regular file I just printing the name , so what is the wrong here
I have build a function that takes the argument of ls command , if no argument , I am listing the file in current directory which is the current path , if there an argument I check if it is a directory and list its files content , if regular file I am just writing the name of the file, now I can not understand what happen in this test case , is this a directory : /tmp/quz ? I need someone to explain the test case setup for me to help me pass this stage
here is my last try output:
Hi @mohamed-khalaf9, it seems you’ve implemented a custom version of ls
? If that’s the case, there’s no need to do so.
The ls
command is already available as an executable on our tester, likely as /bin/ls
. You can simply run it as you did in stage #IP1 (Run a Program).
Here’s a successful run for your reference:
but why the tester display expected: “mango” one file just not all ?
I think that the problem from the tester it expects just one file name , I don’t understand why, you can check screenshots provided by me not like your provided one
I think our expectations run line-by-line, which is why the error looks confusing. It’s only printing the expected/received log for the first line.
Once you implement printing each item on one line (by just using the default ls), things should work.