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
22c73bf3
Commit
22c73bf3
authored
Nov 26, 2014
by
Mislav Marohnić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform CLI argument validation as early as possible
parent
38ae3b56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
9 deletions
+6
-9
bin/rbenv-install
+2
-3
bin/rbenv-uninstall
+2
-3
bin/ruby-build
+2
-3
No files found.
bin/rbenv-install
View file @
22c73bf3
...
@@ -101,6 +101,8 @@ for option in "${OPTIONS[@]}"; do
...
@@ -101,6 +101,8 @@ for option in "${OPTIONS[@]}"; do
esac
esac
done
done
[
"
${#
ARGUMENTS
[@]
}
"
-le
1
]
||
usage 1
unset
VERSION_NAME
unset
VERSION_NAME
# The first argument contains the definition to install. If the
# The first argument contains the definition to install. If the
...
@@ -111,9 +113,6 @@ DEFINITION="${ARGUMENTS[0]}"
...
@@ -111,9 +113,6 @@ DEFINITION="${ARGUMENTS[0]}"
[
-n
"
$DEFINITION
"
]
||
DEFINITION
=
"
$(
rbenv-local 2>/dev/null
||
true
)
"
[
-n
"
$DEFINITION
"
]
||
DEFINITION
=
"
$(
rbenv-local 2>/dev/null
||
true
)
"
[
-n
"
$DEFINITION
"
]
||
usage 1
[
-n
"
$DEFINITION
"
]
||
usage 1
# Fail if number of arguments is greater than 1
[
"
${#
ARGUMENTS
[@]
}
"
-le
1
]
||
usage 1
# Define `before_install` and `after_install` functions that allow
# Define `before_install` and `after_install` functions that allow
# plugin hooks to register a string of code for execution before or
# plugin hooks to register a string of code for execution before or
# after the installation process.
# after the installation process.
...
...
bin/rbenv-uninstall
View file @
22c73bf3
...
@@ -33,6 +33,8 @@ if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
...
@@ -33,6 +33,8 @@ if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
shift
shift
fi
fi
[
"$#"
-eq
1
]
||
usage 1
DEFINITION
=
"
$1
"
DEFINITION
=
"
$1
"
case
"
$DEFINITION
"
in
case
"
$DEFINITION
"
in
""
|
-
*
)
""
|
-
*
)
...
@@ -44,9 +46,6 @@ case "$DEFINITION" in
...
@@ -44,9 +46,6 @@ case "$DEFINITION" in
;;
;;
esac
esac
# Fail if number of arguments is not equal 1
[
"$#"
-eq
1
]
||
usage 1
declare
-a
before_hooks after_hooks
declare
-a
before_hooks after_hooks
before_uninstall
()
{
before_uninstall
()
{
...
...
bin/ruby-build
View file @
22c73bf3
...
@@ -1022,6 +1022,8 @@ for option in "${OPTIONS[@]}"; do
...
@@ -1022,6 +1022,8 @@ for option in "${OPTIONS[@]}"; do
esac
esac
done
done
[
"
${#
ARGUMENTS
[@]
}
"
-eq
2
]
||
usage 1
DEFINITION_PATH
=
"
${
ARGUMENTS
[0]
}
"
DEFINITION_PATH
=
"
${
ARGUMENTS
[0]
}
"
if
[
-z
"
$DEFINITION_PATH
"
]
;
then
if
[
-z
"
$DEFINITION_PATH
"
]
;
then
usage
usage
...
@@ -1046,9 +1048,6 @@ elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
...
@@ -1046,9 +1048,6 @@ elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
PREFIX_PATH
=
"
${
PWD
}
/
${
PREFIX_PATH
}
"
PREFIX_PATH
=
"
${
PWD
}
/
${
PREFIX_PATH
}
"
fi
fi
# Fail if number of arguments is not equal to 2
[
"
${#
ARGUMENTS
[@]
}
"
-eq
2
]
||
usage
if
[
-z
"
$TMPDIR
"
]
;
then
if
[
-z
"
$TMPDIR
"
]
;
then
TMP
=
"/tmp"
TMP
=
"/tmp"
else
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