Operating Systems and Systems Integration Quiz 5: Shell Programming Do not refer to any printed material. No talking or discussion is allowed until the answer sheets are all collected. Review: 1. It is necessary to quote the parentheses ‘(...)’ in the following shell command because: $ echo \(3 + 4\) \* 5 (A) The shell will try to start a subshell (B) The precedence will be wrong, i.e., addition will not be done before multiplication (C) The shell will cause a sementation fault (D) The shell will terminate with a divide by zero exception (E) The shell will expand into a list of files otherwise 2. Which of the following will cause a shell variable x to be defined with the value 10? (A) $ $x=10 (B) $ $x=${10} (C) $ $x = 10 (D) $ x = 10 (E) $ x=10 3. A shell script script.sh is executed like this, and the output is shown: $ script.sh 1 2 3 4 5 6 parameters are 1 2 3 The first line of the file script.sh is #! /bin/sh The second line could be: (A) $ parameters are $1 $2 $3 (B) $ echo parameters are $0 $1 $2 (C) $ echo parameters are $# $1 $2 (D) $ echo parameters are $param1 $param2 $param3 (E) $ echo parameters are $1 $2 $3 Preparation: 4. In the shell, while loops: (A) are not supported; we use for loops instead (B) used with the keywords do. . . done (C) used with the keywords do. . . elihw (D) used with braces, as in C and Java (E) used with the keywords do. . . fi 5. Functions in the shell: (A) are not actual functions, but are separate shell scripts that are loaded at run time (B) are not supported in version 2.x of Bash; (C) are less useful that in other programming languages (D) Cannot accept function parameters (E) are not used as much as shell objects Nick Urbanik ver. 1.0