Open nkabir opened 4 years ago
Also stumbled across this today. The function is available and callable from the terminal, but when trying to call it with plumbum I get a CommandNotFound
error.
A good example is declare
(bash builtin):
which declare
/usr/bin/which: no declare in
declare X=Y
echo $X
>> Y
from plumbum import local
declare = local["declare"]
→ plumbum.commands.processes.CommandNotFound: ('declare', ....
The limiting code is in https://github.com/tomerfiliba/plumbum/blob/master/plumbum/machines/base.py#L51
For bash functions to work, one would probably need to introduce a new Path
specialization.
A workaround is to use a dispatch shell script (e.g. dispatch.sh
):
#!/usr/bin/env bash
readonly TARGET_FUNCTION="${1:?missing target function}"
shift
eval ${TARGET_FUNCTION:?} $@
Then
>>> dispatch = local["./dispatch.sh"]
>>> dispatch["mybash_func"].run_fg()
Does plumbum support accessing bash functions in addition to bash commands?