![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Exit out of the Script Command inside a Script | jmungai | UNIX for Dummies Questions & Answers | 6 | 02-20-2009 05:26 PM |
| which file is sourced by bash on login (Mac OS X 10.5.3)? | Alex_Land | OS X (Apple) | 2 | 07-11-2008 11:52 PM |
| Script exit | Krrishv | Shell Programming and Scripting | 3 | 06-23-2008 06:27 PM |
| how to exit a script? | filthymonk | Shell Programming and Scripting | 15 | 06-29-2007 07:27 AM |
| exit from script | gefa | Shell Programming and Scripting | 1 | 01-23-2007 08:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello,
I have written a script (say chld.sh). its structure is as follows: ------------------------ #!/bin/sh usage() { echo "chld.sh <param1> <param2>" exit 0 } chk_param_1() { case $param1 in c) export PATH=$PATH:/home_a/bin/execs;; d) export PATH=$PATH:/home_b/bin/execs;; *) usage;; esac } chk_param_2() { echo "Chk Param 2" } clear param1=$1 param2=$2 chk_param_1 chk_param_2 ------------------------ Now I source this script, as I want the new PATH variable in my current environment. Hence I give a alias in my environment as alias set_path='. ~/chld.sh' Now when I call the script as: set_path c ........it works fine set_path d..........also works fine. But if I give "set_path e"......it displays the usage and EXITS/LOGOUTS from my parent shell i.e. the main shell. I know the reason is coz due to sourcing, it runs the chld.sh in the current shell and not another subshell. But please tell me how to do this. Whenever I display "usage".....i dont want to continue ahead in the script. Simply come out of this script. Please HELP!! Last edited by angad.makkar; 03-04-2009 at 05:49 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|