Skip to content

Conversation

@katrinabrock
Copy link

This is an unsolicited PR so feel free to close without merging you don't think this needs fixing. Goal is to actually explain what learners need to know about recursion rather than linking out to wikipedia.

Changes:

  • Explain the concept in simple words when first introduced
  • Remind learners of the in-context meaning throughout

This is unfortunately a net add of content. I think it is possible to make the explanation(s) more concise, but likely will still be a net add since it adds an explanation that wasn't there before. I think overall it makes the lesson more clear to a learner who is not already familiar with the concept of recursion.

- Explain the concept in simple words when first introduced
- Remind learners of the in-context meaning throughout
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🆗 Pre-flight checks passed 😃

This pull request has been checked and contains no modified workflow files, spoofing, or invalid commits.

It should be safe to Approve and Run the workflows that need maintainer approval.

Co-authored-by: Benson Muite <bkmgit@users.noreply.github.com>
Comment on lines +96 to +102
The `-R` option to the `ls` command will list all nested subdirectories within a directory.
`R` in `-R` stands for "Recursive" which refers to the idea that the output of a process
becomes the input of another iteration of that same process.
So in this case, `ls -R` lists the contents of a directory, and for every directory
it finds, it lists the contents of that directory,
and for every directory inside those subdirectories,
it lists the contents, and so on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Recursion" should be in the glossary? This might allow simplifying the paragraph.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it should be added. I'll add that to this PR. I still think a short inline explanation would be helpful. The instructor will need to verbally explain -R/-r somehow so I think coming up with some nice concise and approachable wording will be helpful.

Comment on lines +164 to +167
: A recursive precudure is one where one step of the procedure is to apply the procedure itself
(usually to a different input).
In the context of shell, it often refers to applying a command to a directory and to all directories
contained within that directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
: A recursive precudure is one where one step of the procedure is to apply the procedure itself
(usually to a different input).
In the context of shell, it often refers to applying a command to a directory and to all directories
contained within that directory.
: A recursive procedure is one where the output of an iteration
is the input of another iteration of that procedure.

Is context of the shell lesson helpful? Maybe should be added to
other terms if it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this because for all except ls, the command itself is not recursive. Really the only "recursive" part is finding files that we apply the command to. e.g. in grep, we are not applying some kind of recursive algo to search ie feeding the output of the search back into the search algo multiple times (not sure what that would even mean, maybe something akin to a recursive regex 😬 ). We are recursively crawling the filesystem to identify files to search, and then searching them (once each).

For this reason, I think the main thing learners need to know is that -r/-R means "apply this to the entire directory tree within the specified directory". They don't need to fully understand recursion as a general concept. In fact, imo, trying to dig into that would be distracting/confusing. I think it's enough to cover that recursion is a more general concept that has something to do with applying a process in a tree-like manner and in this context when applied to a directory means applying to everything inside as well.

This "apply to everything inside" is probably novices default way of thinking of commands and the fact that it's not the default for shell commands and -r/-R needs to be added is something to actively learn. Meaning, when you copy a folder in a GUI, typically the contents are also copied. When you search a folder in a GUI, typically that means searching all the contents and subfolder contents etc.

Comment on lines +96 to +102
The `-R` option to the `ls` command will list all nested subdirectories within a directory.
`R` in `-R` stands for "Recursive" which refers to the idea that the output of a process
becomes the input of another iteration of that same process.
So in this case, `ls -R` lists the contents of a directory, and for every directory
it finds, it lists the contents of that directory,
and for every directory inside those subdirectories,
it lists the contents, and so on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps if

The `-R` option to the `ls` command will list all nested subdirectories within a directory.

is changed to

The `-R` or `--recursive` option to the `ls` command will make `ls` a [recursive] procedure
which lists all nested sub-directories within a directory.

to ensure recursive links to the glossary add

just before the Keypoints section, see #1510
Then the above can be shortened to

Suggested change
The `-R` option to the `ls` command will list all nested subdirectories within a directory.
`R` in `-R` stands for "Recursive" which refers to the idea that the output of a process
becomes the input of another iteration of that same process.
So in this case, `ls -R` lists the contents of a directory, and for every directory
it finds, it lists the contents of that directory,
and for every directory inside those subdirectories,
it lists the contents, and so on.
The command `ls -R` lists the contents of a directory, and for every directory
it finds, it lists the contents of that directory,
and for every directory inside those subdirectories,
it lists the contents, and so on.

katrinabrock and others added 2 commits November 7, 2025 14:49
Co-authored-by: Benson Muite <bkmgit@users.noreply.github.com>
Co-authored-by: Benson Muite <bkmgit@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants