On Tue May 04 20:30:45 2010, KMX wrote:
Show quoted text> Hi,
>
> please find eclosed proof-of-concept for permanently updating PATH via
> perl
> script.
>
> The questions are:
>
> 1/ is this approach acceptable?
>
> 2/ what other ENV variables apart from PATH we want fo update? (TERM?)
>
> 3/ where to put this code? (maybe we can add some special option
> --update-env
> to relocation.pl)
1/ It's a start. (It's the way I'd do it - and did for the local::lib
script.) Note 4 - 8 below, as well.
2/ Yes, TERM. Anything we tell them to set in the README needs to be set
by this script.
3/ This would be copied to c:\strawberry\perl\bin, and we'd copy
runperl.bat to update_environment.bat, (with the part before the .bat
being what we called it before the .pl) as well, to make it a batch file
(or at least, callable by one. What runperl.bat does is documented in
perlwin32.pod.)
4/ ...\perl\site\bin needs to be added to the path entries, by the way.
5/ It really needs a --directory option as well [5.12 DOES relocate,
after all] which means it needs some pod, and the --man, --help/-?,
--usage, and --version standard options to go with it. Again, see what I
did with relocation.pl as to how I implement those. You may wish to do
it a little differently.
I also prefer to set a $VERSION in scripts, even though it's not
'required', so other people know when the script has been updated, and
to use in my own 'print' statements.
I think the --directory option would take the place of an --update-env
option to the relocation script - or maybe the relocation script can
have that option and call this script to do it. (the .msi relocates the
path all by itself already, so yes, it needs to be an option.)
I know all the options may seem complicated for a small script, but the
man/usage/help/version options are the 4 'meta-options' recommended by
/PBP/ for scripts, and that are used in non-interactive GNUish programs.
Once I include any options at all, I include those 4. (I consider
interactive scripts to have different rules apply to them.)
An option to remove the directory entries (--remove ?) is nice, but not
absolutely REQUIRED, I wouldn't think.
Note that I assume Getopt::Long and Pod::Usage, which are both core.
6/ One major problem - it won't affect the right registry locations when
you run a 32-bit perl on a 64-bit system, because 32-bit apps are
redirected by default. The way to turn that off is shown in
http://svn.ali.as/cpan/trunk/App-local-lib-Win32Helper/script/llw32helper.pl
, where the access ends up being KEY_READ() | KEY_WRITE()| 256 #
KEY_WOW64_64KEY, so that the redirection is turned off.
7/ Print something on success, unless a --quiet option is given. I would
worry about what a script did if it ran successfully, but printed
NOTHING out, unless I asked it not to print anything. The --quiet would
be how I asked it.
8/ The script should check to see if each PATH entry is already there
before it adds an entry.
If you get this done for 5.12.0.1 (the 5.12.0 rebuild), it'd be
fantastic, but I know that allows you very little time (as in only 2
days or so) to do it, so don't feel like you have to rush to get it in
on time, OK?
Keep up the good work.