496 Commits

Author SHA1 Message Date
Mike McQuaid
d0ff64666a bin/brew: improve /usr/local/bin/brew handling.
If `/usr/local` is the prefix but not the repository (so bottles can be
used) then running `/usr/local/bin/brew` works great but
`$HOMEBREW_REPOSITORY/bin/brew` assumes the prefix is
`$HOMEBREW_REPOSITORY`. This is a pain when doing work on the Homebrew
repository and having e.g. `bin` in your `$PATH`. Improve this
behaviour so `bin/brew` knows how to handle this situation.
2016-08-24 10:56:28 +01:00
Mike McQuaid
2f9bf5f047 bin/brew: split up brew file symlink check.
This will enable this code to be reused in a future commit and makes it
more obvious what’s being done.
2016-08-24 10:56:28 +01:00
Mike McQuaid
db4ce3d6b7 bin/brew: refactor HOMEBREW_PREFIX="/" logic.
The previous approach of trying to do it on one line was confusing.
2016-08-24 10:56:28 +01:00
Mike McQuaid
a07ab8bb92 brew.{rb,sh}: move to Library/Homebrew. (#506) 2016-07-15 19:33:30 +01:00
Martin Afanasjew
3c5f007bfa bin/brew: fix corner cases in prefix computation
If `bin/brew` happens to be symlinked to `/brew`, `/bin/brew`, or some
similar location or (worse yet) Homebrew is installed to `/`, then
computation of the prefix and/or repository path could break down and
result in an invalid or empty path.

Closes Homebrew/homebrew-core#2430.
2016-06-29 16:20:47 +02:00
Martin Afanasjew
359b67c6c8 bin/brew: rename 'chdir' to 'quiet_cd'
This is inspired by `quiet_system` with basically the same implication
(suppress output), making the name a lot less confusing and avoiding a
clash with the `chdir` function defined in `Library/brew.sh`.
2016-06-29 13:38:50 +02:00
Mike McQuaid
61e9d43ead bin/brew: unset POSIX mode.
We're using /bin/bash and not /bin/sh for a reason so don't allow users
to override this (seen in Homebrew/homebrew#49514).

Closes Homebrew/homebrew#49515.
2016-02-25 11:33:04 +00:00
David Caldwell
bff90a7233 brew: Make HOMEBREW_REPOSITORY different from prefix only when 'brew' is a symlink
Closes Homebrew/homebrew#49261.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-18 09:32:46 +00:00
David Caldwell
94034a6915 brew: Make HOMEBREW_LIBRARY based off of HOMEBREW_REPOSITORY
This makes the logic match the Ruby code from before it was moved here
(see 390e327f55126f7ee9519bc6c03a0c0aa14f7168)
2016-02-18 09:32:46 +00:00
David Caldwell
9e32aede10 brew: Don't re-canonicalize
HOMEBREW_BREW_FILE and BREW_FILE_DIRECTORY are already canonicalized.
2016-02-18 09:32:46 +00:00
Mike McQuaid
691e4aec11 bin/brew: move logic to Library.
`bin/brew` is getting a bit bloated and it's annoying to open all of
`HOMEBREW_PREFIX` in your editor of choice and have it search through
the `Cellar`. Let's instead keep the bare minimum in `bin/brew` and
move the rest to `Library`.

Closes Homebrew/homebrew#49185.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-16 09:31:58 +00:00
Mike McQuaid
578e68b2c1 brew: remove ln from sudo command check list. 2016-02-15 11:39:41 +00:00
Mike McQuaid
f6cbf7bab0 Move internal command aliases from Ruby to Bash.
This means that internal command aliases can be used for Bash commands
(such as the new, Bash-based `brew update`).

Fixes Homebrew/homebrew#49182.

Closes Homebrew/homebrew#49184.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-15 11:35:25 +00:00
Mike McQuaid
775c4eedd7 Promote update-bash to the default updater.
Also, rename the existing updater to `update-ruby` to allow using as
a fallback. It will eventually be removed.

Closes Homebrew/homebrew#49109.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-15 08:54:03 +00:00
Tim D. Smith
984a70e6e2 use BSD stat
Closes Homebrew/homebrew#48803.
2016-02-04 00:15:07 -08:00
Martin Afanasjew
77975168e0 bin/brew: add support for developer bash commands
This also means `bin/brew` is again consistent with `brew command` and
`brew commands`.
2016-01-26 16:26:08 +01:00
Martin Afanasjew
da47ca9213 bin/brew: put commands into 'homebrew-' namespace
This should help to avoid collisions with external commands and other
shell functions in the future and is closer to what we do in Ruby, where
commands are namespaced by being methods of the `Homebrew` module.
2016-01-26 16:26:08 +01:00
Martin Afanasjew
8907778d4a bin/brew: don't pass command name to bash commands
We have asserted before that the 1st argument is the command name. No
need to pass it to the bash command, which will make the argument
handling for the command itself a bit easier.
2016-01-26 16:26:07 +01:00
Martin Afanasjew
93dad81d95 bin/bash: don't require executable command files
Commands implemented in shell (bash) are supposed to be sourced from
`bin/bash` instead of being executed directly. Consequently, don't
expect the implementation files to be executable.
2016-01-26 16:26:07 +01:00
Xu Cheng
2d65caaee9 bin/brew: use not operator inside [[ 2016-01-20 16:04:02 +08:00
Xu Cheng
318ce388d7 bin/brew: use full path for xcode-select
Closes Homebrew/homebrew#48197.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-20 13:55:07 +08:00
Xu Cheng
b324d61f35 bin/brew: remove unpin from sudo check list
We only need to check sudo for commands which create files.
2016-01-20 13:55:06 +08:00
Xu Cheng
e3011dfe91 bin/brew: include alias in sudo check 2016-01-20 13:55:06 +08:00
Xu Cheng
e12e1a5d5d bin/brew: introduce odie function 2016-01-20 13:55:06 +08:00
Xu Cheng
3fdf1a623b bin/brew: always use [[ for consistency 2016-01-20 13:55:06 +08:00
Xu Cheng
29c50d2567 bin/brew: remove unnecessary check
HOMEBREW_BASH_COMMAND variable will always exist. So we only need to
check whether the corresponding file exist or not.
2016-01-20 13:55:06 +08:00
Xu Cheng
6b5b8757bf bin/brew: fix incorrect argument manipulation
Shifting `-v` argument is all we need to do. We shouldn't enumerate
arguments.
2016-01-20 13:55:06 +08:00
Mike McQuaid
b118539c8c bin/brew: use a function to avoid issues.
Otherwise when `bin/brew` is updated in-place Bash will carry on from
the offset and this can cause issues.

Thanks to `@UniqMartin` for pointing this out.
2016-01-18 09:37:46 +00:00
Mike McQuaid
6f91b429ce Move some brew.rb logic to bin/brew. 2016-01-17 19:48:02 +00:00
Mike McQuaid
b01ce41164 bin/brew: allow writing Homebrew commands in Bash. 2016-01-17 19:48:02 +00:00
Mike McQuaid
effca7d9c6 bin/brew: set more HOMEBREW_* env from Bash. 2016-01-17 19:39:41 +00:00
Martin Afanasjew
8d3f33de90 bin/brew: enforce UTF-8 locale
Everyone should be using a UTF-8 locale nowadays. Not using one causes
issues like `brew doctor` failing while checking symbolic links that
point at file names with non-ASCII characters, since OS X always uses
Unicode for the file system.

Rely on `locale charmap` to detect the currently selected encoding and
if that's not UTF-8, override the user's choice (if any) by setting
`LC_ALL` to `en_US.UTF-8`, the assumption being that every system has a
usable `en_US.UTF-8` locale installed.

Fixes Homebrew/homebrew#44744.
Closes Homebrew/homebrew#47247.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2015-12-23 06:54:11 +01:00
Martin Afanasjew
f1a7e51d2a bin/brew: avoid unnecessary 'readlink' invocation
For typical installations where `brew` is not a symbolic link, this
reduces the number of processes that need to be spawned.

Closes Homebrew/homebrew#46269.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2015-12-01 21:36:05 +01:00
Martin Afanasjew
5b828d4265 bin/brew: avoid unnecessary 'tr' invocation
This reduces the number of processes that need to be forked. If
libtool's `config.guess` is to be trusted, there was never another
spelling/capitalization other that `Darwin`.
2015-12-01 21:36:05 +01:00
Martin Afanasjew
8f175cb03c bin/brew: separate variable assignment and export
This very slightly reduces duplication and the risk of inconsistency by
exporting in one branch, but not the other. By putting all the `export`
statements right before the `exec` it is more obvious what is passed on.
2015-12-01 21:36:05 +01:00
Martin Afanasjew
73a7889de5 bin/brew: quote in assignments for consistency
While `var=$(<command>)` is perfectly valid and won't create any issues,
it is often surprising for less shell-savvy users. Quoting these cases
like in all other instances makes the code more uniform, helps to avoid
future mistakes, and has no downsides.
2015-12-01 21:36:05 +01:00
Martin Afanasjew
fb4a2ea387 bin/brew: be consistent about code style 2015-12-01 21:36:05 +01:00
Xu Cheng
aeb8aad1e0 brew: ensure full path for HOMEBREW_RUBY_PATH 2015-11-20 19:52:19 +08:00
Mike McQuaid
f5104a7946 brew.rb: export HOMEBREW_RUBY_PATH. 2015-11-20 10:24:27 +00:00
Mike McQuaid
c6621faf18 travis: test 10.9 using Ruby 1.8.
Closes Homebrew/homebrew#45816.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-11-18 17:06:28 +00:00
Jack Nagel
18d1d1511b Suppress output from cd
Closes Homebrew/homebrew#34246.
2014-11-25 22:27:03 -05:00
Adam Vandenberg
6908781264 convert tabs to spaces in bin/brew 2014-05-17 10:08:02 -07:00
Jack Nagel
253140c92d Quote argument to readlink 2014-05-02 21:55:44 -05:00
Jack Nagel
bb750e1439 Use parameter expansion to avoid forking 2014-05-02 21:55:44 -05:00
Misty De Meo
5a7a5c3eae Unset GEM_HOME and GEM_PATH before running brew.rb
This was reported in Tigerbrew, but is a worthwhile fix everywhere.

Fixes mistydemeo/tigerbrew#177.
2014-02-21 20:54:23 -08:00
Mike McQuaid
f9f05d1173 brew: use a shell wrapper script for brew
This reverts commit dfd4dd12a41e1697ee9d5feac12cc1ea7c3a590e.

Fixes the problems from Homebrew/homebrew#17683 and Homebrew/homebrew#17685.
2013-02-21 21:42:18 +00:00
Mike McQuaid
191e9ed88a brew: move to Library/brew.rb
This reverts commit ac156b36d00ead5f225389f0a1d8069d0c1cce4a.
2013-02-21 21:42:18 +00:00
Mike McQuaid
4a281cd5cf Rename Library/Contributions/cmds -> cmd. 2013-02-18 10:42:44 +00:00
Mike McQuaid
e9d58c4100 Rework brew command dispatch order.
Make it no longer possible to override e.g. `brew install` with a
script if there is already a built-in Homebrew command named
`brew install`.

References Homebrew/homebrew#17673
2013-02-18 10:42:43 +00:00
Mike McQuaid
1e47298456 Revert "brew: move to Library/brew.rb"
This reverts commit 67d06b84d00a17cf43770eedf34e37e50e209741.

Closes Homebrew/homebrew#17683.
Closes Homebrew/homebrew#17685.
2013-02-08 08:55:53 -08:00