[C][QJ0] Command not found

I’m stuck on Stage #QJ0.

I’ve tried using system in the beginning and then migrating to execvp. But in the end, the function that checks for access on a command is the one failing.

Here are my logs:

[your-program] $ 'exe  with  space' /tmp/bar/f1
[your-program] 'exe  with  space': command not found

This is the function that checks for existence

Eexamples of full_path are

  • /tmp/qux/‘exe with space’
  • /vcpkg/‘exe with space’
    etc

My code as always is still located in GitHub - jvivallos/codecrafters-shell-c at master

1 Like

I was able to solve it! I’ll post the solution so maybe it will help someone else.

Using system to execute a command with quotes will run fine, I suppose that using one of the exec family should too.
The problem was the access checking, because the function I was using, access, won’t find a file on the path while using quotes. E.G. a path check with /usr/bin/‘exe with quotes’ will fail, but if it has the quotes removed /usr/bin/exe with quotes will succeed.

2 Likes

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