------------------------- Week 10 Notes for CST8129 ------------------------- -Ian! D. Allen - idallen@idallen.ca *** Keep up on your readings (Course Outline: average 5 hours/week homework) Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) -------------- Review midterm -------------- I did a review of all M/C questions you found difficult. I wrote the script part of the test. The midterm script was mostly code already written for you in the online script examples, in particular, practiceTest2script.sh.txt . ---------- This week: ---------- Chapter references to current material: Chapter 7 - Bourne Shell 7.3.1 - exit status 7.3.2 - semicolon 7.3.3 - && and || 7.3.4 - background use of shell (optional) 7.4 - metacharacters 7.5 - GLOB 7.6 - variables - modifiers - know four basic variable modifiers (p.301) - $1, $2, $* $@ - .8 special vars 7.7 - quoting 7.8 - command substitution - use bash $(...) syntax instead 7.10 - stdio and redirection 7.11 - pipes New: modifiers - know four basic variable modifiers (p.301) ---------- Next week: ---------- Readings: Chapter 7 - Bourne Shell 7.9 - shell functions 7.12 - "here" documents Chapter 8 - Bourne Shell Programming 8.1 - intro 8.2 - read 8.3 - arithmetic - use ksh/bash "let" statement instead (12.3.4 p.662) 8.4 - positional parameters (especially $* and $@) 8.5 - conditional constructs and flow control - new: the "case" statement 8.6 - looping - new: the "for" command the "until" command (rare) the "shift" command the "break" command the "continue" command - new: subshells with redirection 8.7 - shell functions 8.8 - trapping signals 8.8.5 - debugging !! important !! Chapter 15 - Debugging Shell Scripts - ignore the CSH and TCSH scripts - we use the Bourne Shell syntax more than the Bash syntax, since the Bourne syntax works everywhere - 15.2 - very important advice - use the echo and verbose switches! 15.5.1 - 15.3.3 - know your script permissions - 15.3.4 - ignore the book; never put "." in your PATH - 15.3.5 - use a correct #! line - 15.3.6 - Bourne shell scripts do not load aliases - 15.4.1 - always use -u to detect undefined/misspelled variables - 15.4.2 - don't leave off keywords - indent correctly - use "test" and "[" correctly - quote properly - test script arguments (esp. files) before you use them