Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
8446df21
Commit
8446df21
authored
Aug 15, 2012
by
Sam Stephenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse options so they can be combined (e.g. `-kv`) and occur anywhere on the command line
parent
aee47820
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
35 deletions
+66
-35
bin/ruby-build
+66
-35
No files found.
bin/ruby-build
View file @
8446df21
...
...
@@ -5,6 +5,39 @@ RUBY_BUILD_VERSION="20120524"
set
-E
exec
3<&2
# preserve original stderr at fd 3
lib
()
{
parse_options
()
{
OPTIONS
=()
ARGUMENTS
=()
local
arg option index
for
arg
in
"
$@
"
;
do
if
[
"
${
arg
:0:1
}
"
=
"-"
]
;
then
if
[
"
${
arg
:1:1
}
"
=
"-"
]
;
then
OPTIONS[
${#
OPTIONS
[*]
}
]=
"
${
arg
:2
}
"
else
index
=
1
while
option
=
"
${
arg
:
$index
:1
}
"
;
do
[
-n
"
$option
"
]
||
break
OPTIONS[
${#
OPTIONS
[*]
}
]=
"
$option
"
index
=
$((
$index
+
1
))
done
fi
else
ARGUMENTS[
${#
ARGUMENTS
[*]
}
]=
"
$arg
"
fi
done
}
if
[
"
$1
"
==
"--
$FUNCNAME
"
]
;
then
declare
-f
"
$FUNCNAME
"
exit
fi
}
lib
"
$1
"
resolve_link
()
{
$(
type
-p
greadlink readlink | head
-1
)
"
$1
"
}
...
...
@@ -332,7 +365,7 @@ version() {
usage
()
{
{
version
echo
"usage: ruby-build [-v|--verbose] definition prefix"
echo
"usage: ruby-build [-
k|--keep] [-
v|--verbose] definition prefix"
echo
" ruby-build --definitions"
}
>
&2
...
...
@@ -351,34 +384,41 @@ list_definitions() {
unset
VERBOSE
unset
KEEP_BUILD_PATH
RUBY_BUILD_ROOT
=
"
$(
abs_dirname
"
$0
"
)
/.."
case
"
$1
"
in
"-h"
|
"--help"
)
usage without_exiting
{
echo
echo
" -v/--verbose Verbose mode: print compilation status to stdout"
echo
" --definitions List all built-in definitions"
echo
}
>
&2
exit
0
;;
"--definitions"
)
list_definitions
exit
0
;;
"--version"
)
version
exit
0
;;
"-v"
|
"--verbose"
)
VERBOSE
=
true
shift
;;
esac
parse_options
"
$@
"
for
option
in
"
${
OPTIONS
[@]
}
"
;
do
case
"
$option
"
in
"h"
|
"help"
)
usage without_exiting
{
echo
echo
" -k/--keep Do not remove source tree after installation"
echo
" -v/--verbose Verbose mode: print compilation status to stdout"
echo
" --definitions List all built-in definitions"
echo
}
>
&2
exit
0
;;
"definitions"
)
list_definitions
exit
0
;;
"k"
|
"keep"
)
KEEP_BUILD_PATH
=
true
;;
"v"
|
"verbose"
)
VERBOSE
=
true
;;
"version"
)
version
exit
0
;;
esac
done
DEFINITION_PATH
=
"
$
1
"
DEFINITION_PATH
=
"
$
{
ARGUMENTS
[0]
}
"
if
[
-z
"
$DEFINITION_PATH
"
]
;
then
usage
elif
[
!
-e
"
$DEFINITION_PATH
"
]
;
then
...
...
@@ -391,20 +431,11 @@ elif [ ! -e "$DEFINITION_PATH" ]; then
fi
fi
PREFIX_PATH
=
"
$
2
"
PREFIX_PATH
=
"
$
{
ARGUMENTS
[1]
}
"
if
[
-z
"
$PREFIX_PATH
"
]
;
then
usage
fi
OPTIONS
=
"
$3
"
for
option
in
$OPTIONS
;
do
case
"
$option
"
in
"-k"
|
"--keep"
)
KEEP_BUILD_PATH
=
"y"
;;
esac
done
if
[
-z
"
$TMPDIR
"
]
;
then
TMP
=
"/tmp"
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment