mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Improve working directory error messages
- Check for directory existing and directory being readable separately and print appropriate messages for each - Make error messages more consistent
This commit is contained in:
parent
11e4b66dcf
commit
abc1d14807
@ -419,9 +419,13 @@ fi
|
|||||||
|
|
||||||
# Many Pathname operations use getwd when they shouldn't, and then throw
|
# Many Pathname operations use getwd when they shouldn't, and then throw
|
||||||
# odd exceptions. Reduce our support burden by showing a user-friendly error.
|
# odd exceptions. Reduce our support burden by showing a user-friendly error.
|
||||||
if [[ ! -d "$(pwd)" ]]
|
if ! [[ -d "$(pwd)" ]]
|
||||||
then
|
then
|
||||||
odie "The current working directory doesn't exist, cannot proceed."
|
odie "The current working directory must exist to run brew."
|
||||||
|
fi
|
||||||
|
if ! [[ -r "$(pwd)" ]]
|
||||||
|
then
|
||||||
|
odie "The current working directory must be readable to run brew."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
14
bin/brew
14
bin/brew
@ -12,10 +12,20 @@ fi
|
|||||||
|
|
||||||
set +o posix # as we are using bash now
|
set +o posix # as we are using bash now
|
||||||
|
|
||||||
# Fail fast with concise message when cwd does not exist
|
# Fail fast with concise messages when PWD has issues
|
||||||
|
if [[ -z "${PWD-}" ]]
|
||||||
|
then
|
||||||
|
echo "Error: \$PWD must be set to run brew." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if ! [[ -d "${PWD}" ]]
|
if ! [[ -d "${PWD}" ]]
|
||||||
then
|
then
|
||||||
echo "Error: The current working directory doesn't exist, cannot proceed." >&2
|
echo "Error: The current working directory must exist to run brew." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ -r "${PWD}" ]]
|
||||||
|
then
|
||||||
|
echo "Error: The current working directory must be readable to run brew." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user