1

Using: Ubuntu 20.04.1 LTS Editor: Nano

I am working on a small shell script for college and it needs to have menu with a range of options available to the user. One of the options is to "add a directory to the manual path based on user input". I thought I had the correct answer based on materials given to me but it isn't working?

the current location of manpath is "/usr/bin/manpath"

This is my code so far:

two() {
read -p"Please enter a directory to be added to the MANPATH: " dir
manpath=/usr/share/man$dir:$manpath; export manpath
#TO SHOW IT HAS WORKED 
which manpath
}

Any help would be greatly appreciated.

2
  • the manpath is where man finds pages, not where the command itself is supposed to be. does that help at all? Commented Oct 30, 2020 at 17:05
  • Hi, thank you for your comment :) unfortunately not, i've tried replacing manpath with man and nothing works. Thank you though. Commented Oct 30, 2020 at 17:15

1 Answer 1

2

manpath is a command that (executed without any flags) simply displays the paths where man looks for its pages. In other words, you cannot add a path to the command manpath.

Below is an illustration on how you can add a path - in this case the directory /foobar - to the already existing paths (on Debian 10).

# Original paths
manpath
/usr/local/man:/usr/local/share/man:/usr/share/man

# Adding a path
export MANPATH=$(manpath):/foobar

# Result
manpath
manpath: warning: $MANPATH set, ignoring /etc/manpath.config
/usr/local/man:/usr/local/share/man:/usr/share/man:/foobar

Does this make things a bit clearer?

Please run: man manpath. Where you will find:

DESCRIPTION
       If $MANPATH is set, manpath will simply display its contents and issue a warning.
2
  • Hi, thank you very much for your response. It has made things a lot clearer to me and has allowed me to complete the my task. Thank you again :-) Commented Oct 30, 2020 at 17:47
  • I am glad to hear that @Steven, Happy Hacking! :) Commented Oct 30, 2020 at 17:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.