Re: [BASH] shell functions don't work the same when opening sub-shells

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 11/28/05


Date: Mon, 28 Nov 2005 10:57:39 -0500

On 2005-11-28, Andrew Falanga wrote:
> Hi,
>
> I've got a rather odd occurrance when I open a sub-shell for changes to
> my environment.

   A subshell can only change its own environment, not that of the
   calling shell.

> In my .bashrc file I have some shell functions that
> I've written to help make life easier for me.
>
> One of these functions takes an option, -p, and then a pattern to search
> for. The pattern if found, is used in creating the sub-shell. I have
> it setup that the function always defaults to a specific type of pattern
> if the -p option is not provided.
>
> When starting a new shell all works as it should, but after exiting a
> sub-shell and using this function again, the function completely ignores
> the -p option and simply uses the default. Can anyone shed some light
> as to why for me?

   If it changes the function, it is not a subshell. Please post some
   code that exhibits the problem.

-- 
   Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
   Shell Scripting Recipes:     |  My code in this post, if any,
   A Problem-Solution Approach  |          is released under the
   2005, Apress                 |     GNU General Public Licence


Relevant Pages

  • Re: Set /M within SETLOCAL and after ENDLOCAL
    ... environment" is (either a sub-shell or a setlocal). ... I understand you and don't know how things stand in TCC/4NT, but finding and changing all possible copies of the master environment ... maybe my expectations didn't make sense in the first place or possibly ... so /m only has to find the one shell 0 master env. ...
    (comp.os.msdos.4dos)
  • Re: Korn shell question
    ... Patrick O'Callaghan wrote: ... a vi sub-shell? ... I have a script that has a problem when run from a vi subshell, ...
    (Fedora)
  • [BASH] shell functions dont work the same when opening sub-shells
    ... In my .bashrc file I have some shell functions that ... The pattern if found, is used in creating the sub-shell. ...
    (comp.unix.shell)
  • Re: Korn shell question
    ... a vi sub-shell? ... I have a script that has a problem when run from a vi subshell, ...
    (Fedora)
  • Re: Korn shell question
    ... a vi sub-shell? ... I have a script that has a problem when run from a vi subshell, ... That looks promising... ...
    (Fedora)