File: staden_help

package info (click to toggle)
staden 2.0.0%2Bb11-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 21,556 kB
  • sloc: ansic: 240,603; tcl: 65,360; cpp: 12,854; makefile: 11,201; sh: 2,952; fortran: 2,033; perl: 63; awk: 46
file content (83 lines) | stat: -rwxr-xr-x 1,876 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh

# Finds the directory holding this program
find_dir() {
    arg0=$0

    # Protect against ls, sed and echo being exported shell functions.
    # Eg ls() { ls -F ${@+"$@"} }; export ls
    unset ls
    unset sed
    unset echo
    
    orig_dir=`pwd`
    must_loop=yes

    # The looping is to protect against symbolic links. We find the location
    # of arg0, but if arg0 is a link to elsewhere then we go around again
    # finding its location (noting that symlinks may be ether relative
    # or full pathnames).
    while [ -n "$must_loop" ]
    do
	cur_dir=`pwd`
    
	# Find directory that $arg0 resides in
	case $arg0 in
	    /*)
		# Full pathname, not much to do
		dir=`echo $arg0 | sed 's:/[^/]*$::'`
		;;
	    *)
		# Relative pathname, add current directory.
		dir=`echo $cur_dir/$arg0 | sed 's:/[^/]*$::'`
		;;
	esac
    
	if [ -h $arg0 ]
	then
	    # NOTE: This statement will not work when $arg0 is a filename
	    # containing "-> ".
	    lnto=`ls -l -- $arg0 | sed 's/.*-> //'`
	    lndir=`echo $lnto | sed 's:/[^/]*$::'`
	    case $lndir in
		/*)
		    # Absolute symlink
		    dirto=$lndir
		    ;;
		*)
		    # Relative symlink
		    dirto=`echo $arg0 | sed "s:/[^/]*\$:/$lndir:"`
		    ;;
	    esac

	    cd $dirto
	    arg0=`echo $lnto | sed 's:.*/::'`
	    must_loop=yes
	else
	    must_loop=
	fi
    done
    
    # To tidy up cases with ../ and ./ we cd to the directory, getcwd, and then
    # cd back again
    cd $dir
    dir=`pwd`
    cd $orig_dir
    
    echo $dir
}

STADENROOT=`find_dir $0`/..
export STADENROOT
STADEN_PREPEND=1 . $STADENROOT/staden.profile

#
# Define TCL/TK config - not defined in staden.profile as it may break
# some other applications the user wishes to use.
TCL_LIBRARY=$STADLIB/tcl
TK_LIBRARY=$STADLIB/tk
export TCL_LIBRARY TK_LIBRARY

# Run it!
#
exec ${BROWSER:-netscape} $STADENROOT/doc/staden_home.html