This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
rpg-config.sh
74 lines (66 loc) · 1.89 KB
/
rpg-config.sh
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
#!/bin/sh
# The `rpg-config` program dumps configuration variables to standard output
# in a format suitable for sourcing into a shell or opens an editor on rpg
# configuration files.
set -e
. rpg-sh-setup
ARGV="$@"
USAGE '${PROGNAME}
${PROGNAME} -u
${PROGNAME} -s
Show or edit rpg configuration.
Options
-u Edit the user configuration file
-s Edit the system configuration file
'
# With `-u` or `-s`, open an editor on the configuration file. If the file
# doesn't exist, create it with the program's current output but comment out
# all variable assignment lines.
editfile=
while getopts su opt
do
case $opt in
s) editfile="$RPGSYSCONF";;
u) editfile="$RPGUSERCONF";;
?) helpthem;exit 2;;
esac
done
shift $(( $OPTIND - 1 ))
test -n "$editfile" && {
test -f "$editfile" || {
{
echo "# $(date)"
echo "# This file was generated by "$PROGNAME" on" \
"behalf of $(id -un)"
echo "# Remove comment characters and edit values to" \
"change the default config"
echo
"$0"
} |sed 's/^\([^#]\)/# \1/' >"$editfile"
}
${EDITOR:-vi} "$editfile"
exit $?
}
# Dump config values with some comments so we can use it to generate
# config files in edit mode.
cat <<CONFIG
# rpg installs package contents in these locations:
RPGBIN='$RPGBIN'
RPGLIB='$RPGLIB'
RPGMAN='$RPGMAN'
# rpg keeps its package database, index, and gem cache in these locations:
RPGPATH='$RPGPATH'
RPGDB='$RPGDB'
RPGINDEX='$RPGINDEX'
RPGPACKS='$RPGPACKS'
RPGCACHE='$RPGCACHE'
# rpg sources these configuration files before executing commands:
RPGSYSCONF='$RPGSYSCONF'
RPGUSERCONF='$RPGUSERCONF'
# rpg uses these options to control various aspects of its behavior:
RPGTRACE=$RPGTRACE
RPGSHOWBUILD=$RPGSHOWBUILD
RPGSTALETIME='$RPGSTALETIME'
RPGSPECSURL='$RPGSPECSURL'
RPGGEMURL='$RPGGEMURL'
CONFIG