File: liblook

package info (click to toggle)
ngspice 26-1
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie-kfreebsd
  • size: 49,436 kB
  • sloc: ansic: 463,259; sh: 11,107; xml: 6,938; makefile: 3,574; yacc: 1,509; perl: 1,214; tcl: 1,025; pascal: 702; lex: 319
file content (77 lines) | stat: -rwxr-xr-x 1,552 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
#!/bin/bash
#set -x -v 

# MW. Lib search / show program

# usage liblook libname [text_to_find] [l_before] [l_after]

LIBPATH=/usr/local/lib

function trapper()
    {
     echo User break! 
     echo Exiting . . .
     unset LIBPATH
     exit 1
    }
    
trap trapper SIGINT SIGQUIT 

function operror()
    {
     echo Incorrect parameters: $*, $#
     echo Usage: liblook libname [text_to_find] [l_before] [l_after]
     unset LIBPATH
     exit 2
    }

function showlib()
    {
     if test -f $LIBPATH/$1; then 
         less $LIBPATH/$1; exit 0; fi
	 
     if test -f [C./$1; then
         less ./$1; exit 0; fi
	     
     echo Searching $1 in ~/ . . . 	 
     less $(find ~/ -name $1) 
    }

function searchlib()
    {
    if test -f $LIBPATH/$1; then 
        echo File: $LIBNMAE; echo;
        grep -B"$3" -A"$4" --ignore-case -e "$2" $LIBPATH/$LIBNAME1; 
	echo; exit 0; fi
	 
     if test -f ./$1; then
        echo File: $1; echo; 
        grep -B"$3" -A"$4" --ignore-case -e "$2" ./$1; 
	echo; exit 0; fi
	     
#if *.lib or sth like this

     echo Searching $1 in ~/ . . .;echo;
     if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find ~/ -name $1)); then 
	echo; exit 0; fi

     echo Searching $1 in $LIBPATH;echo;
     if (grep -B"$3" -A"$4" --ignore-case -e "$2" $(find $LIBPATH -name $1)); then
         echo; exit 0; fi

    }
    

# Main body
if test $# -lt 1 -o $# -gt 4; then operror $*; fi

case $# in
1) showlib $*;;
2) searchlib $1 $2 2 2;;
3) searchlib $1 $2 $3 2;;
4) searchlib $1 $2 $3 $4;;
esac

unset LIBPATH
exit 0