rcmdnk/homebrew-file

`file` doesn't seem to expand environment variable `HOSTNAME`

zcutlip opened this issue · 5 comments

I added file ./${HOSTNAME}.Brewfile to my main Brewfile, but it expands to ./.Brewfile

See below:

$ grep -n HOSTNAME $HOMEBREW_BREWFILE
89:file ${HOSTNAME}.Brewfile
$ brew file get_files
/Users/zach/.dotfiles/brewfile/Brewfile
/Users/zach/.dotfiles/brewfile/.Brewfile

But if I put my hostname specifically, then it works:

$ grep -n osarian $HOMEBREW_BREWFILE
89:file osarian.Brewfile
$ brew file get_files
/Users/zach/.dotfiles/brewfile/Brewfile
/Users/zach/.dotfiles/brewfile/osarian.Brewfile

Homebrew & brew-file versions:

$ brew-file --version
Homebrew 2.5.0-115-ge93a6aa
Homebrew/homebrew-core (git revision d0354; last commit 2020-09-11)
Homebrew/homebrew-cask (git revision de2496; last commit 2020-09-11)
brew-file v8.0.2 15/Aug/202

Evidently, I was setting HOSTNAME but not exporting it, so python wasn't able to see it. It seems to work fine if I export the shell variable.

I was mistaken.

If I use brew-file directly HOSTNAME gets expanded. If I use brew file, it doesn't:

$ echo $HOSTNAME
osarian
$ brew-file get_files
/Users/zach/.dotfiles/brewfile/Brewfile
/Users/zach/.dotfiles/brewfile/./osarian.Brewfile
$ brew file get_files
/Users/zach/.dotfiles/brewfile/Brewfile
/Users/zach/.dotfiles/brewfile/./.Brewfile

Thanks for the report.

I found that the env expansion was broken at v8.0.2,
but was working at v8.0.1.

With v8.0.1, it worked even with brew file command.
And it doesn't work with brew-file directly with v8.0.2, either.

Actually there was a change of shell command management and I think it introduced a bug.

Not sure what happened in your case (maybe tried to use old brew-file file directly...?),
but anyways there is a bug in the latest version.

Checking...

could you please try new version of brew-file (v8.0.3).

$ brew update
$ brew upgrade
$ brew file get_files

It should work with both brew file get_files and brew-file get_files.

Yes, it works now. Thank you!