swcarpentry / shell-novice

The Unix Shell
http://swcarpentry.github.io/shell-novice/
Other
375 stars 972 forks source link

Hazards of introducing commands not to follow #1372

Closed karenword closed 1 year ago

karenword commented 1 year ago

I'm a member of The Carpentries Core Team and I'm submitting this issue on behalf of another member of the community. In most cases, I won't be able to follow up or provide more details other than what I'm providing below.


There is a general flow to the entire unix shell course of discussing commands and concepts and then giving the student examples to follow. It's very incongruous then that at the Redirecting To The Same File part, students are then given a concept and shown bash commands NOT to follow! Yes, the text does say this is a bad idea, but a student will not know why. As the rest of the course is showing you examples to follow so that you understand the concept, it is not unreasonable to assume that when the example of the sort command being used to redirect output to the same file as the input, one is supposed to do this so one can actually see the mistaken results. Doing this ends up zeroing out the contents of lengths.txt, but we're not done with it yet! As we move on and need to use it later, we've shot ourselves in the foot by following the previous sort redirection example. Suggestion to make this better - Amend the text as follows:

It's a very bad idea to try redirecting the output of a command that operates on a file to the same file. We will make a copy of lengths.txt to use as an example: BASH $ cp lengths.txt lencopy.txt $ sort -n lencopy.txt > lencopy.txt Doing something like this may give you incorrect results and/or delete the contents of the file. You'll find lencopy.txt is no longer a copy, and is likely blank now.

Now as we move on and need lengths.txt later, we still have the contents we want.

emcaulay commented 1 year ago

This comment specifically relates to Episode 4, and the Tip Box labeled "Redirecting to the same file."

I think the feedback is valid, and I will write a new issue that may be easier to respond to.

emcaulay commented 1 year ago

To the maintainers, I recommend closing this issue and reviewing my revision #1375.

bkmgit commented 1 year ago

Thanks for your feedback.