开发者

How to add your application path to the user's shell path?

Is there a way to add your application path to开发者_JAVA百科 a user's .bash_profile path variable using shell script? Also, what if the user was using a different shell like zsh etc? Is it possible to "universally" add your application path to the user's shell PATH?


Different shells have different syntaxes so there's no real "standard" way.

There are a couple of things you can do.

  1. Install your application confirming to the FHS so that the default paths work. This means that your executables will be (alteast symlinked) in /usr/bin etc.
  2. At the end of your installation routine, spit out a few shells snippets that the user can stick into their shell initialisation scripts so that they can use your application. You can also take this a level further and test the users SHELL variable and insert the appropriate snippet into the correct initialisation file. This might be unwise though. I don't like programs modifying my personal init files. You can support the csh "family" and the bash "family". That should cover most of the cases. People who use more obscure shells will most probably be knowledgeable enough to port the PATH settings anyway.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜