project_bin - Call a Dir::Project specific program
[program] [program_arguments] [program] --project_bin-help [program] --project_bin-which project_which [program] # Example script dispatching cd ~/project1 project_dir --project /path/to/project1 my_tool my_args.... # Executes project1/.../my_tool cd ~/project2 project_dir --project /path/to/project2 my_tool my_args.... # Executes project2/.../my_tool
This program is not usually called directly. Instead project_bin is symlinked as the name of the program to be executed. project_bin then uses that name to determine the program to be called. Alternatively the --project_bin-run option may be used to specify what to execute directly.
This process enables multiple versions of a program to exist in different project directories. The global path only contains a simple non-changing symlink which everyone can share.
prog is to be executed. The shell uses the standard PATH environment variable and finds
prog under $DIRPROJECT_PREFIX/bin/prog. $DIRPROJECT_PREFIX/bin/prog is installed as a simple symlink to project_bin. Thus the shell executes project_bin.
Project_bin then determines the current project and sets the DIRPROJECT environment variable, which has the link to the current project area. See Dir::Project program_bin() for more details.
Project_bin then uses the DIRPROJECT directory in combination with the DIRPROJECT_PATH to search for
prog, the name project_bin was invoked under.
prog is then executed with all of the arguments passed through project_bin.
If project_bin couldn't determine the project or find the binary using DIRPROJECT_PATH, it tries to execute $DIRPROJECT_PREFIX/bin/
prog__notfound which is generally a link to a version of
prog that is the default for when outside a project.
Instead of symlinking, you can make a script to call project_bin. This allows the name of the script to differ from the name of the linked program, and also allows it to work on systems without symlinks.
#!/usr/bin/perl -w exec 'project_bin', '--project_bin-run', 'name_of_script', @ARGV;
The debug flag is passed to the application, and also enables debugging messages from project_bin itself.
Strip this flag before passing to the application, and enable debugging.
Show this help message and exit.
- --project_bin-run program
Specify the program name to be executed. If not specified, presumes project_bin is symlinked, and $0 contains the name of the program to execute. See the example above.
Show program version and exit.
Instead of running the program, print the resolved path, similar to the "which" program. If you symlink project_bin to project_which, this will be the default action.
All other arguments are passed through to the application.
See Dir::Project for the list of relevant environment variables.
Copyright 2001-2017 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Wilson Snyder <email@example.com>