LUX 211 - Shell Programming

Review for Second Test

The following questions are provided to help you study for the second test. Do not expect to see these exact questions on the test.

  1. How would you load a function into RAM from a script?

  2. How can you remove a function frrom RAM once it is loaded?

  3. What is the basic structure of a function?

  4. How is a function called in a script?

  5. What set of symbols marks the body of a function?

  6. How can you end a function before you reach the last line in its body?

  7. How do you pass an argument to a function in a shell script?

  8. What are the two methods shown in chapter 8 to do math with a variable's contents?

  9. Which of the two methods above is more likely to use a dollar sign?

  10. What is the purpose of the -p option for the read command? What is the advantage of doing that?

  11. How do you use the test command to check whether two strings held in variables are the same?

  12. What marks an equal sign as a conditional operator in a test command?

  13. Why is it illogical to have a structure that follows the form ""?

  14. What is the symbol that stands for the number of arguments passed to the last command?

  15. What is the proper syntax to use in a test command that determines whether two variables containing integers are equal?

  16. What command can be used to immediately stop running a script?

  17. What is the concept behind having the command in question 16 use a return value?

  18. What is the meaning of elif? How many elifs are allowed in a single structure that uses them?

  19. What is the troubleshooting value of starting a shell with the -x option?

  20. How does the for structure differ from the structure?

  21. What does the break command do when it is issued inside a loop?

  22. What does the continue command do when it is issued inside a loop?

  23. What are the file descriptors for stdin, stdout, and stderr?

  24. What is the value of $0 when a script starts running?

  25. What are the positional descriptors used for in a script or a function?

  26. Why are we warned to use double quotes around a reference to a positional parameter?

  27. How do we reference the exit code of the most recently ended process?

  28. What does the text mean when it says that shell variables are typically local?

  29. What makes a variable an environment variable?

  30. Can a process pass environment variables to a child process? Can the child process change environment variables? Why is that answer complicated?

  31. How can we most simply load a series of words into an array?

  32. What is the first subscript in any array?

  33. What is the syntax to echo the value stored in a particular array element/item/member? (Yes, those words mean the same thing in this context.)

  34. Can a function overwrite the value stored in a variable that was created in the script that called the function? How can we prevent that from happening accidentally?

  35. What is a builtin command? How is it handled differently from a command strored in a /bin folder?

  36. Describe the two syntaxes for the let command discussed in chapter 10.

  37. What is incrementation? What are the two versions of using the incrementation operator?

  38. How does the shell interpret two commands separated by the && operator? What about the || operator?