Merge pull request #16059 from MikeMcQuaid/whoami

Improve use of `whoami`
This commit is contained in:
Mike McQuaid 2023-10-01 16:04:00 +01:00 committed by GitHub
commit a0805d8678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -411,7 +411,7 @@ EOS
${HOMEBREW_REPOSITORY} is not writable. You should change the
ownership and permissions of ${HOMEBREW_REPOSITORY} back to your
user account:
sudo chown -R \$(whoami) ${HOMEBREW_REPOSITORY}
sudo chown -R ${USER-\$(whoami)} ${HOMEBREW_REPOSITORY}
EOS
fi

View File

@ -352,7 +352,7 @@ module Homebrew
You should create these directories and change their ownership to your user.
sudo mkdir -p #{not_exist_dirs.join(" ")}
sudo chown -R $(whoami) #{not_exist_dirs.join(" ")}
sudo chown -R #{current_user} #{not_exist_dirs.join(" ")}
EOS
end
@ -367,7 +367,7 @@ module Homebrew
#{not_writable_dirs.join("\n")}
You should change the ownership of these directories to your user.
sudo chown -R $(whoami) #{not_writable_dirs.join(" ")}
sudo chown -R #{current_user} #{not_writable_dirs.join(" ")}
And make sure that your user has write permission.
chmod u+w #{not_writable_dirs.join(" ")}
@ -916,7 +916,7 @@ module Homebrew
<<~EOS
The staging path #{user_tilde(path.to_s)} is not writable by the current user.
To fix, run:
sudo chown -R $(whoami):staff #{user_tilde(path.to_s)}
sudo chown -R #{current_user} #{user_tilde(path.to_s)}
EOS
end
@ -1027,6 +1027,10 @@ module Homebrew
def cask_checks
all.grep(/^check_cask_/)
end
def current_user
ENV.fetch("USER", "$(whoami)")
end
end
end
end

View File

@ -86,7 +86,7 @@ module Homebrew
rescue Errno::EACCES, Errno::ENOTEMPTY
odie <<~EOS
Could not rename #{keg.name} keg! Check/fix its permissions:
sudo chown -R $(whoami) #{keg}
sudo chown -R #{ENV.fetch("USER", "$(whoami)")} #{keg}
EOS
end
end

View File

@ -13,7 +13,7 @@ lock() {
odie <<EOS
Can't create ${name} lock in ${lock_dir}!
Fix permissions by running:
sudo chown -R \$(whoami) ${HOMEBREW_PREFIX}/var/homebrew
sudo chown -R ${USER-\$(whoami)} ${HOMEBREW_PREFIX}/var/homebrew
EOS
fi
# 200 is the file descriptor used in the lock.