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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -