Skip to content

generate.sh: bugs identified by shellcheck #7382

@wileyhy

Description

@wileyhy

Describe the bug

A clear and concise description of what the bug is. Include version by typing gh --version.
(installed from dnf:)
gh version 2.27.0 (2023-04-11)
https://github.com/cli/cli/releases/tag/v2.27.0

  1. line 26, so-called "useless" cat
  2. line 27, three unquoted variable expansions

Steps to reproduce the behavior

  1. Type this '...'

In Fedora,
sudo dnf -y install git ShellCheck gh

Distro agnositc,
git clone 'https://github.com/cli/cli'; find . \! -path '*cli/.git/*' \! -empty -type f -exec file -kp '{}' ';' | grep Bourne > /tmp/gh-scripts; mapfile -t ghs < <(cut -d':' -f1 /tmp/gh-scripts); for s in "${ghs[@]}"; do printf '%-50s' "$s"; grep -Eve ^'\s*#' "$s" | wc; done | sort -grk2; shellcheck ./cli/internal/codespaces/rpc/generate.sh

  1. View the output '....'

In ./cli/internal/codespaces/rpc/generate.sh line 26:
services=$(cat "$contract" | grep -Eo "service .+ {" | awk '{print $2 "Server"}')
^---------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
In ./cli/internal/codespaces/rpc/generate.sh line 27:
moq -out $contract.mock.go $dir $services
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
moq -out "$contract".mock.go "$dir" "$services"
For more information:
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
https://www.shellcheck.net/wiki/SC2002 -- Useless cat. Consider 'cmd < file...

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds-triageneeds to be reviewed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions