Introducing UNIX and Linux |
Advanced shell programmingOverview |
Answer to chapter 9 question 3The body of this function is the same as a script, if you had
written it as a script instead. It must be written as a function in
order that the value of
addtopath() {
printf "Enter directory name: " # Prompt
read NEW # Read name
if [ -d "$NEW" ] && # Check directory
[ -r "$NEW" ] # Check readable
then PATH="$PATH":"$NEW" # Update PATH
fi
}
|
Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck