Skip to content

Commit 996b20b

Browse files
committed
Merge remote-tracking branch 'sstephenson/master'
Conflicts: README.md libexec/luaenv---version libexec/luaenv-commands libexec/luaenv-hooks libexec/luaenv-init libexec/luaenv-rehash libexec/luaenv-shims libexec/rbenv-completions libexec/rbenv-exec libexec/rbenv-local libexec/rbenv-prefix libexec/rbenv-sh-rehash libexec/rbenv-sh-shell libexec/rbenv-which
2 parents 62c75ef + 14bc162 commit 996b20b

45 files changed

Lines changed: 1981 additions & 54 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/version
44
/versions
55
/sources
6+
/cache

‎.travis.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install: git clone https://github.com/sstephenson/bats.git
2+
script: bats/bin/bats --tap test
3+
# skips unnecessary Ruby-specific setup
4+
language: c

‎README.md‎

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ names.
1919

2020
**One thing well.** luaenv is concerned solely with switching Lua
2121
versions. It's simple and predictable. A rich plugin ecosystem lets
22+
<<<<<<< HEAD
2223
you tailor it to suit your needs. Compile your own Lua versions, or
2324
use the [lua-build](https://github.com/cehoffman/lua-build)
25+
=======
26+
you tailor it to suit your needs. Compile your own Lua versions, or
27+
use the [lua-build][]
28+
>>>>>>> sstephenson/master
2429
plugin to automate the process. Specify per-application environment
2530
variables with [luaenv-vars](https://github.com/cehoffman/luaenv-vars).
2631
See more [plugins on the
@@ -37,8 +42,14 @@ names.
3742
* [Basic GitHub Checkout](#basic-github-checkout)
3843
* [Upgrading](#upgrading)
3944
* [Homebrew on Mac OS X](#homebrew-on-mac-os-x)
45+
<<<<<<< HEAD
4046
* [Neckbeard Configuration](#neckbeard-configuration)
4147
* [Uninstalling Lua Versions](#uninstalling-lua-versions)
48+
=======
49+
* [How luaenv hooks into your shell](#how-luaenv-hooks-into-your-shell)
50+
* [Installing Lua Versions](#installing-lua-versions)
51+
* [Uninstalling Lua Versions](#uninstalling-lua-versions)
52+
>>>>>>> sstephenson/master
4253
* [Command Reference](#command-reference)
4354
* [luaenv local](#luaenv-local)
4455
* [luaenv global](#luaenv-global)
@@ -103,13 +114,24 @@ reading it from the following sources, in this order:
103114
the [`luaenv shell`](#luaenv-shell) command to set this environment
104115
variable in your current shell session.
105116

117+
<<<<<<< HEAD
106118
2. The application-specific `.lua-version` file in the current
107119
directory, if present. You can modify the current directory's
108120
`.lua-version` file with the [`luaenv local`](#luaenv-local)
109121
command.
110122

111123
3. The first `.lua-version` file found by searching each parent
112124
directory until reaching the root of your filesystem, if any.
125+
=======
126+
2. The first `.lua-version` file found by searching the directory of the
127+
script you are executing and each of its parent directories until reaching
128+
the root of your filesystem.
129+
130+
3. The first `.lua-version` file found by searching the current working
131+
directory and each of its parent directories until reaching the root of your
132+
filesystem. You can modify the `.lua-version` file in the current working
133+
directory with the [`luaenv local`](#luaenv-local) command.
134+
>>>>>>> sstephenson/master
113135
114136
4. The global `~/.luaenv/version` file. You can modify this file using
115137
the [`luaenv global`](#luaenv-global) command. If the global version
@@ -144,7 +166,11 @@ easy to fork and contribute any changes back upstream.
144166
1. Check out luaenv into `~/.luaenv`.
145167

146168
~~~ sh
169+
<<<<<<< HEAD
147170
$ git clone git://github.com/cehoffman/luaenv.git ~/.luaenv
171+
=======
172+
$ git clone https://github.com/sstephenson/luaenv.git ~/.luaenv
173+
>>>>>>> sstephenson/master
148174
~~~
149175

150176
2. Add `~/.luaenv/bin` to your `$PATH` for access to the `luaenv`
@@ -154,7 +180,7 @@ easy to fork and contribute any changes back upstream.
154180
$ echo 'export PATH="$HOME/.luaenv/bin:$PATH"' >> ~/.bash_profile
155181
~~~
156182

157-
**Ubuntu note**: Modify your `~/.profile` instead of `~/.bash_profile`.
183+
**Ubuntu Desktop note**: Modify your `~/.bashrc` instead of `~/.bash_profile`.
158184

159185
**Zsh note**: Modify your `~/.zshrc` file instead of `~/.bash_profile`.
160186

@@ -164,15 +190,22 @@ easy to fork and contribute any changes back upstream.
164190
$ echo 'eval "$(luaenv init -)"' >> ~/.bash_profile
165191
~~~
166192

167-
_Same as in previous step, use `~/.profile` on Ubuntu, `~/.zshrc` for Zsh._
193+
_Same as in previous step, use `~/.bashrc` on Ubuntu, or `~/.zshrc` for Zsh._
168194

195+
<<<<<<< HEAD
169196
4. Restart your shell as a login shell so the path changes take effect.
170197
You can now begin using luaenv.
198+
=======
199+
4. Restart your shell so that PATH changes take effect. (Opening a new
200+
terminal tab will usually do it.) Now check if luaenv was set up:
201+
>>>>>>> sstephenson/master
171202

172203
~~~ sh
173-
$ exec $SHELL -l
204+
$ type luaenv
205+
#=> "luaenv is a function"
174206
~~~
175207

208+
<<<<<<< HEAD
176209
5. Install [lua-build](https://github.com/cehoffman/lua-build),
177210
which provides an `luaenv install` command that simplifies the
178211
process of installing new Lua versions.
@@ -191,6 +224,11 @@ easy to fork and contribute any changes back upstream.
191224
~~~
192225
$ luaenv rehash
193226
~~~
227+
=======
228+
5. _(Optional)_ Install [lua-build][], which provides the
229+
`luaenv install` command that simplifies the process of
230+
[installing new Lua versions](#installing-lua-versions).
231+
>>>>>>> sstephenson/master
194232

195233
#### Upgrading
196234

@@ -210,8 +248,17 @@ $ git fetch
210248
$ git checkout v0.3.0
211249
~~~
212250
251+
If you've [installed via Homebrew](#homebrew-on-mac-os-x), then upgrade
252+
via its `brew` command:
253+
254+
~~~ sh
255+
$ brew update
256+
$ brew upgrade luaenv lua-build
257+
~~~
258+
213259
### Homebrew on Mac OS X
214260

261+
<<<<<<< HEAD
215262
You can also install luaenv using the
216263
[Homebrew](http://mxcl.github.com/homebrew/) package manager on Mac OS
217264
X.
@@ -225,10 +272,22 @@ $ brew install lua-build
225272
To later update these installs, use `upgrade` instead of `install`.
226273

227274
Afterwards you'll still need to add `eval "$(luaenv init -)"` to your
275+
=======
276+
As an alternative to installation via GitHub checkout, you can install
277+
luaenv and [lua-build][] using the [Homebrew](http://brew.sh) package
278+
manager on Mac OS X:
279+
280+
~~~
281+
$ brew update
282+
$ brew install luaenv lua-build
283+
~~~
284+
285+
Afterwards you'll still need to add `eval "$(luaenv init -)"` to your
286+
>>>>>>> sstephenson/master
228287
profile as stated in the caveats. You'll only ever have to do this
229288
once.
230289
231-
### Neckbeard Configuration
290+
### How luaenv hooks into your shell
232291
233292
Skip this section unless you must know what every line in your shell
234293
profile is doing.
@@ -260,7 +319,32 @@ opposed to this idea. Here's what `luaenv init` actually does:
260319
Run `luaenv init -` for yourself to see exactly what happens under the
261320
hood.
262321

322+
<<<<<<< HEAD
263323
### Uninstalling Lua Versions
324+
=======
325+
### Installing Lua Versions
326+
327+
The `luaenv install` command doesn't ship with luaenv out of the box, but
328+
is provided by the [lua-build][] project. If you installed it either
329+
as part of GitHub checkout process outlined above or via Homebrew, you
330+
should be able to:
331+
332+
~~~ sh
333+
# list all available versions:
334+
$ luaenv install -l
335+
336+
# install a Lua version:
337+
$ luaenv install 2.0.0-p247
338+
~~~
339+
340+
Alternatively to the `install` command, you can download and compile
341+
Lua manually as a subdirectory of `~/.luaenv/versions/`. An entry in
342+
that directory can also be a symlink to a Lua version installed
343+
elsewhere on the filesystem. luaenv doesn't care; it will simply treat
344+
any entry in the `versions/` directory as a separate Lua version.
345+
346+
### Uninstalling Lua Versions
347+
>>>>>>> sstephenson/master
264348

265349
As time goes on, Lua versions you install will accumulate in your
266350
`~/.luaenv/versions` directory.
@@ -270,9 +354,14 @@ version you want to remove. You can find the directory of a particular
270354
Lua version with the `luaenv prefix` command, e.g. `luaenv prefix
271355
luajit-2.0.1`.
272356

357+
<<<<<<< HEAD
273358
The [lua-build](https://github.com/cehoffman/lua-build) plugin
274359
provides an `luaenv uninstall` command to automate the removal
275360
process.
361+
=======
362+
The [lua-build][] plugin provides an `luaenv uninstall` command to
363+
automate the removal process.
364+
>>>>>>> sstephenson/master
276365

277366
## Command Reference
278367

@@ -382,19 +471,24 @@ The luaenv source code is [hosted on
382471
GitHub](https://github.com/cehoffman/luaenv). It's clean, modular,
383472
and easy to understand, even if you're not a shell hacker.
384473

474+
Tests are executed using [Bats](https://github.com/sstephenson/bats):
475+
476+
$ bats test
477+
$ bats test/<file>.bats
478+
385479
Please feel free to submit pull requests and file bugs on the [issue
386480
tracker](https://github.com/cehoffman/luaenv/issues).
387481

388482
It is also likely any bugs you find exist in the original source from which
389483
luaenv has been adapted. Check out
390-
[rbenv](https://github.com/sstephenson/rbenv) to see if they have a fix that
484+
[luaenv](https://github.com/sstephenson/luaenv) to see if they have a fix that
391485
should be ported over or need the bug squashed too.
392486

393487
### Version History
394488

395489
**0.4.0** (March 2, 2013)
396490

397-
* Converted rbenv and ruby references to luaenv and lua respectively
491+
* Converted luaenv and lua references to luaenv and lua respectively
398492
* Initial public release.
399493

400494
### License
@@ -421,3 +515,6 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
421515
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
422516
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
423517
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
518+
519+
520+
[lua-build]: https://github.com/sstephenson/lua-build#readme

‎completions/rbenv.fish‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function __fish_luaenv_needs_command
2+
set cmd (commandline -opc)
3+
if [ (count $cmd) -eq 1 -a $cmd[1] = 'luaenv' ]
4+
return 0
5+
end
6+
return 1
7+
end
8+
9+
function __fish_luaenv_using_command
10+
set cmd (commandline -opc)
11+
if [ (count $cmd) -gt 1 ]
12+
if [ $argv[1] = $cmd[2] ]
13+
return 0
14+
end
15+
end
16+
return 1
17+
end
18+
19+
complete -f -c luaenv -n '__fish_luaenv_needs_command' -a '(luaenv commands)'
20+
for cmd in (luaenv commands)
21+
complete -f -c luaenv -n "__fish_luaenv_using_command $cmd" -a "(luaenv completions $cmd)"
22+
end

‎libexec/luaenv‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ if [ -n "$LUAENV_DEBUG" ]; then
1212
set -x
1313
fi
1414

15+
READLINK=$(type -p greadlink readlink | head -1)
16+
if [ -z "$READLINK" ]; then
17+
echo "luaenv: cannot find readlink - are you missing GNU coreutils?" >&2
18+
exit 1
19+
fi
20+
1521
resolve_link() {
16-
$(type -p greadlink readlink | head -1) "$1"
22+
$READLINK "$1"
1723
}
1824

1925
abs_dirname() {

‎libexec/luaenv---version‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ set -e
1414

1515
version="0.4.0"
1616

17-
cd "$LUAENV_ROOT"
18-
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
19-
git_revision="${git_revision#v}"
17+
if cd "$LUAENV_ROOT" 2>/dev/null; then
18+
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
19+
git_revision="${git_revision#v}"
20+
fi
2021

2122
echo "luaenv ${git_revision:-$version}"

‎libexec/luaenv-commands‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ elif [ "$1" = "--no-sh" ]; then
2020
shift
2121
fi
2222

23+
IFS=: paths=($PATH)
24+
2325
shopt -s nullglob
2426

25-
{ for path in ${PATH//:/$'\n'}; do
27+
{ for path in "${paths[@]}"; do
2628
for command in "${path}/luaenv-"*; do
2729
command="${command##*luaenv-}"
2830
if [ -n "$sh" ]; then

‎libexec/luaenv-completions‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if [ -z "$COMMAND" ]; then
1111
fi
1212

1313
COMMAND_PATH="$(command -v "luaenv-$COMMAND" || command -v "luaenv-sh-$COMMAND")"
14-
if grep -i "^# provide luaenv completions" "$COMMAND_PATH" >/dev/null; then
14+
if grep -iE "^([#%]|--|//) provide luaenv completions" "$COMMAND_PATH" >/dev/null; then
1515
shift
1616
exec "$COMMAND_PATH" --complete "$@"
1717
fi

‎libexec/luaenv-exec‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
# Runs an executable by first preparing PATH so that the selected Lua
88
# version's `bin' directory is at the front.
99
#
10-
# For example, if the currently selected Lua version is 5.2.1
11-
# luaenv exec lake install
10+
# For example, if the currently selected Lua version is 5.2.1:
11+
# luaenv exec bundle install
1212
#
1313
# is equivalent to:
14-
# PATH="$LUAENV_ROOT/versions/5.2.1/bin:$PATH" lake install
14+
# PATH="$LUAENV_ROOT/versions/5.2.1/bin:$PATH" bundle install
1515

1616
set -e
1717
[ -n "$LUAENV_DEBUG" ] && set -x
@@ -21,18 +21,22 @@ if [ "$1" = "--complete" ]; then
2121
exec luaenv shims --short
2222
fi
2323

24-
export LUAENV_VERSION="$(luaenv-version-name)"
24+
LUAENV_VERSION="$(luaenv-version-name)"
2525
LUAENV_COMMAND="$1"
2626

2727
if [ -z "$LUAENV_COMMAND" ]; then
2828
luaenv-help --usage exec >&2
2929
exit 1
3030
fi
3131

32+
export LUAENV_VERSION
3233
LUAENV_COMMAND_PATH="$(luaenv-which "$LUAENV_COMMAND")"
3334
LUAENV_BIN_PATH="${LUAENV_COMMAND_PATH%/*}"
3435

35-
for script in $(luaenv-hooks exec); do
36+
OLDIFS="$IFS"
37+
IFS=$'\n' scripts=(`luaenv-hooks exec`)
38+
IFS="$OLDIFS"
39+
for script in "${scripts[@]}"; do
3640
source "$script"
3741
done
3842

‎libexec/luaenv-hooks‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ if [ -z "$LUAENV_COMMAND" ]; then
1919
exit 1
2020
fi
2121

22+
READLINK=$(type -p greadlink readlink | head -1)
23+
if [ -z "$READLINK" ]; then
24+
echo "luaenv: cannot find readlink - are you missing GNU coreutils?" >&2
25+
exit 1
26+
fi
27+
2228
resolve_link() {
23-
$(type -p greadlink readlink | head -1) $1
29+
$READLINK "$1"
2430
}
2531

2632
realpath() {
2733
local cwd="$(pwd)"
28-
local base="$(basename $1)"
2934
local path="$1"
3035

3136
while [ -n "$path" ]; do
@@ -34,13 +39,15 @@ realpath() {
3439
path="$(resolve_link "$name" || true)"
3540
done
3641

37-
echo "$(pwd)/$base"
42+
echo "$(pwd)/$name"
3843
cd "$cwd"
3944
}
4045

46+
IFS=: hook_paths=($LUAENV_HOOK_PATH)
47+
4148
shopt -s nullglob
42-
for path in ${LUAENV_HOOK_PATH//:/$'\n'}; do
43-
for script in $path/"$LUAENV_COMMAND"/*.bash; do
49+
for path in "${hook_paths[@]}"; do
50+
for script in "$path/$LUAENV_COMMAND"/*.bash; do
4451
echo $(realpath $script)
4552
done
4653
done

0 commit comments

Comments
 (0)