swcarpentry / shell-novice

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

Ep 4. Tip "Redirecting to the same file" -- to prevent following along mistake #1375

Open emcaulay opened 1 year ago

emcaulay commented 1 year ago

https://swcarpentry.github.io/shell-novice/04-pipefilter/index.html#redirecting-to-the-same-file

I am writing this issue to make it easier to discuss.

Why should a revision be considered? Pedagogy -- the flow of the Carpentries lessons is to provide "follow along" examples. However, in this section of the lesson (tip: redirecting to the same file) gives a demonstration of what not to do, and if the learner follows along then they are hampered from continuing the lesson.

A possible revision The community member who initially raised this concern suggested adding a step of making a new copy of the file before executing the bad example code. e.g.,

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.

NB: This issue is a re-working of a previous issue to provide more actionable information. (Revised from #1372)

Background The original feedback came from a Carpentries community member through the Carpentries Core team, so there is no ability to discuss further with the originator of this idea. I happened to notice the title of the issue and was intrigued to read through the issue. Once I read the comment, I could see the value of the feedback, but realized some work needed to be done to figure out what episode of the lesson the commenter was referring to. Once I did that work, I thought it would be clearer and easier to start a new issue.

bkmgit commented 1 year ago

Am in favor of this, see https://github.com/swcarpentry/shell-novice/pull/1363/files though there is a callout with the information https://github.com/swcarpentry/shell-novice/pull/1363 Maybe it is better to emphasize that one can lose data, though some participants may want a deeper explanation of why.

emcaulay commented 1 year ago

I am a bit confused (please understand I am still a novice at Git and Github) -- I think the PR linked above is a good solution.

I see the PR is closed, but I do not see the change in the episode. Was the change rejected?

emcaulay commented 1 year ago

Okay, I made some progress navigating Github, and I see that the PR was rejected. I think the PR could introduce a little protection to support learners and instructors in learning the pitfall while also being able to continue follow along with the commands presented in the episode.

gcapes commented 1 year ago

There is value in showing this (what not to do), because it differs from variable assignment which some learners might be applying to their mental model of what's going on in the shell. Reassigning to a file is different to a = a + 1.

However, I think a better solution is to remind learners how they generated the lengths.txt file in the first place, so they can recover, if they 'pressed the red button' ("don't press the red button!")

wc -l *.pdb > lengths.txt

This is less cumbersome and more realistic than making a copy of the file in order to make a deliberate mistake.

bkmgit commented 1 year ago

@emcaulay Does the suggestion seem ok to you? Would you like to make a pull request implementing this change?