Thank you all for your help. I think I get it now.
Just to clear up some confusion, when I'm working in BBEDit, I have
two options to run the script:
Run -- which seems to run the script in bash.
Run In Terminal -- which runs in my chosen shell
and I also run scripts from cron, using the Cronnix utility
Here's a script:
for(keys(%ENV)){
print "$_ == $ENV{$_}\n";
}
Output of this script with BBEDit's "Run":
-----
USER == myusername
PATH == /usr/bin:/bin:/usr/sbin:/sbin:/Users/myusername
__CF_USER_TEXT_ENCODING == 0x1F5:0:0
HOME == /Users/myusername
SECURITYSESSIONID == 23bac080
SHELL == /bin/bash
-----
Output of this script with BBEDit's "Run In Terminal":
-----
LOGNAME == myusername
HOST == jh.my.work
GROUP == myusername
SHLVL == 2
PATH == /bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin
HTTP_PROXY == http://my.work.proxy:8080/
USER == myusername
HOSTTYPE == powermac
VENDOR == apple
HOME == /Users/myusername
TERM_PROGRAM_VERSION == 100.1.8
TERM_PROGRAM == Apple_Terminal
SHELL == /bin/bash
SECURITYSESSIONID == 23bac080
__CF_USER_TEXT_ENCODING == 0x1F5:0:0
_ == /usr/bin/perl
TERM == xterm-color
MACHTYPE == powerpc
PWD == /private/tmp/501/Cleanup At Startup
OSTYPE == darwin
-----
output when run as cron script:
-----
SHLVL == 1
SHELL == /bin/sh
HOME == /Users/myusername
PATH == /usr/bin:/bin
_ == /usr/bin/perl
LOGNAME == myusername
PWD == /Users/myusername
USER == myusername
-----
But Cronnix also has a "run now" option to test ones scripts, and
when I use that, I get the same output as when it's run in the
Terminal.
Can you see now why I was a little confused? Not to mention my Linux
colleague's advice that the environment variable for my favourite
shell would be some kind of global variable.
Off I go to investigate the $HOME/.MacOSX/environment.plist idea...