New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

06-script: user-defined variables in scripts #512

Open
stouffer opened this Issue Feb 10, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@stouffer

stouffer commented Feb 10, 2017

In order to remind learners about the idea of shell variables (which are introduced in 05-loops) and reinforce good practice, legibility, helping future users, etc., I'd like to suggest that we add another example after introducing comments. Specifically, it could look like:

$ nano middle.sh
# Select lines from the middle of a file.
# Usage: bash middle.sh filename end_line num_lines
filename="$1"
end_line="$2"
num_lines="$3"
head -n "$end_line" "$filename" | tail -n "$num_lines"

Since variables are already come up in the previous lesson, I expect that the added time should be quite minimal whereas the payoff is quite important since some learners might forget that they can define their own variables or, worse, think that they are constrained to use the default special variables.

The downside is that many instructors are already pressed for time at this stage without new/additional material. Therefore, ways to cut back that don't strike me personally as too large a sacrifice could include:

  1. Removing the "Why Isn't It Doing Anything?" section. I find that this is often quite confusing for learners and in my experience isn't that common an error when starting to write one's own scripts.
  2. Moving the "Why Isn't It Doing Anything?" section to be a new challenge along the lines of the "Debugging Scripts" challenge that already exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment