Background: I already have a working alias my-tool
as follows:
alias my-tool='~/path/to/src/my-tool.py'
I want another alias that depends on that alias' path (so I don't write the path in two places):
alias other-tool=$'$(dirname $(dirname $(which my-tool | awk \'{ print($NF) }\')))/script/other-tool.sh'
which outputs the error
zsh: no such file or directory: ~/path/to/script/other-tool.sh
but it exists!
Strangely, if I replace the alias with
alias other-tool=$'$(dirname $(dirname ~/path/to/src/my-tool.py))/script/other-tool.sh'
it works, but again I want to avoid entering the ~/path/to/..
twice
Clearly there's unexpected behavior in either awk
, dirname
or which
, can anyone explain why the error?