Consider this:$ cd /tmp$ echo echo YES >> prog/myprog$ chmod +x prog/myprog$ prog/myprogYES$ myprogmyprog: command not foundI can temporarily modify PATH to call myprog by name like this:$ PATH=$PATH:$(readlink -f prog) myprogYES... however I cannot chain commands with this approach:$ PATH=$PATH:$(readlink -f prog) myprog && myprogYESmyprog: command not found... apparently the modified PATH apparently didn't propagate to the second invocation.I'm aware I could do this:$ PATH=$PATH:$(readlink -f prog) bash -c myprog && myprogYESYES... but then I have to invoke an extra bash process - and even worse, I have to quote.Is there any way to append to PATH temporarily for chained commands in a one-liner, without having to invoke extra bash and quote? Tried backticks, they don't work:$ PATH=$PATH:$(readlink -f prog) `myprog && myprog`myprog: command not found
Bash one-liner to temporarily append path for chained commands without additional bash invocation?
bash;environment variables;path
How about using a subshell:$ (PATH=$PATH:$(readlink -f prog); myprog && myprog)YESYES