Shell Function and $PATH?

Mark Waddingham 36degrees at runrev.com
Sat Feb 4 06:21:12 EST 2006


Hi David,

> How does the $PATH and the shell() function work?
>
> That is the path as you get from:
>
>     put $PATH
>
> or
>
>     put shell("echo $PATH")
>
> does not correspond with what you get if you try the same from the  
> shell. This is presumably because these are set by various bash  
> scripts when a terminal starts and Rev does not do this?
>
> OK - but how does Rev do this exactly, which $PATH does if take,  
> and what happens when you set the PATH from inside Revolution -  
> this is important as shelling to programs does not work unless they  
> are on the PATH.

All variables that are prefixed by '$' are directly linked to their  
corresponding environment variables. So the values you see from  
within a Revolution application are what has been passed to the  
process by the OS.

In particular, the PATH variable will often differ from that which  
you see in a Terminal window because after the terminal launches it  
runs an interactive shell. Interactive shells (such as bash)  
typically have their own configuration that augments the PATH variable.

In terms of setting such variables then the only thing to remember is  
that environment variables are passed from parent process to child  
process but not the other way around. So the OS gives Revolution its  
own set of environment variables, which you can modify, and  
Revolution will then pass the same values (including modifications)  
on to any child processes it launches - in particular, ones run using  
shell.

So, all you need to do to change the paths that the shell command  
looks in is to set the $PATH variable to the required list before  
using the shell function.

Hope this helps,

Mark.

------------------------------------------------------------------
  Mark Waddingham ~ 36degrees at runrev.com ~ http://www.runrev.com
        Runtime Revolution ~ User-Centric Development Tools





More information about the use-livecode mailing list