In principle, recursion is never necessary. It can always be replaced by an iterative construct, such as while or until. Rewrite makepath (page 502) as a nonrecursive function. Which version do you prefer? Why?

What will be an ideal response?


function makepath2()
{
wd=$(pwd)
pathname=$1
while [[ $pathname = */* && ${#pathname} > 0 ]]
do
if [[ ! -d "${pathname%%/*}" ]]
then
mkdir "${pathname%%/*}"
fi
cd "${pathname%%/*}"
pathname="${pathname#*/}"
done
if [[ ! -d $pathname && ${#pathname} > 0 ]]
then
mkdir $pathname
fi
cd $wd
}

The recursive version is simpler: There is no need to keep track of the work-
ing directory and you do not have to handle the task of making the final
directory separately.

Computer Science & Information Technology

You might also like to view...

Standard modules are saved on disk as files that end with this extension.

a. .mod b. .proj c. .frm d. .vb

Computer Science & Information Technology

You can click Microsoft Expression on the All programs list to display the list of installed Microsoft Expression programs, as shown in the accompanying figure.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

AppLocker enables the administrator to specify exactly what users are permitted to run on their desktops according to unique file identities

Indicate whether the statement is true or false

Computer Science & Information Technology

Describe the Near Field Communication (NFC) technology.

What will be an ideal response?

Computer Science & Information Technology