cmdchallenge icon indicating copy to clipboard operation
cmdchallenge copied to clipboard

Files vs symlinks

Open discoltk opened this issue 8 years ago • 9 comments

Being a test of unix command line proficiency, I took the instructions literally. I was surprised to find that when you refer to files below the current directory, you're actually talking about symbolic links to files located elsewhere. I think the instructions should be accurate.

discoltk avatar Apr 07 '17 07:04 discoltk

Thanks for the feedback, I will look at improving the description. In the meantime feel free to submit a PR against https://github.com/jarv/cmdchallenge/blob/master/challenges.yaml if you would like to improve it yourself.

jarv avatar Apr 07 '17 07:04 jarv

Is it intentional that the files are symlinks? Making them be files instead of symlinks would make the challenge description accurate without changing the wording.

discoltk avatar Apr 07 '17 07:04 discoltk

If we are talking about this challenge https://github.com/jarv/cmdchallenge/blob/master/challenges.yaml#L177 then it is using the general term file to refer to everything, directories, symlinks, etc. which is not wrong though I agree it could be confusing. Maybe we should change the description to simply say:

      Delete the entire contents of this challenge
      directory recursively.

jarv avatar Apr 07 '17 08:04 jarv

Actually it was "search for string in files recursive" that I noticed it. find . -type f -name "access.log*" -exec egrep string {} \;

Didn't return anything, because its a symlink, not a file. It says to search through the files in the current directory, and even hints that its in a nested directory, but there literally are no files, only symlinks to files elsewhere. Unless there is a reason they're symlinks, I'd just make them actual files and then the description is accurate.

# Print all matching lines (without the filename
# or the file path) in all files under the current
# directory that start with "access.log" that
# contain the string "500". Note that there are no
# files named "access.log" in the current directory,
# you will need to search recursively.

discoltk avatar Apr 07 '17 09:04 discoltk

Yes, it is a bit confusing.

find -L . -type f -name "access.log*" -exec egrep string {} \;

Will - with the -L flag - act like you expect. I think in the ideal case there are a few files and a few symlinks, so people realize they might have missed the latter if they always blindly apply find as is.

mrquincle avatar Apr 30 '17 18:04 mrquincle

For me personally, I'm not always this pedantic - but when it come to UNIX you really ought to be! It's an unforgiving system.

The person taking the challenge should not need to toy around with different parameters to figure out what the challenge really intended they solve. The directions should be explicit and accurate, so the person can type the correct answer the first time. Symlinks aren't files. Maybe have a separate challenge entirely which allows the person to show full understanding of symlinks (and hard linking for that matter.)

At least use language like: "Find all the files within, or files referenced from within this directory structure which contain xxxx"

On Mon, May 1, 2017 at 3:02 AM, Anne van Rossum [email protected] wrote:

Yes, it is a bit confusing.

find -L . -type f -name "access.log*" -exec egrep string {} ; Will of course with the -L act like you expect. I think in the ideal case there are a few files and a few symlinks, so people realize they might have missed the latter if they always blindly apply find as is.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jarv/cmdchallenge/issues/131#issuecomment-298247091, or mute the thread https://github.com/notifications/unsubscribe-auth/AADr0YOUxGmk3rKsrU3zUuLvkofuQgvLks5r1MzQgaJpZM4M2jwl .

discoltk avatar May 01 '17 01:05 discoltk

  • I don't know anything about UNIX.
  • A symbolic link is a file, a special kind of file: http://man7.org/linux/man-pages/man7/symlink.7.html

mrquincle avatar May 01 '17 07:05 mrquincle

In that sense, a FIFO is also a special (kind of) file.

http://man7.org/linux/man-pages/man7/fifo.7.html

I would not assume we were intended to read from one where it present.

On Mon, May 1, 2017 at 4:25 PM, Anne van Rossum [email protected] wrote:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jarv/cmdchallenge/issues/131#issuecomment-298298552, or mute the thread https://github.com/notifications/unsubscribe-auth/AADr0RrkJeWeF5Q7OsulxWqsSM2GGyxnks5r1YjxgaJpZM4M2jwl .

discoltk avatar May 01 '17 07:05 discoltk

That might have been reasonable (there is an underlying inode). :-) However, fifos were not present in the assignment.

Apart from all this, I think you're right with suggesting a more crisp description of what to do.

"Find all the (linked) files ..." would also be sufficient.

mrquincle avatar May 01 '17 08:05 mrquincle