Quote:
Originally Posted by
onenessboy
With Don Cragun suggestion , put Path ,&& before the braces worked.
Thank you Don Cragun for help
I'm glad it is working for you, but my explanation in post #3 isn't entirely correct and I'm not sure that the "problem" would appear in all shells. When I originally wrote post #3, I was thinking of ommands in a compound list surrounded by parentheses; in that case the commands in the compound list are executed in a subshell environment and what you were doing would never have worked in that case.
But, commands in a compound list surrounded by braces are executed in the current process environment. But the order in which commands are executed in a pipeline isn't as clearly specified. If the
cd in the compound list is executed before the
sh at the end of the pipeline is invoked, the pipeline as written would work. If the
cd in the compound list is executed after the
sh at the end of the pipeline is invoked, the pipeline as written would fail with the diagnostic messages the submitter stated. Therefore, the code you showed us in post #1 has a race condition that may work sometimes and fail at other times. Your choice of shells might alter the likelihood of success or failure, but the race condition would always be there.
By putting the
cd before the pipeline in an AND list, we are forcing it to be completed successfully before the pipeline is started; therefore, we know that all elements of the pipeline have to be executed in the desired working directory