File: mkvariable

package info (click to toggle)
ultrapossum 1.0rc5-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,452 kB
  • ctags: 111
  • sloc: sh: 7,252; makefile: 346; perl: 239; python: 37; ruby: 26
file content (51 lines) | stat: -rwxr-xr-x 1,437 bytes parent folder | download
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
#!/bin/sh
#
# Copyright (C) 2003 VA Linux Systems Japan, K.K.
#
# LICENSE NOTICE
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#

# $Id: mkvariable,v 1.1 2004/10/19 08:32:52 taru Exp $

set -e

if test "x$2" = "x"; then
  echo "Usage: $0 <variable|pysical|logical> <files..>" 1>&2
  exit 1
fi

type=$1
shift

case "x$type" in
  xvariable)
    egrep "[A-Z_][A-Z_]*=" "$@" | cut -d= -f1 | cut -d: -f2- | grep -v IFS | tr -d '# ' | sort | uniq
    ;;
  xpysical)
    egrep "[A-Z_][A-Z_]*=" "$@" | grep ultrapossum_getconf | cut -d= -f1 | cut -d: -f2- | grep -v IFS | tr -d '# ' | sort | uniq
    ;;
  xlogical)
    tmp=`basename $0`$$
    trap "/bin/rm -f $tmp" 0
    $0 pysical "$@" > $tmp
    echo "$($0 variable "$@")" | diff - $tmp | egrep "^< " | cut -d' ' -f2
    ;;
  xsecret)
    egrep "[A-Z_][A-Z_]*=" "$@" | grep "XXXXXX" | cut -d= -f1 | cut -d: -f2- | grep -v IFS | tr -d '# ' | sort | uniq
    ;;
  x*)
    echo "Unknown variable type: $type" 1>&2
    exit 1
    ;;
esac