java - `hash` in script doesn't run properly with Process -
i have script following line:
hash git >/dev/null 2>&1 || { echo >&2 "git not installed"; exit 2; }
asserting git installed and, if not, exiting. want run java:
new processbuilder("script.sh", "0").start().waitfor()
the process exits because git isn't being found, though runs fine in bash (because installed).
edit: same command -v , runtime.getruntime().exec(..) (all combinations)
it seems $path variable not sourced in new context created processbuilder method.
as script executes fine , doesn't throw error, if shows unexpected result, seems hash recognized, call doesn't know git executable
try rewritting script using full path function java able find executables, i.e. /usr/bin/git
Comments
Post a Comment