-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellcheck.mk
More file actions
79 lines (63 loc) · 3.05 KB
/
shellcheck.mk
File metadata and controls
79 lines (63 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
SHELL := /bin/bash -euo pipefail
define SHELLCHECK_HELP
REQUIREMENTS:
- shellcheck : `shellcheck` command must be available.
TARGETS:
- shellcheck-help : show help message.
- shellcheck : run shellcheck command with given args.
- shellcheck-run : run shellcheck.
VARIABLES [default value]:
- SHELLCHECK_CMD : shellcheck binary path. [shellcheck]
- SHELLCHECK_TARGET : target of spell check. [All *.sh files]
- SHELLCHECK_OPTION : shellcheck command line option. []
REFERENCES:
- https://github.com/koalaman/shellcheck
- https://www.shellcheck.net/
- https://www.shellcheck.net/wiki/Directive#shellcheckrc-file
IDE INTEGRATIONS:
- VSCode : https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck
- JetBrains : https://plugins.jetbrains.com/plugin/13122-shell-script
- JetBrains : https://plugins.jetbrains.com/plugin/10195-shellcheck
PROJECT STRUCTURE:
/ |-- Project
├─ _scripts/ |-- Git submodule
│ └─ makefiles/ |
│ └─ shellcheck.mk |
├─ .shellcheckrc |-- Config file
└─ Makefile |-- include _scripts/makefiles/shellcheck.mk
endef
.PHONY: shellcheck-help
shellcheck-help:
$(info $(SHELLCHECK_HELP))
@echo ""
#├─────────────────────────────────────────────────────────────────────────────┤
SHELLCHECK_CMD ?= shellcheck
SHELLCHECK_TARGET ?= $(shell find . -type f -name '*.sh' 2>/dev/null)
SHELLCHECK_OPTION ?=
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: shellcheck-usage
shellcheck-usage:
# Usage : make shellcheck ARGS=""
# Exec : $$(SHELLCHECK_CMD) $$(ARGS)
# Desc : Run shellcheck with given arguments.
# Examples:
# - make shellcheck ARGS="--version"
# - make shellcheck ARGS="--help"
.PHONY: shellcheck
shellcheck:
$(SHELLCHECK_CMD) $(ARGS)
#├─────────────────────────────────────────────────────────────────────────────┤
.PHONY: shellcheck-run-usage
shellcheck-run-usage:
# Usage : make shellcheck-run ARGS=""
# Exec : $$(SHELLCHECK_CMD) $$(ARGS) $$(SHELLCHECK_OPTION) $$(SHELLCHECK_TARGET)
# Desc : Run shellcheck for the specified target.
# Examples:
# - make shellcheck-run
# - make shellcheck-run ARGS=""
.PHONY: shellcheck-run
shellcheck-run:
ifneq (,$(SHELLCHECK_TARGET))
$(SHELLCHECK_CMD) $(ARGS) $(SHELLCHECK_OPTION) $(SHELLCHECK_TARGET)
endif
#├─────────────────────────────────────────────────────────────────────────────┤