Closed marcelpaulo closed 6 years ago
Great stuff, thanks !
I've just discovered what it seems like a bash quirk: HOSTNAME is not exported in the environment:
paulo:~$ declare -p HOSTNAME
declare -- HOSTNAME="monk"
but running:
#!/bin/bash
echo $HOSTNAME
it's output, when it shouldn't, since it's not exported in the environment. So, need to export it in .profile, so that torf config can pick it up.
That's as it should be. Environment variables are only exposed to this
process. The export
command exists so child processes can inherit your
environment.
$ foo=bar
$ zsh -c 'echo $foo'
$ export foo=bar
$ zsh -c 'echo $foo'
bar
Yes and no, as I have just learned. HOSTNAME
is a shell variable, so even though it's not exported in the environment, it's visible in shell scripts, but won't be visible from other programs:
paulo:~$ bash -c 'echo $HOSTNAME'
monk
paulo:~$ perl -e 'print $ENV{HOSTNAME}'
paulo:~$
Whereas USER
is not a shell variable, but some process (don't know which, I'd imagine the login manager, lightdm
in the case of Xubuntu) sets and exports it:
paulo:~$ bash -c 'echo $USER'
paulo
paulo:~$ perl -e 'print $ENV{USER}, "\n"'
paulo
It does seem to be a bash idiosyncrasy. Interesting.
$ zsh -c 'echo $HOSTNAME'
$ bash -c 'echo $HOSTNAME'
boing
It might be useful to be able to expand environment values in the config file. For instance, I set the comment for sef-created torrents in a bash script:
It would be nice to be able to set it in torf's config file, like: