bat/tests/syntax-tests/source/PowerShell/test.ps1
Martin Nordholts 68d525cd8b Don't add artificial newline to last line if --style=plain
This fixes #1438.

Note however, that using a pager such as less will add a newline itself.
So to actually not print a newline for such files, you need to either
disable paging:

  bat --style=plain --paging=never no-newline-at-end-of-file.txt

or use a "pager" that does not add a newline:

  bat --style=plain --pager=cat no-newline-at-end-of-file.txt

Note that we also update syntax tests file since a bunch of them had
missing newlines on the last lines.
2020-12-19 10:32:50 +01:00

26 lines
1.4 KiB
PowerShell
Executable File
Vendored
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PowerShell script for testing syntax highlighting
function Get-FutureTime {
param (
[Int32] $Minutes
)
$time = Get-Date | % { $_.AddMinutes($Minutes) }
"{0:d2}:{1:d2}:{2:d2}" -f @($time.hour, $time.minute, $time.second)
}
if ($env:PATH -match '.*rust.*') {
'Path contains Rust'
try {
& "cargo" "--version"
} catch {
Write-Error "Failed to run cargo"
}
} else {
'Path does not contain Rust'
}
(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
"The time will be " + $later + " later."