The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
current running process in shell moco Shell Programming and Scripting 1 04-12-2007 12:15 AM
How do i execute script in the current shell Naresh Kumar Shell Programming and Scripting 5 06-12-2006 12:55 PM
Command to findout the current shell? Aceform UNIX for Dummies Questions & Answers 5 09-07-2005 01:00 PM
current shell mkan Shell Programming and Scripting 3 02-21-2005 07:20 AM
How do you know what your current shell is? shad0w75 UNIX for Dummies Questions & Answers 4 06-13-2003 03:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-10-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
How to run a new shell with copy of current shell declarations?

How to run another shell and have all current shell dectaration copied to that new shell?

I would like to have available all current declarations in a new shell. That are functions, aliases, variables.

I need to test some functions that use the 'exit', but running it in current shell on 'exit' will close the shell, which I do not like.
  #2 (permalink)  
Old 03-10-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922

Code:
# export thing=hello
# echo $thing
hello
# bash
# echo $thing
hello
#

I don't see the problem...
  #3 (permalink)  
Old 03-10-2008
rm-r rm-r is offline
Registered User
  
 

Join Date: May 2005
Location: Montreal
Posts: 17
I had a similar issue recently and found that I could use the "return" command and it wouldn't kill my session.
ex:
return 10

This is under ksh.
  #4 (permalink)  
Old 03-11-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
The problem is:
The only EXPORTED variables are copyed.
I need many functions and declared not exported variables.
I am running functions which change and define variables.
Some of them need to be run in separate process, in '()': like >(funct_boo)
I do not want redeclare all functions, aliases and variables in the new process


Code:
src> alias boo="echo boo-boo"
src> foo()
> {
> echo "foo from func";
> }
src> foo
foo from func
src> boo
boo-boo
src> var=variable
src> echo $var
variable
src> hm
dca0701> bash
executing file .bashrc - starting the bash shell--
----> Start of the .myset file  <---
----> End   of the .myset file  <---
src> foo
bash: foo: command not found
src> boo
bash: boo: command not found
src> echo $var

src>

The return() I have used, but it is not cover my situation.
There is a stack of functions, if somewhere something has not-0-return I need to stop execution of all stacked function, but do not kill the shell.
Return works only for one function.

Is any other possibility exist?
  #5 (permalink)  
Old 03-26-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
Still have no idea how to do it.
Is it possible to run another shell and have all FUNCTIONS and ALIASES from current shell be available in new one?
  #6 (permalink)  
Old 03-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
bash has an -a option to automatically export all variables and functions, dunno if this is a bashism but I would guess it's POSIX. Try "set -a" at the top of the script.

In bash, it seems you can't export aliases. All the more reason to use functions instead of aliases.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0