Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate ShellCheck into GitHub Action #7904

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ jobs:
brew install vale
vale docs/

- name: Run ShellCheck
run: |
brew install shellcheck
shellcheck --color bin/brew
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is (or at least should be) already run by brew style:

shellcheck = which("shellcheck")
shellcheck ||= which("shellcheck", ENV["HOMEBREW_PATH"])
shellcheck ||= begin
ohai "Installing `shellcheck` for shell style checks..."
system HOMEBREW_BREW_FILE, "install", "shellcheck"
which("shellcheck") || which("shellcheck", ENV["HOMEBREW_PATH"])
end
unless shellcheck
opoo "Could not find or install `shellcheck`! Not checking shell style."
return rubocop_success
end

ven='./Library/Homebrew/vendor/*'
taps='./Library/Taps/*'
find . -type f -iname "*\.sh" -not -path "$ven" -not -path "$taps" -exec shellcheck --color {} \;

- name: Lint Dockerfile
if: matrix.os == 'ubuntu-latest'
run: |
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
# Force UTF-8 to avoid encoding issues for users with broken locale settings.
if [[ "$(locale charmap 2>/dev/null)" != "UTF-8" ]]
then
export LC_ALL="en_US.UTF-8"
fi

# USER isn't always set so provide a fall back for `brew` and subprocesses.
export USER=${USER:-`id -un`}
export USER=${USER:-$(id -un)}

# Where we store built products; a Cellar in HOMEBREW_PREFIX (often /usr/local
# for bottles) unless there's already a Cellar in HOMEBREW_REPOSITORY.
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/shellenv.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#: * `shellenv`
#:
#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`.
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/update-reset.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#: * `update-reset` [<repository>]
#:
#: Fetch and reset Homebrew and all tap repositories (or any specified <repository>) using `git`(1) to their latest `origin/master`.
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#: * `update`, `up` [<options>]
#:
#: Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations.
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/vendor-install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#: @hide_from_man_page
#: * `vendor-install` [<target>]
#:
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils/analytics.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# Migrate analytics UUID to its new home in Homebrew repo's git config and
# remove the legacy UUID file if detected.
migrate-legacy-uuid-file() {
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils/lock.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# create a lock using `flock(2)`. A name is required as first argument.
# the lock will be automatically unlocked when the shell process quits.
# Noted due to the fixed FD, a shell process can only create one lock.
Expand Down
3 changes: 2 additions & 1 deletion Library/Homebrew/utils/ruby.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
test_ruby () {
if [[ ! -x $1 ]]
then
Expand Down Expand Up @@ -44,7 +45,7 @@ If there's no Homebrew Portable Ruby available for your processor:
then
HOMEBREW_RUBY_PATH="$vendor_ruby_path"
[[ -z "$HOMEBREW_MACOS" ]] && TERMINFO_DIRS="$vendor_ruby_terminfo"
if [[ $vendor_ruby_current_version != $vendor_ruby_latest_version ]]
if [[ $vendor_ruby_current_version != "$vendor_ruby_latest_version" ]]
then
if ! brew vendor-install ruby
then
Expand Down
4 changes: 2 additions & 2 deletions bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ symlink_target_directory() {
builtin enable compgen unset
for cmd in $(builtin compgen -A builtin)
do
builtin unset -f $cmd
builtin enable $cmd
builtin unset -f "$cmd"
builtin enable "$cmd"
done
unset cmd

Expand Down