johnny


Joined 2 years ago
Homeworks submitted:
Homework comments:
5
3

About Me

No description provided.

Classes

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming

Class status: Established
Role: Student
. 0% complete

Bash Scripting

Class status: Established
Role: Student
. 27% complete

Submitted Assignments

Bash Scripting: Lesson 5, HW 1

I "graded" myself ahead of time, while I'm reading the chapter I thought I would post some things I thought where interesting:

  • double bracket if tests enable regular expression testing: I see this all the time in scripts online but I don't think many script writers understand the implications of double brackets compared to single brackets.

  • expressions inside parentheses that evaluate to a nonzero status will return a 0, a zero result from an expression returns a 1. Code like C or Java and while still operates correctly even though in bash exit status's are opposite of boolean values (1 is boolean true but exit status of error, 0 is boolean false but exit status of OK)


johnny 2 years ago
Bash Scripting: Lesson 3, HW 1

Discussion in 4.8.3 has a nice one-liner for running a command and verbosely exiting if it fails: cmd || { printf "%b" "FAILED.\n" ; exit 1 ; }

set -e could also be interesting, but I have typically wrapped most if not all of my commands in 'if' or 'while' loops which negates the effect.


johnny 2 years ago
Bash Scripting: Lesson 2, HW 1

Pacing in this chapter is pretty much crap, in 3.6 the author really drops a load on the reader. But the select function is really cool!


johnny 2 years ago
Bash Scripting: Lesson 1, HW 1

All done... (better late then never). The crazy file redirection was new to me e.g. 3>&1 1>&2 2>&3.


johnny 2 years ago