3 # This defines some general, useful functions.
5 if [ ! -z "$SHELL_DEBUG" ]; then
6 echo function definitions begin...
9 # makes a directory of the name specified and then tries to change the
10 # current directory to that directory.
12 if [ ! -d "$1" ]; then mkdir -p "$1"; fi
16 # locates a process given a search pattern to match in the process list.
18 PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")"
19 appropriate_pattern='s/^[-a-zA-Z_0-9][-a-zA-Z_0-9]* *\([0-9][0-9]*\).*$/\1/p'
20 # pattern to use for peeling off the process numbers.
22 # flags to pass to ps if any special ones are needed.
23 if [ "$OS" = "Windows_NT" ]; then
24 # on win32, there is some weirdness to support msys.
25 appropriate_pattern='s/^[ ]*\([0-9][0-9]*\).*$/\1/p'
28 /bin/ps $extra_flags wuax >$PID_DUMP
29 # remove the first line of the file, search for the pattern the
30 # user wants to find, and just pluck the process ids out of the
32 PIDS_SOUGHT=$(cat $PID_DUMP \
35 | sed -n -e "$appropriate_pattern")
36 if [ ! -z "$PIDS_SOUGHT" ]; then echo "$PIDS_SOUGHT"; fi
40 # finds all processes matching the pattern specified and shows their full
41 # process listing (whereas psfind just lists process ids).
44 if [ ! -z "$p" ]; then
46 echo "Processes containing \"$1\"..."
48 if [ -n "$IS_DARWIN" ]; then
51 # only print the header the first time.
52 if [ -z "$fuzil_sentinel" ]; then
55 ps $i -w -u | sed -e '1d'
60 # cases besides darwin OS (for macs).
62 if [ "$OS" = "Windows_NT" ]; then
63 # special case for windows.
67 ps $extra_flags | grep "^ *$curr"
70 # normal OSes can handle a nice simple query.
77 # an unfortunately similarly named function to the above 'ps' as in process
78 # methods, but this 'ps' stands for postscript. this takes a postscript file
79 # and converts it into pcl3 printer language and then ships it to the printer.
80 # this mostly makes sense for an environment where one's default printer is
81 # pcl. if the input postscript causes ghostscript to bomb out, there has been
82 # some good success running ps2ps on the input file and using the cleaned
83 # postscript file for printing.
86 gs -sDEVICE=pcl3 -sOutputFile=- -sPAPERSIZE=letter "$i" | lpr -l
91 sudo /etc/init.d/alsasound restart
94 # switches from a /X/path form to an X:/ form.
95 function msys_to_dos_path() {
96 # we always remove dos slashes in favor of forward slashes.
97 echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
100 # switches from an X:/ form to an /X/path form.
101 function dos_to_msys_path() {
102 # we always remove dos slashes in favor of forward slashes.
103 echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/'
106 if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi