Prefer $(pwd) to $PWD

I'm unsure if this is idiomatic POSIX shell scripting or not, but I generally
prefer function calls to variables. Thankfully things like Haskell don't
differentiate between the two. In other cold and hostile environments like shell
scripting, us programmers must take care to prefer functions to variables where
it makes sense.
This commit is contained in:
William Carroll 2019-03-23 16:38:19 +00:00
parent 7167764622
commit f5ace0b0a9

View file

@ -9,7 +9,7 @@ fv() {
tbz() { tbz() {
# Toggle between blaze-bin and your source. # Toggle between blaze-bin and your source.
# Useful if you like to cd into the dir where your source lives. # Useful if you like to cd into the dir where your source lives.
if [[ $PWD =~ '(.*)/blaze-bin(.*)' ]]; then if [[ "$(pwd)" =~ '(.*)/blaze-bin(.*)' ]]; then
cd "${match[1]}${match[2]}" cd "${match[1]}${match[2]}"
else else
cd "${PWD/\/google3//google3/blaze-bin}" cd "${PWD/\/google3//google3/blaze-bin}"