If I invoke an HTTP trigger with the statement "console.log(process.env)", I get this in the log:
{ WORKER_PORT: '8091',
GCLOUD_PROJECT: 'the-id-of-my-project',
FUNCTION_NAME: 'api',
SUPERVISOR_HOSTNAME: '192.168.1.1',
PATH: '/usr/local/bin:/usr/bin:/bin',
PWD: '/user_code',
FUNCTION_TRIGGER_TYPE: 'HTTP_TRIGGER',
NODE_ENV: 'production',
SHLVL: '1',
CODE_LOCATION: '/user_code',
FUNCTION_MEMORY_MB: '256',
GCP_PROJECT: 'the-id-of-my-project',
PORT: '8080',
SUPERVISOR_INTERNAL_PORT: '8081',
ENTRY_POINT: 'api',
OLDPWD: '/var/tmp/worker/',
_: '/usr/bin/env',
HOME: '/tmp' }
I don't know which one is the most appropriate, but I'd go with process.env.GCLOUD_PROJECT or process.env.GCP_PROJECT to see where it's running. Neither of those are probably in your shell environment. Alternately, you can put something special in your shell env and check for it in process.env.
Doug