07-01-2009
Quote:
Originally Posted by
Al262
Not really much help. The link tried to provide workarounds rather than answering the question. There are times when inside the script, it doesn't know what directory it is in. Seems like a $0 equivalent should be available for a sourced file.
You'd think , huh?
But it ($0 in the sourced shell) is not what what it's in the 'called' (not sourced) script - as the 'sourced' script runs in the same process space (there's no newly forked process) as the 'sourcing' script. Therefore, the '$0' in the sourced script is the '$0' of the sourcing script.
I'm not sure if I'm explaining this correctly - you can take a look at this
thread or browse this
comp.unix.shell user group for similar threads.
Last edited by vgersh99; 07-01-2009 at 06:14 PM..
10 More Discussions You Might Find Interesting
1. OS X (Apple)
Hi:
So my current Python (2.52) rig is not working as intended. "echo $PATH" in bash gives me 'X'" that's not what i want, so i need to change my path. To do that, there appeared to be four choices (all in my ~/ directory--note: I'm root, it's my Mac, but i'm in a user account):
.profile... (2 Replies)
Discussion started by: Alex_Land
2 Replies
2. Shell Programming and Scripting
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... (2 Replies)
Discussion started by: angad.makkar
2 Replies
3. Shell Programming and Scripting
Hi Everyone,
I have 1.txt
here
a
b
c' funny"yes";
d
e
The finally output is:
here
a
b
c
d
e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies
4. Shell Programming and Scripting
This is a very simple problem, I am wondering why I can find no answer anywhere...
I have a script that can be run either sourced or not. This script has some place where it needs to quit execution (e.g., when an error is found)
If I "exit", the sourced call would exit the parent shell, but... (7 Replies)
Discussion started by: MadMage
7 Replies
5. Shell Programming and Scripting
Hello,
I am trying to install Env::Sourced and i get the following error.
sh: source: not found
sh: include.sh: not found
Unable to determine your shells source program, typically 'source' or '.'
How can i overcome this?
Best Regards,
Christos (3 Replies)
Discussion started by: chriss_58
3 Replies
6. Shell Programming and Scripting
Hi,
I am logging to a linux server through a user "user1" in /home directory.
There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory.
When the script is added to crontab, on... (1 Reply)
Discussion started by: archana.n
1 Replies
7. Shell Programming and Scripting
I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt.
Please help me how to do this in shell script. (1 Reply)
Discussion started by: vel4ever
1 Replies
8. Shell Programming and Scripting
Hi
This is my third past and very impressed with previous post replies
Hoping the same for below query
How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies
9. Shell Programming and Scripting
I've been asked if I can write a "quick" little ksh script that will do the following:
java java_class_file /dir/input_file.xml /dir/output_file.xml
I'm a complete newbie with ksh so any help would be appreciated.
This is on AIX and java is found in
/usr/java5/jre/bin/java (4 Replies)
Discussion started by: newbie_ksh
4 Replies
10. Shell Programming and Scripting
Hello there wonderful people,
I am running on Solaris 10 and with the following ksh version:
strings /bin/ksh | grep Version | tail -2
@(#)Version M-11/16/88i
Suppose I want to copy files that end in _v2 from underneath /dir1/dir2/save directory to /dir1/dir2. Basically, what I’m... (12 Replies)
Discussion started by: ejianu
12 Replies
LEARN ABOUT FREEBSD
atf-sh
ATF-SH(1) BSD General Commands Manual ATF-SH(1)
NAME
atf-sh [-s shell] -- interpreter for shell-based test programs
SYNOPSIS
atf-sh script
DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library.
atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter-
preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not
use any non-standard extensions.
The following options are available:
-s shell Specifies the shell to use instead of the value provided by ATF_SHELL.
ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes.
ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes.
ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a
specific interpreter.
EXAMPLES
Scripts using atf-sh(3) should start with:
#! /usr/bin/env atf-sh
Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode
the path to atf-sh in the script and then use the -s option afterwards as a single parameter:
#! /path/to/bin/atf-sh -s/bin/bash
ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts.
SEE ALSO
atf-sh(3)
BSD
September 27, 2014 BSD