Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

docco cleanup, remove undocumented stuff from doc target

  • Loading branch information...
commit 0e5e9357c4bd14b82539d211641cf326e7eb3ee2 1 parent f5f7140
@rtomayko authored
Showing with 64 additions and 52 deletions.
  1. +4 −8 Makefile
  2. +27 −27 rpg-sh-setup.sh
  3. +24 −16 rpg-version-test.sh
  4. +9 −1 rpg.sh
View
12 Makefile
@@ -49,13 +49,9 @@ PROGRAMPROGRAMS = \
PROGRAMS = $(USERPROGRAMS) $(PROGRAMPROGRAMS)
DOCHTML = \
- rpg-sh-setup.html rpg.html rpg-config.html rpg-fetch.html \
- rpg-install.html rpg-list.html rpg-version-test.html rpg-uninstall.html \
- rpg-build.html rpg-env.html rpg-sync.html rpg-resolve.html \
- rpg-upgrade.html rpg-steal.html rpg-fsck.html rpg-status.html \
- rpg-outdated.html rpg-package-register.html rpg-package-install.html \
- rpg-solve.html rpg-package-spec.html rpg-parse-index.html \
- rpg-shit-list.html rpg-prepare.html
+ rpg-sh-setup.html rpg.html rpg-fetch.html rpg-version-test.html \
+ rpg-sync.html rpg-upgrade.html rpg-status.html rpg-outdated.html \
+ rpg-package-install.html rpg-package-spec.html rpg-parse-index.html
.SUFFIXES: .sh .rb .html
@@ -83,7 +79,7 @@ DOCHTML = \
.rb.html:
printf "%13s %-30s" "[ROCCO]" "$@"
- rocco $<
+ rocco $< >/dev/null
printf " OK\n"
rpg-sh-setup: config.sh munge.rb
View
54 rpg-sh-setup.sh
@@ -40,35 +40,35 @@ __rpg_sh_setup_included=true
# determine the best locations for various RPG paths.
if test -z "$__RPGENV__"
then
-PATH="${libexecdir}:$PATH"
-RUBY="$(command -v ruby 2>/dev/null || echo "${RUBY:-ruby}")"
-__RPGENV__="$RUBY"
-
-rubyenv () {
-$RUBY <<RUBY
-require 'rbconfig'
-conf = RbConfig::CONFIG
-puts "
-RUBYPREFIX='#{conf['prefix']}'
-RUBYDLEXT='#{conf['DLEXT']}'
-RUBYSITEDIR='#{conf['sitelibdir']}'
-RUBYVENDORDIR='#{conf['vendorlibdir']}'
-RUBYMANDIR='#{conf['mandir']}'
-RUBYBINDIR='#{conf['bindir']}'
-RUBYSTATEDIR='#{conf['localstatedir']}'
-RUBYVERSION='#{conf['ruby_version']}'
-RUBYLIBDIR='#{File.dirname(conf['rubylibdir'])}'
-"
-RUBY
-}
-eval "$(rubyenv)"
-
-export __RPGENV__ RUBY
-export RUBYPREFIX RUBYDLEXT RUBYSITEDIR RUBYVENDORDIR RUBYMANDIR RUBYBINDIR
-export RUBYSTATEDIR RUBYLIBDIR RUBYVERSION
+ PATH="${libexecdir}:$PATH"
+ RUBY="$(command -v ruby 2>/dev/null || echo "${RUBY:-ruby}")"
+ __RPGENV__="$RUBY"
+
+ eval "$(
+ $RUBY <<__RUBY__
+ require 'rbconfig'
+ conf = RbConfig::CONFIG
+ puts "
+ RUBYPREFIX='#{conf['prefix']}'
+ RUBYDLEXT='#{conf['DLEXT']}'
+ RUBYSITEDIR='#{conf['sitelibdir']}'
+ RUBYVENDORDIR='#{conf['vendorlibdir']}'
+ RUBYMANDIR='#{conf['mandir']}'
+ RUBYBINDIR='#{conf['bindir']}'
+ RUBYSTATEDIR='#{conf['localstatedir']}'
+ RUBYVERSION='#{conf['ruby_version']}'
+ RUBYLIBDIR='#{File.dirname(conf['rubylibdir'])}'
+ "
+__RUBY__
+ )"
+
+ export __RPGENV__ RUBY
+ export RUBYPREFIX RUBYDLEXT RUBYSITEDIR RUBYVENDORDIR RUBYMANDIR RUBYBINDIR
+ export RUBYSTATEDIR RUBYLIBDIR RUBYVERSION
# With `configure --development`, set all paths to be inside a work dir.
- if $develmode; then
+ if $develmode
+ then
: ${RPGPATH:="./work"}
: ${RPGLIB:="$RPGPATH/lib"}
: ${RPGMAN:="$RPGPATH/man"}
View
40 rpg-version-test.sh
@@ -1,4 +1,8 @@
#!/bin/sh
+# The `rpg-version-test` program tests a version string against one or more
+# matching expressions. When all expressions match the version, the program
+# exits successfully. When any expression fails to match, the program exits
+# non-zero.
set -e
. rpg-sh-setup
@@ -23,26 +27,26 @@ test "$1" = '-q' && {
shift
}
-# Like expr(1) but ignore stdout.
+# Like `expr(1)` but ignore stdout.
compare () { expr "$1" "$2" "$3" >/dev/null; }
-# Usage: rpg_version_eval <ver1> <op> <ver2>
-# Compare <ver1> with <ver2> using operator <op>.
-# Return zero if <ver1> matches <ver2>, non-zero otherwise.
+#/ Usage: rpg_version_eval <ver1> <op> <ver2>
+#/ Compare <ver1> with <ver2> using operator <op>.
+#/ Return zero if <ver1> matches <ver2>, non-zero otherwise.
version_compare () {
v1="$1."; op="$2"; v2="$3."
while test -n "$v1" -o -n "$v2"
do
- # take left-most item from v1 and v2
+ # Take left-most item from `v1` and `v2`.
left=${v1%%.*}; right=${v2%%.*}
- # remove left-most item from v1 and v2
+ # Remove left-most item from `v1` and `v2`.
v1=${v1#*.}; v2=${v2#*.}
- # use 0 if we've eaten through either side
+ # Use `0` if we've eaten through either side.
left=${left:-0}; right=${right:-0}
- # check if v1 satisfies operator w/ v2.
+ # Check if `v1` satisfies operator w/ `v2`.
if compare $left $op $right
then compare $left = $right || return 0
else compare $left = $right || return 1
@@ -74,28 +78,32 @@ allmatch=true
for ver in $vers
do satisfied=true
for exp in $exps
- do # extract operator part or default to '='
+ do
+ # Extract the operator part or default to '='.
operator=${exp%%[!><=~]*}
operator=${operator:-=}
- # extract version part
+ # Extract the version part.
ver2=${exp##*[><=~]}
case "$operator" in
- =) # fast path equality
- test "$ver" = "$ver2" || {
+
+ # Fast path equality.
+ =) test "$ver" = "$ver2" || {
satisfied=false
break
};;
- ~\>) # handle squiggly guy
- lt="${ver2%.*}.999999" # gross
+
+ # Handle the squiggly guy.
+ ~\>) lt="${ver2%.*}.999999" # gross
version_compare "$ver" "<" "$lt" &&
version_compare "$ver" ">=" "$ver2" || {
satisfied=false
break
};;
- *) # normal comparison
- version_compare "$ver" "$operator" "$ver2" || {
+
+ # Normal comparison.
+ *) version_compare "$ver" "$operator" "$ver2" || {
satisfied=false
break
};;
View
10 rpg.sh
@@ -1,5 +1,10 @@
#!/bin/sh
+# The main rpg user executable. `rpg` sets environment variables for global
+# options and execs child commands.
set -e
+
+# This usage message only lists porcelainish commands. The rpg(1) manpage
+# documents all commands in detail.
PROGNAME="$(basename $0)"
usage="Usage: ${PROGNAME} [-vx] [-c <path>] <command> [<args>...]
Manage gem packages, quickly.
@@ -21,7 +26,10 @@ Options
-x Enable shell tracing to stderr (extremely verbose)
See \`${PROGNAME} help <command>' for more information on a specific command."
+
[ "$*" ] || set -- "--help"
+
+# Look for --help before the child command.
for a in "$@"
do
case "$a" in
@@ -31,7 +39,7 @@ do
esac
done
-# Argument parsing.
+# Global options.
while getopts qvxc: opt
do
case $opt in
Please sign in to comment.
Something went wrong with that request. Please try again.