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
which manpath

Any help would be greatly appreciated.

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

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

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

# Result
manpath: warning: $MANPATH set, ignoring /etc/manpath.config

Does this make things a bit clearer?

Please run: man manpath. Where you will find:

       If $MANPATH is set, manpath will simply display its contents and issue a warning.
  • 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 :-) – Steven Oct 30 '20 at 17:47
  • I am glad to hear that @Steven, Happy Hacking! :) – maulinglawns Oct 30 '20 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.