This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On Tue, 28 Mar 2000 15:25:36 -0700, Thunder Scientific Corporation wrote: > Why can't I change my PATH in a shell script? This is really about process relationships. When you run a shell script by just typing its name, under the hood your shell starts a new copy of the shell as a child process and that child executes the PATH change. When that process exits, you again see your original shell's prompt, which never saw its environment change. If, on the other hand, you run the script within your current shell process (using the "." operator or the "source" directive), then the current process executes the PATH change and it will stick. Note that this is not unique to Linux. The same thing happens in any multi-tasking system with parent-child process relationships, including Windows and OS/2. The reason that batch files in DOS-like environments change the current path is that DOS-like interpreters use the current shell, not a subshell, to execute the batch file. To get bash-like behavior in command.com or cmd.exe, you must "call" the batch file (ie. "call foo.bat") to execute the script in a subshell. Kenneth Porter Kensington Laboratories, Inc. mailto:kenneth_porter@kensingtonlabs.com http://www.kensingtonlabs.com ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |