would add /opt/bin to PATH only if that pathname is not already in PATH. Be sure your solution works even if the shell variable starts out empty. Also make sure you check the list elements carefully. If /usr/opt/bin is in PATH but /opt/bin is not, the example just given should still add /opt/bin to PATH. (Hint: You might find this exercise easier to complete if you first write a function locate_field that tells you whether a string is an element in the value of a variable.)

Lists are commonly stored in environment variables by putting a colon
(:) between each of the list elements. (The value of the PATH variable is
an example.) You can add an element to such a list by catenating the new
element to the front of the list, as in

PATH=/opt/bin:$PATH

If the element you add is already in the list, you now have two copies of it
in the list. Write a shell function named addenv that takes two arguments:
(1) the name of a shell variable and (2) a string to prepend to the list that is
the value of the shell variable only if that string is not already an element of
the list. For example, the call

addenv PATH /opt/bin


Computer Science & Information Technology

You might also like to view...

In a try-catch statement, the ____________ keyword appears immediately after the try block.

a. try b. catch c. break d. continue

Computer Science & Information Technology

When you create a table, all of the cells have black, solid line borders of which point size?

A) 1/2 point B) 1.5 pt C) 2 pt D) 1 pt

Computer Science & Information Technology

Write a program based on Figs. 20.20–20.22 that inputs a line of text, tokenizes the sen- tence into separate words (you may want to use the strtok library function), inserts the words in a binary search tree and prints the inorder, preorder and postorder traversals of the tree. Use an OOP approach.

What will be an ideal response?

Computer Science & Information Technology

Item D in the accompanying figure is used to set the _______________ for the audio player plugin.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology