LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   howto spawn shell when env variable doesn't point to /bin/sh (https://www.linuxquestions.org/questions/linux-software-2/howto-spawn-shell-when-env-variable-doesnt-point-to-bin-sh-509485/)

DoDo1975 12-11-2006 03:46 PM

howto spawn shell when env variable doesn't point to /bin/sh
 
Hi,

I have my environment (ENV) variable set to a shell script that used dialog and ncurses to display a graphical menu. One of the options of the menu is to spawn a shell.

When this option is chosen, the shell immediately spawns but then runs my menu again.

Is there a way I can spawn just a shell, and not run the environment variable everytime or some other way of achieving this?

chrism01 12-11-2006 05:10 PM

How are you spawning?
What happens if you explictly spawn /bin/bash ?

unSpawn 12-11-2006 05:30 PM

Add a check in your shellscript to check current SHLVL and don't spawn the menu if SHLVL=$[${SHLVL}+1] ?

budword 12-11-2006 05:37 PM

Edited my post, as I didn't understand your question the first time around. :)

Sorry bout that.

DoDo1975 12-11-2006 05:58 PM

Hi,

If I explicitly call /bin/sh or /bin/ash (I am not using bash), then I can see a shell spawned for a split second, but then my menu returns.

DoDo1975 12-11-2006 06:09 PM

Unspawn,

You had a great idea. I just realised though that ash doesn't support this environment variable. I am attempting to see if I can remedy that or maybe somehow create my own variable. I guess I could just set a variable in the profile before the env setting and check if its set before setting the env to the menu. I will try that.

If anyone else has any ideas, please let me know!

Joel

unSpawn 12-11-2006 07:34 PM

I guess I could just set a variable in the profile before the env setting and check if its set before setting the env to the menu.
Clean solution. Exporting once should prolly do. Inheritance and all that.


All times are GMT -5. The time now is 09:35 PM.