Question: Unix/Lunix Programming Exercise 4 Read the following script process_cmd_arg and answer the question. usage () { echo usage: program [-f file | -i] } #

Unix/Lunix Programming

Exercise 4

Read the following script process_cmd_arg and answer the question.

usage () {

echo "usage: program [-f file | -i]"

}

# process command line argument

interactive=

filename=

while [[ -n $1 ]]; do

if [[ "$1" == "-f" ]]; then

shift

filename=$1

elif [[ "$1" == "-i" ]]; then

interactive=1

elif [[ "$1" == "-h" ]]; then

usage

exit

else

usage >&2

exit 1

fi

shift

done

Trace the values of the following variables during the execution of a given command.

Command: process_cmd_arg -f outputFile

interactive

filename

$1

Command: process_cmd_arg -i

interactive

filename

$1

Command: process_cmd_arg -h

interactive

filename

$1

Command: process_cmd_arg -f outputFile -i

interactive

filename

$1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!