resolve comments.
This commit is contained in:
@@ -12,20 +12,22 @@ function Validate-Scripts {
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$Pattern
|
[string]$Pattern
|
||||||
)
|
)
|
||||||
$ScriptsWithBrokenShebang = @()
|
$ScriptWithoutShebangLine = @()
|
||||||
Get-ChildItem $path | ForEach-Object {
|
Get-ChildItem $path | ForEach-Object {
|
||||||
if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) {
|
if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) {
|
||||||
Write-Host "Pattern '$Pattern' found in '$($_.FullName)'"
|
Write-Host "Pattern '$Pattern' found in '$($_.FullName)'"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Pattern '$Pattern' not found in '$($_.FullName)'"
|
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) {
|
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
||||||
$ScriptsWithBrokenShebang | ForEach-Object {
|
$ScriptsWithBrokenShebang | ForEach-Object {
|
||||||
Write-Warning "The following script does not contain shebang: '$_'"
|
Write-Warning "The following script does not contain shebang: '$_'"
|
||||||
|
|||||||
Reference in New Issue
Block a user