resolve comments.

This commit is contained in:
Darii Nurgaleev
2020-10-13 17:24:06 +07:00
parent 374bf8e5cd
commit fe4def7739

View File

@@ -12,20 +12,22 @@ function Validate-Scripts {
[Parameter(Mandatory=$true)]
[string]$Pattern
)
$ScriptsWithBrokenShebang = @()
$ScriptWithoutShebangLine = @()
Get-ChildItem $path | ForEach-Object {
if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) {
Write-Host "Pattern '$Pattern' found in '$($_.FullName)'"
}
else {
Write-Host "Pattern '$Pattern' not found in '$($_.FullName)'"
$ScriptsWithBrokenShebang += $($_.FullName)
$ScriptWithoutShebangLine += $($_.FullName)
}
}
return $ScriptsWithBrokenShebang
return $ScriptWithoutShebangLine
}
$ScriptsWithBrokenShebang = Validate-Scripts -Path $path -Pattern "#!/bin/bash -e"
$ScriptsWithBrokenShebang = @()
$ScriptsWithBrokenShebang += Validate-Scripts -Path $path1 -Pattern "#!/bin/bash -e"
$ScriptsWithBrokenShebang += Validate-Scripts -Path $path2 -Pattern "#!/bin/bash -e"
if ($ScriptsWithBrokenShebang.Length -gt 0) {
$ScriptsWithBrokenShebang | ForEach-Object {
Write-Warning "The following script does not contain shebang: '$_'"