Skip to content

Commit 8d8de27

Browse files
committed
Add custom shebang support for MunkiAdmin and Outset scripts
1 parent 168f22e commit 8d8de27

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. This projec
1515
### Added
1616

1717
- Added support for minimum AutoPkg version validation for new [VariableSetter](https://github.com/autopkg/autopkg/wiki/Processor-VariableSetter) processor.
18+
- `check-munkiadmin-scripts` and `check-outset-scripts` now support the `--valid-shebangs` argument for specifying additional valid interpreter paths.
1819

1920
### Changed
2021

pre_commit_macadmin_hooks/check_munkiadmin_scripts.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ def build_argument_parser() -> argparse.ArgumentParser:
1515
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
1616
)
1717
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
18+
parser.add_argument(
19+
"--valid-shebangs",
20+
nargs="+",
21+
default=[],
22+
help="Add other valid shebangs for your environment",
23+
)
1824
return parser
1925

2026

@@ -48,7 +54,7 @@ def main(argv: Optional[List[str]] = None) -> int:
4854
# Ensure scripts have a proper shebang
4955
with open(filename, encoding="utf-8") as openfile:
5056
script_content = openfile.read()
51-
if not validate_shebangs(script_content, filename):
57+
if not validate_shebangs(script_content, filename, args.valid_shebangs):
5258
print(f"{filename}: does not start with a valid shebang")
5359
retval = 1
5460

pre_commit_macadmin_hooks/check_outset_scripts.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ def build_argument_parser() -> argparse.ArgumentParser:
1515
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
1616
)
1717
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
18+
parser.add_argument(
19+
"--valid-shebangs",
20+
nargs="+",
21+
default=[],
22+
help="Add other valid shebangs for your environment",
23+
)
1824
return parser
1925

2026

@@ -34,7 +40,7 @@ def main(argv: Optional[List[str]] = None) -> int:
3440
# Ensure scripts have a proper shebang
3541
with open(filename, encoding="utf-8") as openfile:
3642
script_content = openfile.read()
37-
if not validate_shebangs(script_content, filename):
43+
if not validate_shebangs(script_content, filename, args.valid_shebangs):
3844
print(f"{filename}: does not start with a valid shebang")
3945
retval = 1
4046

0 commit comments

Comments
 (0)