3 # This defines some general, useful functions.
5 if [ ! -z "$SHELL_DEBUG" ]; then
6 echo function definitions begin...
9 # applies a chown and a chgrp to the files specified, but the user name must
10 # have a private group of the same name for this to work.
13 # $2 $3 $4 $5 $6 $7 $8 $9
15 # $2 $3 $4 $5 $6 $7 $8 $9
18 # makes a directory of the name specified and then tries to change the
19 # current directory to that directory.
21 if [ ! -d "$1" ]; then mkdir -p "$1"; fi
25 # locates a process given a search pattern to match in the process list.
27 PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")"
28 appropriate_pattern='s/^[-a-zA-Z_0-9][-a-zA-Z_0-9]* *\([0-9][0-9]*\).*$/\1/p'
29 # pattern to use for peeling off the process numbers.
31 # flags to pass to ps if any special ones are needed.
32 if [ "$OS" = "Windows_NT" ]; then
33 # on win32, there is some weirdness to support msys.
34 appropriate_pattern='s/^[ ]*\([0-9][0-9]*\).*$/\1/p'
37 /bin/ps $extra_flags wuax >$PID_DUMP
38 # remove the first line of the file, search for the pattern the
39 # user wants to find, and just pluck the process ids out of the
41 PIDS_SOUGHT=$(cat $PID_DUMP \
44 | sed -n -e "$appropriate_pattern")
45 if [ ! -z "$PIDS_SOUGHT" ]; then echo "$PIDS_SOUGHT"; fi
49 # finds all processes matching the pattern specified and shows their full
50 # process listing (whereas psfind just lists process ids).
53 if [ ! -z "$p" ]; then
55 echo "Processes containing \"$1\"..."
57 if [ -n "$IS_DARWIN" ]; then
60 # only print the header the first time.
61 if [ -z "$fuzil_sentinel" ]; then
64 ps $i -w -u | sed -e '1d'
69 # cases besides darwin OS (for macs).
71 if [ "$OS" = "Windows_NT" ]; then
72 # special case for windows.
76 ps $extra_flags | grep "^ *$curr"
79 # normal OSes can handle a nice simple query.
86 # an unfortunately similarly named function to the above 'ps' as in process
87 # methods, but this 'ps' stands for postscript. this takes a postscript file
88 # and converts it into pcl3 printer language and then ships it to the printer.
89 # this mostly makes sense for an environment where one's default printer is
90 # pcl. if the input postscript causes ghostscript to bomb out, there has been
91 # some good success running ps2ps on the input file and using the cleaned
92 # postscript file for printing.
95 gs -sDEVICE=pcl3 -sOutputFile=- -sPAPERSIZE=letter "$i" | lpr -l
100 sudo /etc/init.d/alsasound restart
103 # switches from a /X/path form to an X:/ form.
104 function msys_to_dos_path() {
105 # we always remove dos slashes in favor of forward slashes.
106 echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/'
109 # switches from an X:/ form to an /X/path form.
110 function dos_to_msys_path() {
111 # we always remove dos slashes in favor of forward slashes.
112 echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/'
115 if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi