Using powershell.exe to execute a PowerShell script using -File currently provides no way to pass $true/$false as parameter values. Current behavior is that -File accumulates passed parameters as strings only.
Fix is to special case this based on discussion with PS-Committee to support $true/$false as parsed values to parameters. Switch values is also supported as currently documented syntax doesn't work.
This change is only for Windows and appends the Windows PowerShell PSModulePath on startup via a default profile. Depending on the data/feedback we get, we can decide what to do (opt-in vs opt-out) as we get closer to a release candidate.
Previously powershell.exe treated unknown arguments as a command line to execute. To align with POSIX so that things like shebang scripts work correctly, we are changing powershell.exe so that it treats unknown arguments (aka positional argument) as a file. This means that `powershell foo` will now attempt to use `foo` as a PowerShell script whereas previously `foo` would be treated as a command to execute. This doesn't affect existing usage of either -File nor -Command. Fixed tests that didn't explicitly use -Command parameter.
On Unix, it is a convention for shells to accept `-i` for an interactive shell and many
tools expect this behavior (`script` for example, and when setting powershell as the
default shell) and calls the shell with the `-i` switch. This change is breaking in
that `-i` previously could be used as short hand to match `-inputformat` which now will
need to be `-in`.
There are cases like using PowerShell via Puppet where the account being
used does not have a home directory. Updated PowerShell to use a process
specific temporary directory if HOME, CONFIG, CACHE, and DATA directories
are not available. Temporary directory is removed when last runspace
is disposed.
XDG profile directory creation can fail for accounts that do not have home directories.
The module analysis was trying to persist it's cache in an XDG profile directory.
The cache is less critical than it once was, so it's reasonable to not cache if there is no good place to do so.
Fixes#3011
* Implement -version parameter in console host (address part of https://github.com/PowerShell/PowerShell/issues/1084)
This does not support providing a specific version to run, but
like most other *nix commands, -version will now return the version
of the PowerShell Engine. 'powershell' is prepended to the output to
match other *nix commands. We are using gitcommitid which includes more
info about the build.
* Fix GetType() bad pattern and related issues in tests
$var.GetType() can raise an exception in tests so we should check $var
before make the call. A large part of the tests does not make this
check.
I start with searching ".GetType()" but discovered many related issues
in tests (reduntant and unneeded tests, "throw" bad pattens, bugs,
formattings (sorry!) and so on) - I had to fix them too.
* Fix after code review
* Second wave of migration GetType() -> BeOfType
Removed 'GetType().Name' patterns.
When running on systems that do not support a virtual terminal,
the tests was incorrectly assuming escape sequences were removed.
The fix is to expect different results depending on whether or not
the host supports virtual terminal mode.
* Wire up proper ConsoleHostRawUserInterface.LengthInBufferCells for Unix
Ref https://github.com/PowerShell/PowerShell/issues/2502
This allows for Unix console host to properly calculate display width for
strings containing escape sequences (e.g. ANSI color), rather than
falling back to naive string.Length.
* Add basic tests for host LengthInBufferCells calculation
PowerShell can be started with input redirected in different scenarios.
`powershell -Command -` is one scenario where commands are sent to
PowerShell, but this is not a interactive shell scenario, it's really
a server to run commands from some other process.
`powershell -File -` or just regular redirected input means PowerShell
is an interactive shell, but command line editing must be done via
the redirected standard input handle instead of interacting directly
with a console handle.
In this scenario, we want to provide a good editing experience. Today,
we provide the bare minimum, supporting backspace but no cursor movement.
The bug here is that backspace was treated as a backspace in the server mode
but should not have been.
The input loop reading from stdin did not handle multi-line input correctly
because it was adding a newline character where none was expected.
The fix was to not include the final newline character to accept input,
just like Console.ReadLine or PSReadline would.
This restructuring moves tests to a directory name which matches the module
in which the cmdlet resides which should improve the discoverability of a
specific test.
For tests which are not about cmdlets in a module, new directories have been
created to make those tests easier to find as well
2016-06-29 12:05:41 -07:00
Renamed from test/powershell/ConsoleHost.Tests.ps1 (Browse further)