mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Merge pull request #786 from PowerShell/andschwa/remove-aliases
Fix aliases
This commit is contained in:
@@ -5121,8 +5121,6 @@ end
|
|||||||
"Where-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Where-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("?",
|
new SessionStateAliasEntry("?",
|
||||||
"Where-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Where-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("ac",
|
|
||||||
"Add-Content", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("clc",
|
new SessionStateAliasEntry("clc",
|
||||||
"Clear-Content", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Clear-Content", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("cli",
|
new SessionStateAliasEntry("cli",
|
||||||
@@ -5131,26 +5129,18 @@ end
|
|||||||
"Clear-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Clear-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("clv",
|
new SessionStateAliasEntry("clv",
|
||||||
"Clear-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Clear-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("compare",
|
|
||||||
"Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("cpi",
|
new SessionStateAliasEntry("cpi",
|
||||||
"Copy-Item", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Copy-Item", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("cpp",
|
|
||||||
"Copy-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("cvpa",
|
new SessionStateAliasEntry("cvpa",
|
||||||
"Convert-Path", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Convert-Path", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("dbp",
|
new SessionStateAliasEntry("dbp",
|
||||||
"Disable-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Disable-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("diff",
|
|
||||||
"Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("ebp",
|
new SessionStateAliasEntry("ebp",
|
||||||
"Enable-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Enable-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("epal",
|
new SessionStateAliasEntry("epal",
|
||||||
"Export-Alias", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Export-Alias", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("epcsv",
|
new SessionStateAliasEntry("epcsv",
|
||||||
"Export-Csv", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Export-Csv", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("fc",
|
|
||||||
"Format-Custom", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("fl",
|
new SessionStateAliasEntry("fl",
|
||||||
"Format-List", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Format-List", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("ft",
|
new SessionStateAliasEntry("ft",
|
||||||
@@ -5260,26 +5250,75 @@ end
|
|||||||
"Set-Item", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Set-Item", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("sl",
|
new SessionStateAliasEntry("sl",
|
||||||
"Set-Location", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Set-Location", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("sleep",
|
|
||||||
"Start-Sleep", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("sort",
|
|
||||||
"Sort-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("sp",
|
new SessionStateAliasEntry("sp",
|
||||||
"Set-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Set-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("saps",
|
new SessionStateAliasEntry("saps",
|
||||||
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("start",
|
|
||||||
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("spps",
|
new SessionStateAliasEntry("spps",
|
||||||
"Stop-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Stop-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("spsv",
|
new SessionStateAliasEntry("spsv",
|
||||||
"Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("sv",
|
new SessionStateAliasEntry("sv",
|
||||||
"Set-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Set-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
// Porting note: #if !LINUX is used to disable alises for cmdlets which conflict with Linux / OS X
|
||||||
|
#if !LINUX
|
||||||
|
// ac is a native command on OS X
|
||||||
|
new SessionStateAliasEntry("ac",
|
||||||
|
"Add-Content", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("compare",
|
||||||
|
"Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("cpp",
|
||||||
|
"Copy-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("diff",
|
||||||
|
"Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("sleep",
|
||||||
|
"Start-Sleep", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("sort",
|
||||||
|
"Sort-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("start",
|
||||||
|
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("tee",
|
new SessionStateAliasEntry("tee",
|
||||||
"Tee-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Tee-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("write",
|
new SessionStateAliasEntry("write",
|
||||||
"Write-Output", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
"Write-Output", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
// These were traqnsferred from the "transferred from the profile" section
|
||||||
|
new SessionStateAliasEntry("cat",
|
||||||
|
"Get-Content", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("cp",
|
||||||
|
"Copy-Item", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("ls",
|
||||||
|
"Get-ChildItem", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("man",
|
||||||
|
"help", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("mount",
|
||||||
|
"New-PSDrive", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("mv",
|
||||||
|
"Move-Item", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("ps",
|
||||||
|
"Get-Process", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("rm",
|
||||||
|
"Remove-Item", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("rmdir",
|
||||||
|
"Remove-Item", "", ScopedItemOptions.AllScope),
|
||||||
|
#endif
|
||||||
|
// Bash built-ins we purposefully keep even if they override native commands
|
||||||
|
new SessionStateAliasEntry("cd",
|
||||||
|
"Set-Location", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("dir",
|
||||||
|
"Get-ChildItem", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("echo",
|
||||||
|
"Write-Output", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("fc",
|
||||||
|
"Format-Custom", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("kill",
|
||||||
|
"Stop-Process", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("pwd",
|
||||||
|
"Get-Location", "", ScopedItemOptions.AllScope),
|
||||||
|
new SessionStateAliasEntry("type",
|
||||||
|
"Get-Content", "", ScopedItemOptions.AllScope),
|
||||||
|
// Native commands we keep because the functions act correctly on Linux
|
||||||
|
new SessionStateAliasEntry("clear",
|
||||||
|
"Clear-Host", "", ScopedItemOptions.AllScope),
|
||||||
//#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore
|
//#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore
|
||||||
#if !CORECLR
|
#if !CORECLR
|
||||||
new SessionStateAliasEntry("asnp",
|
new SessionStateAliasEntry("asnp",
|
||||||
@@ -5316,46 +5355,18 @@ end
|
|||||||
"Out-Printer", "", ScopedItemOptions.AllScope),
|
"Out-Printer", "", ScopedItemOptions.AllScope),
|
||||||
#endif
|
#endif
|
||||||
// Aliases transferred from the profile
|
// Aliases transferred from the profile
|
||||||
new SessionStateAliasEntry("cat",
|
|
||||||
"Get-Content", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("cd",
|
|
||||||
"Set-Location", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("clear",
|
|
||||||
"Clear-Host", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("cp",
|
|
||||||
"Copy-Item", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("h",
|
new SessionStateAliasEntry("h",
|
||||||
"Get-History", "", ScopedItemOptions.AllScope),
|
"Get-History", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("history",
|
new SessionStateAliasEntry("history",
|
||||||
"Get-History", "", ScopedItemOptions.AllScope),
|
"Get-History", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("kill",
|
|
||||||
"Stop-Process", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("ls",
|
|
||||||
"Get-ChildItem", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("man",
|
|
||||||
"help", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("mount",
|
|
||||||
"New-PSDrive", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("md",
|
new SessionStateAliasEntry("md",
|
||||||
"mkdir", "", ScopedItemOptions.AllScope),
|
"mkdir", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("mv",
|
|
||||||
"Move-Item", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("popd",
|
new SessionStateAliasEntry("popd",
|
||||||
"Pop-Location", "", ScopedItemOptions.AllScope),
|
"Pop-Location", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("ps",
|
|
||||||
"Get-Process", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("pushd",
|
new SessionStateAliasEntry("pushd",
|
||||||
"Push-Location", "", ScopedItemOptions.AllScope),
|
"Push-Location", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("pwd",
|
|
||||||
"Get-Location", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("r",
|
new SessionStateAliasEntry("r",
|
||||||
"Invoke-History", "", ScopedItemOptions.AllScope),
|
"Invoke-History", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("rm",
|
|
||||||
"Remove-Item", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("rmdir",
|
|
||||||
"Remove-Item", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("echo",
|
|
||||||
"Write-Output", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("cls",
|
new SessionStateAliasEntry("cls",
|
||||||
"Clear-Host", "", ScopedItemOptions.AllScope),
|
"Clear-Host", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("chdir",
|
new SessionStateAliasEntry("chdir",
|
||||||
@@ -5364,8 +5375,6 @@ end
|
|||||||
"Copy-Item", "", ScopedItemOptions.AllScope),
|
"Copy-Item", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("del",
|
new SessionStateAliasEntry("del",
|
||||||
"Remove-Item", "", ScopedItemOptions.AllScope),
|
"Remove-Item", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("dir",
|
|
||||||
"Get-ChildItem", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("erase",
|
new SessionStateAliasEntry("erase",
|
||||||
"Remove-Item", "", ScopedItemOptions.AllScope),
|
"Remove-Item", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("move",
|
new SessionStateAliasEntry("move",
|
||||||
@@ -5376,8 +5385,6 @@ end
|
|||||||
"Rename-Item", "", ScopedItemOptions.AllScope),
|
"Rename-Item", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("set",
|
new SessionStateAliasEntry("set",
|
||||||
"Set-Variable", "", ScopedItemOptions.AllScope),
|
"Set-Variable", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("type",
|
|
||||||
"Get-Content", "", ScopedItemOptions.AllScope),
|
|
||||||
new SessionStateAliasEntry("icm",
|
new SessionStateAliasEntry("icm",
|
||||||
"Invoke-Command", "", ScopedItemOptions.AllScope),
|
"Invoke-Command", "", ScopedItemOptions.AllScope),
|
||||||
new SessionStateAliasEntry("clhy",
|
new SessionStateAliasEntry("clhy",
|
||||||
@@ -5460,12 +5467,18 @@ if($paths) {
|
|||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("prompt", DefaultPromptFunctionText),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("prompt", DefaultPromptFunctionText),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("TabExpansion2", TabExpansionFunctionText),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("TabExpansion2", TabExpansionFunctionText),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Clear-Host", GetClearHostFunctionText()),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Clear-Host", GetClearHostFunctionText()),
|
||||||
|
// Porting note: we keep more because the function acts correctly on Linux
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("more", DefaultMoreFunctionText),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("more", DefaultMoreFunctionText),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("help", GetHelpPagingFunctionText()),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("help", GetHelpPagingFunctionText()),
|
||||||
|
// Porting note: we remove mkdir on Linux because it is a conflict
|
||||||
|
#if !LINUX
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("mkdir", GetMkdirFunctionText()),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("mkdir", GetMkdirFunctionText()),
|
||||||
|
#endif
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Get-Verb", GetGetVerbText()),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Get-Verb", GetGetVerbText()),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("oss", GetOSTFunctionText()),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("oss", GetOSTFunctionText()),
|
||||||
|
|
||||||
|
// Porting note: we remove the drive functions from Linux because they make no sense
|
||||||
|
#if !LINUX
|
||||||
// Default drives
|
// Default drives
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("A:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("A:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("B:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("B:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
||||||
@@ -5493,6 +5506,7 @@ if($paths) {
|
|||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("X:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("X:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Y:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Y:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Z:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("Z:", DefaultSetDriveFunctionText, SetDriveScriptBlock),
|
||||||
|
#endif
|
||||||
|
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("cd..", "Set-Location .."),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("cd..", "Set-Location .."),
|
||||||
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("cd\\", "Set-Location \\"),
|
SessionStateFunctionEntry.GetDelayParsedFunctionEntry("cd\\", "Set-Location \\"),
|
||||||
|
|||||||
@@ -35,35 +35,6 @@ Describe "Compare-Object" {
|
|||||||
{ Compare-Object -ReferenceObject $(Get-Content $file1) $(Get-Content $file2) } | Should Not Throw
|
{ Compare-Object -ReferenceObject $(Get-Content $file1) $(Get-Content $file2) } | Should Not Throw
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to execute compare object using the compare alias" {
|
|
||||||
{ compare -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) } | Should Not Throw
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should produce the same output when the compare alias is used" {
|
|
||||||
$alias = compare -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2)
|
|
||||||
$fullname = Compare-Object -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2)
|
|
||||||
|
|
||||||
$alias[0].InputObject | Should Be $fullname[0].InputObject
|
|
||||||
$alias[0].SideIndicator | Should Be $fullname[0].SideIndicator
|
|
||||||
$alias[1].InputObject | Should Be $fullname[1].InputObject
|
|
||||||
$alias[1].SideIndicator | Should Be $fullname[1].SideIndicator
|
|
||||||
|
|
||||||
$alias.Length | Should Be 2 # There should be no other elements to test
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should be able to execute compare object using the diff alias" {
|
|
||||||
$alias = diff -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2)
|
|
||||||
$fullname = Compare-Object -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2)
|
|
||||||
|
|
||||||
$alias[0].InputObject | Should Be $fullname[0].InputObject
|
|
||||||
$alias[0].SideIndicator | Should Be $fullname[0].SideIndicator
|
|
||||||
$alias[1].InputObject | Should Be $fullname[1].InputObject
|
|
||||||
$alias[1].SideIndicator | Should Be $fullname[1].SideIndicator
|
|
||||||
|
|
||||||
$alias.Length | Should Be 2 # There should be no other elements to test
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should indicate data that exists only in the reference dataset" {
|
It "Should indicate data that exists only in the reference dataset" {
|
||||||
$actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4)
|
$actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
$removeAliasList = @("ac","compare","cpp","diff","sleep","sort","start","cat","cp","ls","man","mount","mv","ps","rm","rmdir")
|
||||||
|
$keepAliasList = @{cd="Set-Location"},@{dir="Get-ChildItem"},@{echo="Write-output"},@{fc="format-custom"},@{kill="stop-process"},@{clear="clear-host"}
|
||||||
|
Describe "Windows aliases do not conflict with Linux commands" {
|
||||||
|
foreach ($alias in $removeAliasList) {
|
||||||
|
It "Should not have certain aliases on Linux" -Skip:$IsWindows {
|
||||||
|
Test-Path Alias:$alias | Should Be $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($alias in $keepAliasList) {
|
||||||
|
It "Should have aliases that are Bash built-ins on Linux" {
|
||||||
|
(Get-Alias $alias.Keys).Definition | Should Be $alias.Values
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Should have more as a function" {
|
||||||
|
Test-Path Function:more | Should Be $true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -144,7 +144,7 @@ Describe "Export-Alias" {
|
|||||||
|
|
||||||
Test-Path $fulltestpath | Should Be $true
|
Test-Path $fulltestpath | Should Be $true
|
||||||
|
|
||||||
$actual = Get-Content $fulltestpath | Sort
|
$actual = Get-Content $fulltestpath | Sort-Object
|
||||||
$expected = Get-Command -CommandType Alias
|
$expected = Get-Command -CommandType Alias
|
||||||
|
|
||||||
for ( $i=0; $i -lt $expected.Length; $i++)
|
for ( $i=0; $i -lt $expected.Length; $i++)
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ Describe "Get-ChildItem" {
|
|||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to use the ls alias" {
|
|
||||||
$(ls .).Name.Length | Should Be $(Get-ChildItem .).Name.Length
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should have a the proper fields and be populated" {
|
It "Should have a the proper fields and be populated" {
|
||||||
$var = Get-Childitem .
|
$var = Get-Childitem .
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,6 @@ Describe "Get-Content" {
|
|||||||
(Get-Content -Path $testPath) | Should Be $testString
|
(Get-Content -Path $testPath) | Should Be $testString
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to call using the cat alias" {
|
|
||||||
{ cat -Path $testPath } | Should Not Throw
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should be able to call using the gc alias" {
|
It "Should be able to call using the gc alias" {
|
||||||
{ gc -Path $testPath } | Should Not Throw
|
{ gc -Path $testPath } | Should Not Throw
|
||||||
}
|
}
|
||||||
@@ -55,11 +51,9 @@ Describe "Get-Content" {
|
|||||||
It "Should return the same values for aliases" {
|
It "Should return the same values for aliases" {
|
||||||
$getContentAlias = Get-Content -Path $testPath
|
$getContentAlias = Get-Content -Path $testPath
|
||||||
$gcAlias = gc -Path $testPath
|
$gcAlias = gc -Path $testPath
|
||||||
$catAlias = cat -Path $testPath
|
|
||||||
$typeAlias = type -Path $testPath
|
$typeAlias = type -Path $testPath
|
||||||
|
|
||||||
$getContentAlias | Should Be $gcAlias
|
$getContentAlias | Should Be $gcAlias
|
||||||
$getContentAlias | Should Be $catAlias
|
|
||||||
$getContentAlias | Should Be $typeAlias
|
$getContentAlias | Should Be $typeAlias
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,21 +62,21 @@ Describe "Get-Content" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to specify the number of lines to get the content of using the TotalCount switch" {
|
It "Should be able to specify the number of lines to get the content of using the TotalCount switch" {
|
||||||
$returnArray = (cat -Path $testPath2 -TotalCount 2)
|
$returnArray = (Get-Content -Path $testPath2 -TotalCount 2)
|
||||||
|
|
||||||
$returnArray[0] | Should Be $firstline
|
$returnArray[0] | Should Be $firstline
|
||||||
$returnArray[1] | Should Be $secondline
|
$returnArray[1] | Should Be $secondline
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to specify the number of lines to get the content of using the Head switch" {
|
It "Should be able to specify the number of lines to get the content of using the Head switch" {
|
||||||
$returnArray = (cat -Path $testPath2 -Head 2)
|
$returnArray = (Get-Content -Path $testPath2 -Head 2)
|
||||||
|
|
||||||
$returnArray[0] | Should Be $firstline
|
$returnArray[0] | Should Be $firstline
|
||||||
$returnArray[1] | Should Be $secondline
|
$returnArray[1] | Should Be $secondline
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to specify the number of lines to get the content of using the First switch" {
|
It "Should be able to specify the number of lines to get the content of using the First switch" {
|
||||||
$returnArray = (cat -Path $testPath2 -First 2)
|
$returnArray = (Get-Content -Path $testPath2 -First 2)
|
||||||
|
|
||||||
$returnArray[0] | Should Be $firstline
|
$returnArray[0] | Should Be $firstline
|
||||||
$returnArray[1] | Should Be $secondline
|
$returnArray[1] | Should Be $secondline
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ Describe "Get-Item" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should have mode flags set" {
|
It "Should have mode flags set" {
|
||||||
ls $PSScriptRoot | foreach-object { $_.Mode | Should Not BeNullOrEmpty }
|
Get-ChildItem $PSScriptRoot | foreach-object { $_.Mode | Should Not BeNullOrEmpty }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,22 @@
|
|||||||
Describe "NativeLinuxCommands" {
|
Describe "NativeLinuxCommands" {
|
||||||
It "Should return a type of System.Object for hostname cmdlet" {
|
It "Should return a type of System.Object for hostname cmdlet" {
|
||||||
(hostname).GetType().BaseType | Should Be 'System.Object'
|
(hostname).GetType().BaseType | Should Be 'System.Object'
|
||||||
(hostname).GetType().Name | Should Be String
|
(hostname).GetType().Name | Should Be String
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should have not empty Name flags set for ps object" {
|
It "Should have not empty Name flags set for ps object" {
|
||||||
ps | foreach-object { $_.ProcessName | Should Not BeNullOrEmpty }
|
Get-Process | foreach-object { $_.ProcessName | Should Not BeNullOrEmpty }
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should find Application grep" -Skip:$IsWindows {
|
It "Should find Application grep" -Skip:$IsWindows {
|
||||||
(get-command grep).CommandType | Should Be Application
|
(get-command grep).CommandType | Should Be Application
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should pipe to grep and get result" -Skip:$IsWindows {
|
It "Should pipe to grep and get result" -Skip:$IsWindows {
|
||||||
"hello world" | grep hello | Should Be "hello world"
|
"hello world" | grep hello | Should Be "hello world"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should find Application touch" -Skip:$IsWindows {
|
It "Should find Application touch" -Skip:$IsWindows {
|
||||||
(get-command touch).CommandType | Should Be Application
|
(get-command touch).CommandType | Should Be Application
|
||||||
}
|
|
||||||
|
|
||||||
It "Should find Alias ls" -Skip:$IsWindows {
|
|
||||||
(get-command ls).CommandType | Should Be Alias
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should find Function mkdir" -Skip:$IsWindows {
|
|
||||||
(get-command mkdir).CommandType | Should Be Function
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,5 @@ Describe "Start-Sleep" {
|
|||||||
$result = Measure-Command { Start-Sleep -s 1 }
|
$result = Measure-Command { Start-Sleep -s 1 }
|
||||||
$result.TotalSeconds | Should BeGreaterThan 0.25
|
$result.TotalSeconds | Should BeGreaterThan 0.25
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should sleep for at least 1 second using the alias" {
|
|
||||||
$result = Measure-Command { sleep -s 1 }
|
|
||||||
$result.TotalSeconds | Should BeGreaterThan 0.25
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,8 @@ Describe "Tee-Object" {
|
|||||||
|
|
||||||
It "Should return the output to the screen and to the variable" {
|
It "Should return the output to the screen and to the variable" {
|
||||||
$teefile = $testfile
|
$teefile = $testfile
|
||||||
echo teeobjecttest1 | Tee-Object -variable teeresults
|
echo teeobjecttest1 | Tee-Object -variable teeresults
|
||||||
$teeresults | Should Be "teeobjecttest1"
|
$teeresults | Should Be "teeobjecttest1"
|
||||||
Remove-Item $teefile -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
It "Should return the output to the screen and to the variable from the alias" {
|
|
||||||
$teefile = $testfile
|
|
||||||
echo teeobjecttest2 | tee -variable teeresults
|
|
||||||
$teeresults | Should Be "teeobjecttest2"
|
|
||||||
Remove-Item $teefile -ErrorAction SilentlyContinue
|
Remove-Item $teefile -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,12 +17,5 @@ Describe "Tee-Object" {
|
|||||||
Get-Content $teefile | Should Be "teeobjecttest3"
|
Get-Content $teefile | Should Be "teeobjecttest3"
|
||||||
Remove-Item $teefile -ErrorAction SilentlyContinue
|
Remove-Item $teefile -ErrorAction SilentlyContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Should tee the output to a file using the alias" {
|
|
||||||
$teefile = $testfile
|
|
||||||
echo teeobjecttest4 | tee $teefile
|
|
||||||
Get-Content $teefile | Should Be "teeobjecttest4"
|
|
||||||
Remove-item $teefile -ErrorAction SilentlyContinue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user