请输入您要查询的百科知识:

 

词条 Comparison of command shells
释义

  1. General characteristics

  2. Interactive features

      Background execution    Completions    Command history    Mandatory argument prompt    Automatic suggestions    Directory history, stack or similar features    Implicit directory change    Autocorrection    Integrated environment    Snippets    Value prompt    Menu/options selector    Progress indicator    Interactive table    Syntax highlighting   Context sensitive help  Command builder 

  3. Programming features

  4. String processing and filename matching

  5. Inter-process communication

     Keystroke stacking 

  6. Security features

      Secure prompt    Encrypted variables/parameters    Execute permission    Untrusted script blocking    Script origin execution restriction    Signed script restriction    Multilevel execution policies    Restricted shell subset    Safe data subset  

  7. References

  8. External links

{{details|Shell (computing)}}{{multiple issues|{{Refimprove|date=August 2011}}{{Undue weight|date=October 2013}}{{POV|date=July 2014}}}}

A command shell is a command line interface computer program to an operating system.

General characteristics

ShellUsual environmentUsually invokedIntroducedPlatform-independentDefault login shell inDefault script shell inLicenseSource code availabilityUser interfaceMouse supportUnicode supportISO 8601 supportConsole redirectionStream redirectionConfigurabilityStartup/shutdown scriptsBatch scriptsLoggingavailable as statically linked, independent single file executable
Thompson shellUNIXsh1971{{N/A}}UNIXUNIX{{N/A}}{{yes}}Text-based CLI{{no}}{{no}}{{N/A}}{{yes}}{{N/A}}{{N/A}}{{N/A}}{{N/A}}{{N/A}}{{N/A}}
Bourne shell 1977 version7th Ed. UNIXsh1977Yes[1]}}7th Ed. UNIX7th Ed. UNIX,Proprietary[2]}}{{yes}}Text-based CLI{{no}}{{no}}{{N/A}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (.profile)}}Yes (Unix feature)}}{{no}}{{yes}}
Bourne shell current versionVarious UNIXsh1977Yes[3]}}SunOS-5.x, FreeBSD (non-root user)[4]SunOS-5.xCDDL[5]{{better source|date=April 2015}}}}{{yes}}Text-based CLI{{no}}[6]{{better source>date=April 2015}}{{N/A}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (.profile)}}Yes (Unix feature)}}{{yes}}[7]{{yes}}
POSIX shell[8]POSIXsh1992[9]{{N/A}}{{N/A}}POSIX{{N/A}}{{N/A}}Text-based CLI{{no}}Yes, if used by configured locale}}{{N/A}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Unspecified (.profile given as an example)Yes (Unix feature)}}{{yes}}{{N/A}}
bash (v4)POSIXbash, sh1989[10]{{yes}}GNU, Linux (default for root), Mac OS X 10.3+GNU, Linux, Haiku, Mac OS XGPL}}{{yes}}Text-based CLI{{no}}[11]{{better source>reason=Unicode escape is just a small part of Unicode support. There's also editing and string handling. This works in bash 4.3.33, but needs a source.|date=May 2015}}Yes (printf builtin)}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (/etc/profile, .bash_profile, .bash_login, .profile, .bashrc)}}Yes (Unix feature)}}{{yes}}{{yes}}
cshPOSIXcsh1978{{yes}}SunOS{{dunno}}BSD}}{{yes}}Text-based CLI{{no}}{{no}}{{dunno}}{{yes}}Yes (stdin, stdout, stdout+stderr)}}Yes (via variables and options)}}Yes (~/.cshrc, ~/.login, ~/.logout)}}Yes (Unix feature)}}{{yes}}{{yes}}
tcshPOSIXtcsh, csh1983[12]{{yes}}FreeBSD (default for root), formerly Mac OS X{{dunno}}BSD}}{{yes}}Text-based CLI{{no}}{{yes}}{{dunno}}{{yes}}Yes (stdin, stdout, stdout+stderr)}}Yes (via variables and options)}}Yes (/etc/csh.cshrc, /etc/csh.login, ~/.tcshrc, ~/.cshrc, ~/.history, ~/.login, ~/.cshdirs)}}Yes (Unix feature)}}{{yes}}{{yes}}
Hamilton C shellWin32, OS/2csh1988[13]{{yes}} (OS/2 version no longer maintained){{optional}}{{optional}}{{proprietary}}{{no}}Text-based CLI{{no}}{{no}}Yes (-t timestamp operator)}}{{yes}}Yes (stdin, stdout, stdout+stderr)}}Yes (via variables and options)}}Yes (via login.csh, startup.csh and logout.csh)}}Yes (command line option)}}{{yes}}{{yes}}
ScshPOSIXscsh1994{{yes}}{{dunno}}{{dunno}}BSD-style}}{{yes}}{{dunno}}{{dunno}}{{dunno}}{{dunno}}{{dunno}}{{yes}}{{dunno}}{{dunno}}{{dunno}}{{dunno}}{{yes}}
ksh (ksh93t+)POSIXksh1983[14][15]{{yes}}AIX, HP-UXOpenSolarisCommon Public License}}{{yes}}Text-based CLI{{no}}{{yes}}Yes (printf builtin with %(%F)T[16])}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (system and user's profile and kshrc)}}Yes (Unix feature)}}{{yes}}{{yes}}
pdkshPOSIXksh, sh1989?{{yes}}OpenBSD[17]OpenBSD[17]Public Domain}}{{yes}}Text-based CLI{{no}}{{no}}{{N/A}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (/etc/profile, .profile)}}Yes (Unix feature)}}{{yes}}{{yes}}
zshPOSIXzsh1990{{yes}}Deepin, Gobolinux, GrmlGrmlMIT-style}}{{yes}}Text-based CLIvia additional code[18]}}{{yes}}Yes (various internal features involving the date, by using the %F strftime format[19] and the -i option for the fc builtin[20])}}{{yes}}Yes (arbitrary fds)}}Yes (via variables, options, functions, styles, etc.)}}Yes (system and user's zshenv, zprofile, zshrc, zlogin, zlogout)}}Yes (Unix feature)}}{{yes}}{{yes}}
ashPOSIXsh1989{{yes}}Minix, BusyBox based systemsNetBSD, Minix, BusyBox based systemsBSD-style}}{{yes}}Text-based CLI{{no}}{{partial}} (for BusyBox, supported in command-line editing, but not in string handling[21]){{N/A}}{{yes}}Yes (arbitrary fds)}}Yes (via variables and options)}}Yes (/etc/profile, .profile)}}Yes (Unix feature)}}{{yes}}{{yes}}
CCPCP/M, MP/M(CCP)1975 (1973){{no}}CP/M (no login), MP/MCP/M, MP/MFreeware (originally proprietary)}}{{yes}} (originally closed-source)Text-based CLI{{no}}{{no}}{{no}}{{dunno}}{{no}}{{no}}{{yes}} (automatic via $$$.SUB){{partial}} (only via external SUBMIT command to update $$$.SUB){{no}}{{yes}}
COMMAND.COMDOSCOMMAND1980{{no}} (3rd party implementations, not bound to a specific DOS vendor or version, available)DOS, Windows 95, 98, SE, MEDOS, Windows 95, 98, SE, MEvendor specific, f.e. MS-EULA,[22] or BSD/GPL (free clones){{no}} (except for OpenDOS, DR-DOS, PTS/DOS and FreeDOS)Text-based CLI{{no}}{{no}}{{no}} (except for DR-DOS){{yes}} (via COMMAND con: or CTTY con:)Yes (stdin, stdout)}}{{yes}} (via startup parameters and environment variables, DR-DOS also supports DIR /C /R user-default switch command){{yes}} (automatic \\AUTOEXEC.BAT for primary shell, or explicitly via /P, /P:filename.bat or /K startup options){{yes}} (via CALL command or /C and /K startup options){{no}}{{yes}}
OS/2 CMD.EXEOS/2CMD1987{{no}}OS/2OS/2IBM-EULA}}[23]{{no}}Text-based CLI{{no}}{{no}}{{no}}{{no}}Yes (stdin, stdout, stderr)}}{{dunno}}{{partial}} (only via /K startup option){{yes}} (via CALL command or /C and /K startup options){{no}}{{dunno}}
Windows CMD.EXE[24]Win32CMD1993{{no}}Windows NT, 2000, XP, Server 2003, VistaWindows NT, 2000, XP, Server 2003, VistaMS-EULA}}[25]{{no}}Text-based CLI{{no}}{{partial}} (CHCP 65001 for UTF-8, but program arguments are still encoded in local codepage){{no}}{{no}}{{yes}}{{yes}} (via registry, startup parameters, and environment variables){{yes}} (automatic via registry, or explicitly via /K startup option){{yes}} (via CALL command or /C and /K startup options){{no}}{{yes}}
4DOS, NDOSDOS, Windows 95, 98, SE, ME4DOS, NDOS1989 (1986)No (not bound to a specific OS vendor or version)}}{{optional}}{{optional}}MIT License, with restrictions}}{{yes}}Text-based CLI with TUI extensions{{yes}} (popups, help system, %_MOUSE internal variable, INKEY /M command){{no}}{{yes}}{{yes}} (via CTTY con:, except for DRAWBOX, DRAWLINE, DRAWVLINE, LIST, SCREEN, SCRPUT, SELECT, VSCRPUT commands and file / directory coloring)Yes (stdin, stdout, stderr, stdout+stderr)}}{{yes}} (via 4DOS.INI/NDOS.INI file, startup parameters, environment variables, SETDOS command){{yes}} (automatic \\AUTOEXEC.BAT for primary shell and 4START.BTM/4START.BAT as well as 4EXIT.BTM/4EXIT.BAT for any shell, or explicitly via /P, /P:dir\\filename.ext or /K startup options){{yes}} (via CALL command or /C and /K startup options){{yes}}{{yes}}
4OS2OS/24OS21992No (not bound to specific OS/2 versions)}}{{optional}}{{optional}}Freeware}}{{yes}}Text-based CLI{{no}}{{no}}{{no}}{{no}}Yes (stdin, stdout, stderr, stdout+stderr)}}{{yes}} (via 4OS2.INI file, startup parameters, environment variables, SETDOS command){{yes}} (automatic via 4START.CMD/4START.BTM as well as 4EXIT.CMD/4EXIT.BTM files, or explicitly via /K startup.cmd option){{yes}} (via CALL command or /C and /K startup options){{yes}}{{dunno}}
TCC (formerly 4NT)Win32TCC1993No (not bound to specific NT versions)}}optionaloptionalShareware}}{{no}}Text-based CLI (Take Command: GUI){{yes}} (console mouse, popups, help system, %_XMOUSE, %_YMOUSE internal variables, INKEY /M command){{yes}}{{yes}}{{no}}Yes (stdin, stdout, stderr, stdout+stderr)}}{{yes}} (via registry, TCMD.INI/4NT.INI file, startup parameters, environment variables, SETDOS command){{yes}} (automatic via registry and TCSTART/4START as well as TCEXIT/4EXIT, or explicitly via /K startup option){{yes}} (via CALL command or /C and /K startup options){{yes}}{{no}}
VMS DCL[26]OpenVMSAutomatically for login/interactive process1977?{{yes}}VMSVMSProprietary, bundled in VMSby special license only}}Text-based CLIwith DECwindows/Motif}}{{yes}}Yes, at least to 1988 standard}}{{yes}}Yes (sys$input, sys$output assignment)}}Yes (via symbols, logical names, and options)}}Yes (SYS$MANAGER:SYLOGIN.COM and user defined LOGIN.COM)}}{{yes}}{{yes}}{{no}}
PowerShell.NETPowerShell2006{{yes}}Windows Server 2008, 7, Vista, XP[27]Windows Server 2008, 7MIT-style}}{{yes}}Graphical CLI{{yes}}{{yes}}{{yes}}{{no}}{{yes}}Yes (via variables and options)}}Yes (%USERPROFILE%\\Documents \\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1)}}Yes (PowerShell feature)}}{{yes}}{{no}}
rcPlan 9, POSIXrc1989{{yes}}Plan 9, Version 10 UnixPlan 9, Version 10 UnixLucent Public License}}{{dunno}}{{dunno}}{{dunno}}{{yes}}{{dunno}}{{dunno}}{{yes}}{{dunno}}{{dunno}}{{dunno}}{{dunno}}{{yes}}
BeanShellJava{{dunno}}2005{{yes}}{{dunno}}{{dunno}}LGPL}}{{dunno}}{{dunno}}{{dunno}}{{yes}}{{dunno}}{{dunno}}{{yes}}{{dunno}}{{dunno}}{{dunno}}{{dunno}}{{no}}
fishPOSIXfish2005[28]{{yes}}GhostBSD{{dunno}}GPL}}{{yes}}Text-based CLI{{dunno}}{{yes}}{{dunno}}{{dunno}}Yes (arbitrary fds)}}Yes (through environment variables and via web interface through fish_config)}}Yes (/etc/fish/config.fish and ~/.config/fish/config.fish)}}Yes (Unix feature)}}Yes (~/.config/fish/fish_history*)}}{{dunno}}
ShellUsual environmentUsually invokedIntroducedPlatform-independentDefault login shell inDefault script shell inLicenseSource code availabilityUser interfaceMouse supportUnicode supportISO 8601 supportConsole redirectionStream redirectionConfigurabilityStartup/shutdown scriptsBatch scriptsLoggingavailable as statically linked, independent single file executable

Interactive features

ShellCommand
name
completion
Path
completion
Command
argument
completion
Wildcard
completion
Command
history
Mandatory
argument
prompt
Automatic
suggestions
Syntax
highlighting
Directory history, stack or similar featuresImplicit
directory
change
Auto­correctionIntegrated
environment
SnippetsValue
prompt
Menu/options
prompt
Progress
indicator
Context
sensitive
help
Command
builder
Thompson shell{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
Bourne shell 1977 version{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
Bourne shell current version{{no}}{{yes}}[29]{{no}}{{no}}{{yes}}[29]{{no}}{{no}}{{no}}{{yes}} (CDPATH, pushd, popd, dirs), CDPATH since SVr4{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
POSIX shell{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}Yes (CDPATH)}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
bash (v4.0){{yes}}{{yes}}when defined}}{{yes}}[30]{{yes}}{{no}}{{no}}{{no}}Yes (CDPATH, pushd, popd)}}optional}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}
csh{{yes}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}Yes (cdpath, pushd, popd)}}optional}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
tcsh{{yes}}{{yes}}when defined}}{{no}}{{yes}}{{no}}{{no}}{{no}}Yes (cdpath, pushd, popd)}}optional}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
Hamilton C shell{{yes}}{{yes}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}Yes (cdpath, pushd, popd)}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
Scsh{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
ksh (ksh93t+)Yes (extendable)}}Yes (extendable)}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}Yes (cdpath builtin, pushd, popd implemented as functions)}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}
pdksh{{yes}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}
zsh{{yes}}{{yes}}when defined}}{{yes}}[31]{{yes}}{{no}}Yes (via predict-on or user-defined[32])}}Third-party extension}}[33]{{yes}}optional}}{{yes}}{{no}}when defined (as ZLE widgets)}}{{yes}}{{yes}}{{no}}{{yes}}{{no}}
ash{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}
CCP{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
COMMAND.COM{{no}}{{no}}{{no}}{{no}}{{no}}[34][35]{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}} (only via external CHOICE command, in DR-DOS also via SWITCH / DRSWITCH internal commands){{no}}{{no}}{{no}}
OS/2
CMD.EXE
{{yes}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
Windows
CMD.EXE
partial}}partial}}{{no}}{{no}}Yes (F8)}}{{no}}{{no}}{{no}}Yes (PUSHD, POPD)}}{{no}}{{no}}{{no}}{{no}}{{yes}} (via SET /P command){{no}}{{no}}{{no}}{{no}}
4DOS{{yes}}{{yes}}{{yes}}{{yes}}{{yes}}[36][37]{{no}}{{no}}{{no}}(via popup, extended directory searches, CDPATH, PUSHD, POPD, DIRHISTORY, DIRS, CDD, CD - commands and %@DIRSTACK[] function)}}{{yes}}{{no}}{{yes}}{{no}}{{yes}} (via INPUT, INKEY and ESET commands){{yes}} (via @SELECT[] function, and indirectly via a combination of INKEY, INPUT, SWITCH commands){{no}}{{yes}}{{no}} (except for OPTION command for INI file directives)
4OS2????{{yes}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}?{{no}}??{{no}}{{yes}}{{no}}
TCC (formerly 4NT){{yes}}{{yes}}{{yes}}{{yes}}{{yes}}{{no}}{{no}}{{yes}}(via popup, extended directory searches, CDPATH, PUSHD, POPD, DIRHISTORY, DIRS, CDD, CD - commands and %@DIRSTACK[] function)}}{{yes}}{{no}}{{yes}}{{no}}{{yes}} (via INPUT, INKEY, ESET and SET /P commands){{yes}} (via @SELECT[] function, and indirectly via a combination of INKEY, INPUT, SWITCH commands)[38]{{no}}{{yes}}{{no}}
PowerShell{{yes}}{{yes}}{{yes}}{{yes}}Yes (F8)}}{{yes}}{{yes2}}Yes, in ISE[41]{{yes2}}Yes, in ISE[41] and PSReadLine[39] module (included in v5.0[40])Yes; multiple stacks; multiple location types}}[41]{{no}}{{yes2}}Yes, in PSReadLine[39] module{{yes2}}Yes, in ISE[42]{{yes2}}Yes, in ISE[42]{{yes}}{{yes}}[43]{{yes}}[44]{{yes2}}Yes, in ISE[42]popup window}}[45]
rc{{yes}}[46]{{yes}}[46]{{no}}{{no}}{{yes}}[46]{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}?{{no}}{{no}}{{no}}{{no}}
BeanShell{{yes}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
VMS DCLMinimum uniqueness scheme}}{{no}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}
fish{{yes}}{{yes}}when defined or parsable in man pages}}[47]{{yes}}[47]{{yes}}{{no}}{{yes}}{{yes}}{{yes}}{{yes}}{{yes}}{{yes}}[48]{{no}}{{yes}}(via fish_config command)}}{{no}}{{no}}{{no}}
ShellCommand
name
completion
Path
completion
Command
argument
completion
Wildcard
completion
Command
history
Mandatory
argument
prompt
Automatic
suggestions
Syntax
highlighting
Directory history, stack or similar featuresImplicit
directory
change
Auto­correctionIntegrated
environment
SnippetsValue
prompt
Menu/options
prompt
Progress
indicator
Context
sensitive
help
Command
builder

Background execution

Background execution allows a shell to run a command in background. POSIX shells and other Unix shells allow background execution by using the & character and the end of command, and in PowerShell you can use Start-Process or Start-Job commands.

Completions

{{main article|Command-line completion}}

Completion features assist the user in typing commands at the command line, by looking for and suggesting matching words for incomplete ones. Completion is generally requested by pressing the completion key (often the {{keypress|TAB}} key).

Command name completion is the completion of the name of a command. In most shells, a command can be a program in the command path (usually $PATH), a builtin command, a function or alias.

Path completion is the completion of the path to a file, relative or absolute.

Wildcard completion is a generalization of path completion, where an expression matches any number of files, using any supported syntax for file matching.

Variable completion is the completion of the name of a variable name (environment variable or shell variable).

Bash, zsh, and fish have completion for all variable names. PowerShell has completions for environment variable names, shell variable names and — from within user-defined functions — parameter names.

Command argument completion is the completion of a specific command's arguments. There are two types of arguments, named and positional: Named arguments, often called options, are identified by their name or letter preceding a value, whereas positional arguments consist only of the value. Some shells allow completion of argument names, but few support completing values.

Bash, zsh and fish offer parameter name completion through a definition external to the command, distributed in a separate completion definition file. For command parameter name/value completions, these shells assume path/filename completion if no completion is defined for the command. Completion can be set up to suggest completions by calling a shell function.[49] The fish shell additionally supports parsing of man pages to extract parameter information that can be used to improve completions/suggestions. In PowerShell, all types of commands (cmdlets, functions, script files) inherently expose data about the names, types and valid value ranges/lists for each argument. This metadata is used by PowerShell to automatically support argument name and value completion for built-in commands/functions, user-defined commands/functions as well as for script files. Individual cmdlets can also define dynamic completion of argument values where the completion values are computed dynamically on the running system.

Command history

{{main article|Command history}}

A user of a shell may find that he/she is typing something similar to what the user typed before. If the shell supports command history the user can call

the previous command into the line editor and edit it before issuing it again.

Shells that support completion may also be able to directly complete the command from the command history given a partial/initial part of the previous command.

Most modern shells support command history. Shells which support command history in general also support completion from history rather than just recalling

commands from the history. In addition to the plain command text, PowerShell also records execution start- and end time and execution status in the command history.

Mandatory argument prompt

{{further|Named parameter#Optional_parameters}}

Mandatory arguments/parameters are arguments/parameters which must be assigned a value upon invocation of the command, function or script file. A shell that can determine ahead

of invocation that there are missing mandatory values, can assist the interactive user by prompting for those values instead of letting the command fail.

Having the shell prompt for missing values will allow the author of a script, command or function to mark a parameter as mandatory instead of creating script code to either

prompt for the missing values (after determining that it is being run interactively) or fail with a message.

PowerShell allows commands, functions and scripts to define arguments/parameters as mandatory. The shell determines prior to invocation if there is any

mandatory arguments/parameters which have not been bound, and will then prompt the user for the value(s) before actual invocation.

[50]

Automatic suggestions

{{main article|Autocomplete}}

With automatic suggestions the shell monitors while the interactive user is typing and displays context-relevant suggestions without interrupting the typing instead of the user explicitly requesting completion.

The PowerShell Integrated Scripting Environment use the discoverable metadata to provide "intellisense" - i.e. suggestions that automatically pops up as the user types, in addition to when the user explicitly requests completion lists by pressing e.g. {{keypress|tab}}

{{further|Intellisense}}

Directory history, stack or similar features

A shell may record the locations the user has used as current locations and allow fast switching to any location/directory in the history.

One of the uses of the zsh directory stack is to record a directory history. In particular, the AUTO_PUSHD option and advanced cd arguments and completion are used for this purpose.

PowerShell allows multiple named stacks to be used. Locations (directories) can be pushed onto/popped from the current stack or a named stack. Any stack can become the current (default) stack. Unlike most other shells, PowerShell's location concept allow location stacks to hold file system locations as well as other location types like e.g. Active Directory organizational units/groups, SQL Server databases/tables/objects, Internet Information Server applications/sites/virtual directories.

4DOS and Take Command Console record history of current directories and allows the user to switch to a directory in the history using a popup a window.

Implicit directory change

A directory name can be used directly as a command which implicitly changes the current location to the directory.

Autocorrection

When a command line does not match a command or arguments directly, spell checking can automatically correct common typing mistakes (such as case sensitivity, missing letters). There are two approaches to this; the shell can either suggest probable corrections upon command invocation, or this can happen earlier as part of a completion or autosuggestion.

The tcsh and zsh shells feature optional spell checking/correction, upon command invocation.

Fish does the autocorrection upon completion and autosuggestion. The feature is therefore not in the way when typing out the whole command and pressing enter, whereas extensive use of the tab and right-arrow keys makes the shell mostly case insensitive.

The PSReadLine[39] PowerShell module (which is shipped with version 5.0) provides the option to specify a CommandValidationHandler ScriptBlock which runs before submitting the command. This allows for custom correcting of commonly mistyped commands, and verification before actually running the command.

Integrated environment

{{main article|Integrated development environment}}{{see also|Integrated applications environment|File manager}}

An integrated environment is the integration of the command-line interface with editors (typically multiple documents), help system and possibly debugging and other tools.

Take Command Console (TCC) comes with an integrated environment with command line pane, file explorer, editor, batch debugger and more.[51]PowerShell ISE includes a command line pane with support for integrated command line, copy-paste, multiple document editors, source-level debugging, help pane, command explorer pane and scripting interface allowing scripts/modules to manipulate menus, add-ons etc. The ISE (menus, windows, shortcuts, addons) are customizable through scripts.[52]

Snippets

{{main article|Snippet (programming)}}

Snippets are small regions of reusable script code. Snippets are often used to save keystrokes, or to assist the user with common scripting patterns. Many text editors support snippets for scripting either as built-in functionality or through plugins.

PowerShell supports snippets in the Integrated Scripting Environment (ISE) using {{keypress|Ctrl|J}}.[53]

Value prompt

A shell script can prompt the interactive user for a value.

Menu/options selector

A shell script can present the interactive user with a list of choices.

Progress indicator

A shell script (or job) can report progress of long running tasks to the interactive user.

Unix/Linux systems may offer other tools support using progress indicators from scripts or as standalone-commands, such as the program "pv".[54] These are not integrated features of the shells, however.

PowerShell has a built-in command and API functions (to be used when authoring commands) for writing/updating a progress bar. Progress bar messages are sent separates from regular command output

and the progress bar is always displayed at the ultimate interactive users console regardless of whether the progress messages originates from an interactive script, from a background job or from a remote session.

Interactive table

Output from a command execution can be displayed in a table/grid which can be interactively sorted and filtered and/or otherwise manipulated after command execution ends.

PowerShell Out-GridView cmdlet displays data in an interactive window with interactive sorting and filtering.

Syntax highlighting

{{main article|Syntax highlighting}}

An independent project offers syntax highlighting as an add-on to the Z Shell (zsh).[55] This is not part of the shell, however.

PowerShell provides customizable syntax highlighting on the command line through the PSReadLine[39] module. This module can be used with PowerShell v3.0+, and it's included with v5.0. Additionally, it is loaded by default in the command line host "powershell.exe" in v5.0. The PowerShell ISE also includes syntax highlighting on the command line as well as in the script pane.[52]

Take Command Console (TCC) offers syntax highlighting in the integrated environment.

Context sensitive help

{{main article|Context-sensitive help}}

4DOS, 4OS2, 4NT / Take Command Console and PowerShell (in PowerShell ISE) looks up context-sensitive help information when {{keypress|F1}} is pressed.

Zsh provides various forms of configurable context-sensitive help as part of its run-help widget, _complete_help command, or in the completion of options for some commands.

Command builder

A command builder is a guided dialog which assists the user in filling in a command. PowerShell has a command builder which is available in PowerShell ISE or which can be displayed separately through the Show-Command cmdlet.[56]

Programming features

ShellFunctionsException handlingSearch & replace on variable substi­tutionsArith­meticFloating pointMath function libraryLinear arrays or listsAssoc­iative arraysLambda functionseval func­tionPseudo­random number generationBytecode
Bourne shell 1977 version{{no}}Yes (via trap)}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}
Bourne shell current versionYes since SVR2}}Yes (via trap)}}{{no}}{{yes}}[29]{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}
POSIX shell{{yes}}Yes (via trap)}}{{no}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}
bash (v4.0){{yes}}Yes (via trap)}}Yes (via ${//} syntax)}}{{yes}}{{no}}{{no}}{{yes}}{{yes}}{{no}}{{yes}}Yes ($RANDOM) }}{{no}}
csh{{no}}{{no}}Yes (via $var:s/// syntax)}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}
tcsh{{no}}{{no}}Yes (via $var:s/// syntax)}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}
Hamilton C shell{{yes}}{{no}}Yes (via $var:s/// syntax)}}{{yes}}{{yes}}{{yes}}{{yes}}{{no}}{{no}}{{yes}}Yes (random utility)}}{{no}}
Scsh{{yes}}?Yes (via string functions and regular expressions)}}???{{yes}}?{{yes}}{{yes}}Yes (random-integer, random-real)}}Yes (compiler is Scheme48 virtual machine, via scshvm)}}
ksh (ksh93t+){{yes}}Yes (via trap)}}Yes (via ${//} syntax and builtin commands)}}{{yes}}{{yes}}{{no}}{{yes}}{{yes}}{{no}}{{yes}}Yes ($RANDOM)}}Yes (compiler is called shcomp)}}
pdksh{{yes}}Yes (via trap)}}{{no}}{{yes}}{{no}}{{no}}{{yes}}{{no}}{{no}}{{yes}}Yes ($RANDOM)}}{{no}}
zsh{{yes}}{{yes}}Yes (via ${:s//} and ${//} syntax)}}{{yes}}{{yes}}Yes (zsh/mathfunc module)}}{{yes}}{{yes}}{{no}}{{yes}}Yes ($RANDOM)}}Yes (built-in zcompile command)}}
ash{{yes}}{{yes}} (via trap){{no}}Yes (since 1992)[57]}}{{no}}{{no}}{{no}}{{no}}{{no}}{{yes}}{{no}}{{no}}
CCP{{no}}?{{no}}{{no}}??{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
COMMAND.COM{{no}}{{partial}} (only Auto-fail (via COMMAND /F (or /N in some versions of DR-DOS)){{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
OS/2 CMD.EXE{{no}}{{no}}{{no}}?{{no}}{{no}}?{{no}}{{no}}{{no}}{{no}}{{no}}
Windows CMD.EXEYes (via CALL :label)}}{{no}}Yes (via SET %varname:expression syntax)}}Yes (via SET /A)[58]}}{{no}}{{no}}Yes (via SET[59])}}{{no}}{{no}}{{no}}Yes (%random%)}}{{no}}
4DOS{{yes}}Yes (via ON command, optional Auto-fail via 4DOS /F)}}Yes (via %@Replace[…] function)}}Yes (via SET /A)}}??Yes (via ranges, include lists, @file lists and FOR command)}}{{no}}{{no}}{{yes}}Yes (%@Random[…] function)}}Yes (via BATCOMP command)}}
4OS2????????{{no}}{{yes}}{{yes}} (%@Random[…] function)?
TCC (formerly 4NT){{yes}}Yes (via ON and various …MONITOR commands)}}Yes (via %@Replace[…] function)}}Yes (via SET /A)}}??Yes (via ranges, include lists, @file lists and FOR command)}}?{{no}}{{yes}}{{yes}} (%@Random[…] function){{yes}} (via BATCOMP command)
PowerShell{{yes}}{{yes}} (Try-Catch-Finally)Yes (-replace operator)}}{{yes}}{{yes}}[Math] class}}[60]{{yes}}{{yes}}{{yes}}{{yes}}{{yes}}Yes, automatic}}
rc{{yes}}{{yes}}{{no}}???{{yes}}?{{no}}{{yes}}{{no}}{{no}}
BeanShell{{yes}}{{yes}}?{{yes}}??{{yes}}{{yes}}{{no}}{{yes}}{{yes}}{{yes}}
VMS DCL{{yes}}{{yes}}{{no}}{{yes}}{{no}}yes, for compiled programs}}{{yes}}{{no}}{{no}}{{no}}{{no}}{{no}}
fish{{yes}}Yes (via trap)}}{{no}}Optional {{ref|fishmath|fish math}}}}Optional {{ref|fishmath|fish math}}}}Optional {{ref|fishmath|fish math}}}}{{yes}}{{no}}{{no}}{{yes}}Yes (random)}}{{no}}
Notes

{{note|fishmath|fish math}}:The bundled math function requires bc.

String processing and filename matching

ShellString processingAlternation (Brace expansion)Pattern matching (regular expressions built-in)Pattern matching (filename globbing)Globbing qualifiers (filename generation based on file attributes)Recursive globbing (generating files from any level of subdirectories)
Bourne shell 1977 version?{{no}}{{no}}Yes (*, ?, […])}}{{no}}{{no}}
Bourne shell recent version{{partial}} (prefix and suffix stripping in variable expansion){{no}}{{no}}Yes (*, ?, […])}}{{no}}{{no}}
POSIX shell{{partial}} (prefix and suffix stripping in variable expansion){{no}}{{no}}Yes (*, ?, […])}}{{no}}{{no}}
bash (v4.0){{partial}} (prefix and suffix stripping in variable expansion){{yes}}{{yes}}Yes (*, ?, […], {…})}}{{no}}{{yes}} (**/...)
cshYes (:s and other editing operators)}}{{yes}}{{no}}{{yes}}{{no}}{{no}}
tcshYes (:s and other editing operators)}}{{yes}}{{yes}}{{yes}}{{no}}{{no}}
Hamilton C shellYes (:s and other editing operators + substr, strlen, strindex, printf, reverse, upper, lower, concat and other builtin functions)}}{{yes}}{{no}}{{yes}}{{no}}Yes (via indefinite directory "..." wildcard[61])}}
Scsh??{{yes}}{{yes}}{{no}}{{no}}
ksh (ksh93t+){{partial}} (prefix, suffix stripping and string replacement in variable expansion){{yes}}[62]{{yes}}Yes (*, ?, […])}}{{no}}{{yes}} (with set -G, no following of symlinks)
pdksh?{{yes}}[62]{{no}}{{yes}}{{no}}{{no}}
zsh{{yes}} (through variable processing: e.g. substring extraction, various transformations via parameter expansion){{yes}}{{yes}}Yes (*, ?, […], extended globbing[63])}}{{yes}}{{yes}} (**/... or ***/... to follow symlinks)
ash??{{no}}{{yes}}{{no}}{{no}}
CCP{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
COMMAND.COM{{no}}{{no}}{{no}}Yes (*, ?)}}{{no}}{{no}}
OS/2 CMD.EXE{{no}}{{no}}{{no}}Yes (*, ?)}}{{partial}} (only in DIR /A:… command){{no}}
Windows CMD.EXE{{partial}} (only through FOR /F and SET /A){{no}}No[64]}}Yes (*, ?)}}{{partial}} (only in DIR /A:… command){{yes}} (via FOR /R command, or, where available, indirectly via /S subdir option)
4DOS{{yes}} (through variable functions %@…[], extended environment variable processing, various string commands and FOR /F and SET /A){{no}}{{no}}Yes (*, ?, […], extended wildcards, SELECT popup command)}}{{yes}} (via /A:… attribute and /I"…" description options and /[S…] size, /[T…] time, /[D…] date, and /[!…] file exclusion ranges){{yes}} (via FOR /R command, or indirectly via GLOBAL command or, where available, /S subdir option)
4OS2?{{no}}{{no}}???
TCC (formerly 4NT){{yes}} (through variable functions %@…[], extended environment variable processing, various string commands and FOR /F and SET /A){{no}}{{yes}}Yes (*, ?, […], extended wildcards, SELECT popup command)}}{{yes}} (via /A:… attribute and /I"…" description options and /[S…] size, /[T…] time, /[D…] date, /[O…] owner, and /[!…] file exclusion ranges){{yes}} (via FOR /R command, or indirectly via GLOBAL command or, where available, /S subdir option)
PowerShellYes (Concat/Substring/Insert/Remove/Replace, ToLower/ToUpper, Trim/TrimStart/TrimEnd, Compare, Contains/StartsWith/EndWith, Format, IndexOf/LastIndexOf, Pad/PadLeft/PadRight, Split/Join, regular expression functions and other .NET string functions)}}{{no}}Yes (full regex support)[65]}}Yes (*, ?, […])}}??
rc??{{no}}{{yes}}{{no}}{{no}}
BeanShell??{{yes}}???
VMS DCL{{yes}}{{no}}{{no}}{{yes}}{{no}}{{yes}} (via [SUBDIR…])
fish{{no}}Yes}}{{no}}Yes (*, ?, {…})}}{{no}}{{yes}} (**/...)

Inter-process communication

ShellPipesCommand substitutionProcess substitutionSubshellsTCP/UDP connections as streamsKeystroke stacking
Bourne shellbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
POSIX shellbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
bash (v4.0)bytes concurrent}}{{yes}}Yes (if system supports /dev/fd/ or named pipes)}}{{yes}}Yes (client only)}}{{N/A}}[66]
cshbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
tcshbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
Hamilton C shellbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}?
Scshtext}}???{{yes}}{{N/A}}[66]
ksh (ksh93t+)bytes (may contain serialized objects if print -C is used) concurrent}}Yes ($(…) and ${…;})}}Yes (if system supports /dev/fd/)}}{{yes}}Yes (and SCTP support, client only)}}{{N/A}}[66]
pdkshbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
zshbytes concurrent}}{{yes}}{{yes}}{{yes}}Yes (client and server, but only TCP)}}{{N/A}}[66]
ashbytes concurrent}}{{yes}}{{no}}{{yes}}{{no}}{{N/A}}[66]
CCP{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
COMMAND.COMtext sequential temporary files}}{{no}}{{no}}{{partial}} (only under DR-DOS multitasker via COMMAND.COM /T){{no}}{{no}}
OS/2 CMD.EXEtext concurrent}}{{no}}{{no}}?{{no}}{{no}}
Windows CMD.EXEtext concurrent}}Yes (via FOR /F command)}}{{no}}Yes (Backtick: ` in FOR /F usebackq)}}{{no}}{{no}}
4DOStext sequential temporary files}}Yes (via FOR /F command)}}?{{partial}} (via %@EXECSTR[] and %@EXEC[], or via SET /M, ESET /M and UNSET /M and %@MASTER[…]){{no}}{{yes}} (via KEYSTACK and KSTACK)[67]
4OS2text concurrent}}???{{no}}{{yes}} (via KEYSTACK)
TCC (formerly 4NT)text concurrent}}Yes (via FOR /F command)}}?{{partial}} (via %@EXECSTR[] and %@EXEC[]){{yes}} (via FTP, TFTP, FTPS, SFTP, HTTP, HTTPS and IFTP, client only){{yes}} (via KEYSTACK)
PowerShellobjects concurrent}}{{yes}}{{no}}{{yes}}{{yes}}?
rctext concurrent}}{{yes}}Yes (via: <{cmd} if system supports /dev/fd/)}}{{yes}}{{no}}?
BeanShellnot supported}}???{{yes}}?
VMS DCLtext (via PIPE command)}}{{yes}}{{no}}Yes (spawn)}}Yes (server TCP only)}}{{no}}
fishbytes concurrent}}{{yes}} (...)No (broken)[68]}}{{no}}{{no}}{{N/A}}[66]

Keystroke stacking

In anticipation of what a given running application may accept as keyboard input, the user of the shell instructs the shell to generate a sequence of simulated keystrokes, which the application will interpret as an keyboard input from an interactive user. By sending keystroke sequences the user may be able to direct the application to perform actions that would be impossible to achieve through input redirection or would otherwise require an interactive user. For example, if an application acts on keystrokes, which cannot be redirected, distinguishes between normal and extended keys, flushes the queue before accepting new input on startup or under certain conditions, or because it does not read through standard input at all. Keystroke stacking typically also provides means to control the timing of simulated keys being sent or to delay new keys until the queue was flushed etc. It also allows to simulate keys which are not present on a keyboard (because the corresponding keys do not physically exist or because a different keyboard layout is being used) and therefore would be impossible to type by a user.

Security features

{{importance section|date=July 2014}}
ShellSecure (password) promptEncrypted variables/ parametersFile/directory passwordsExecute permissionUntrusted script blockingRestricted shell subsetSafe data subset
Bourne shellvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
POSIX shellvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{no}}{{no}}
bash (v4.0)read -s}}{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
cshvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
tcshvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
Hamilton C shell{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
Scshvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{no}}{{no}}
ksh (ksh93t+)via stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
pdkshvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
zshread -s}}{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
ashvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}{{no}}
CCP{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
COMMAND.COM{{partial}} (only under DR-DOS, prompts for password if file/directory is protected){{no}}{{partial}} (only under DR-DOS via \\dirname;dirpwd\\filename;filepwd syntax)[71]{{partial}} (only under DR-DOS, if files are password-protected for read and/or execute permission)[72]{{no}}{{no}}{{no}}
OS/2 CMD.EXE{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
Windows CMD.EXE{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
4DOS{{yes}} (via INPUT /P or INKEY /P)[73]{{no}}{{partial}} (only under DR-DOS via \\dirname;;dirpwd\\filename;;filepwd syntax)[71]{{partial}} (only under DR-DOS, if files are password-protected for read and/or execute permission)[72]{{no}}{{no}}{{no}}
4OS2?{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
TCC (formerly 4NT){{yes}} (via INPUT /P, INKEY /P or QUERYBOX /P)[73]{{no}}{{no}}{{no}}{{no}}{{no}}{{no}}
PowerShell{{yes}}[74]{{yes}}{{no}}{{no}}[75]{{yes}}[76]{{yes}}[77]{{yes}}[78]
rcvia stty}}[69]{{no}}?{{N/A}}[70]{{no}}{{yes}}[79]{{no}}
BeanShell???????
VMS DCL{{yes}}{{no}}{{no}}{{yes}}{{no}}{{yes}}{{no}}
fishread -s}}{{no}}?{{N/A}}[70]{{no}}Yes (via fish -l)}}?

Secure prompt

Some shell scripts need to query the user for sensitive information such as passwords, private digital keys, PIN codes or other confidential information. Sensitive input should not be echoed back to the screen/input device where it could be gleaned by unauthorized persons. Plaintext memory representation of sensitive information should also be avoided as it could allow the information to be compromised, e.g., through swap files, core dumps etc.[80]

The shells bash, zsh and PowerShell offer this as a specific feature.[81][82] Shells which do not offer this as a specific feature may still be able to turn off echoing through some other means. Shells executing on a Unix/Linux operating system can use the stty external command to switch off/on echoing of input characters.[83] In addition to not echoing back the characters, PowerShell's -AsSecureString option also encrypts the input character-by-character during the input process, ensuring that the string is never represented unencrypted in memory where it could be compromised through memory dumps, scanning, transcription etc.

Encrypted variables/parameters

If a script reads a password into an environment variable it is in memory in plain text, and thus may be accessed via a core dump. It is also in the process environment, which may be accessible by other processes started by the script.[84]

PowerShell can work with encrypted string variables/parameters.[85] Encrypted variables ensure that values are not inadvertently disclosed through e.g. transcripts, echo'ing, logfiles, memory or crash dumps or even malicious memory scanning. PowerShell also supports saving of such encrypted strings in text files, protected by a key owned by the current user.

Execute permission

Some operating systems define an execute permission which can be granted to users/groups for a file.

On Unix systems, the execute permission controls access to invoking the file as a program, and applies both to executables and scripts.

As the permission is enforced in the program loader, no obligation is needed from the invoking program, nor the invoked program, in enforcing the execute permission{{Snd}} this also goes for shells and other interpreter programs.

The behaviour is mandated by the POSIX C library that is used for interfacing with the kernel. POSIX specifies that the exec family of functions shall fail with EACCESS (permission denied) if the file denies execution permission (see {{man|sh|execve|SUS}}).

The execute permission only applies when the script is run directly. If a script is invoked as an argument to the interpreting shell, it will be executed regardless of whether the user holds the execute permission for that script.

Although Windows also specifies an execute permission, none of the Windows-specific shells block script execution if the permission has not been granted.

Untrusted script blocking

Some shells will block scripts determined to be untrustworthy, or refuse to run scripts if mandated by a system administrator.

Script origin execution restriction

PowerShell can be set to block execution of scripts which has been marked as obtained from an unknown/untrusted origin (e.g. the Internet).[86] Internet facing applications such as web browsers, IM clients, mail readers etc. mark files downloaded from the internet with the origin zone in an alternate data stream which is understood by PowerShell.

Signed script restriction

Script/code signing policies can be used to ensure that an operations department only run approved scripts/code which have been reviewed and signed by a trusted reviewer/approver. Signing regimes also protects against tampering. If a script is sent from vendor to a client, the client can use signing to ensure that the script has not been tampered with during transit and that the script indeed originates from the vendor and not an attacker trying to social engineer an operator into running an attack script.

PowerShell can be set to allow execution of otherwise blocked scripts (e.g. originating from an untrusted zone) if the script has been digitally signed using a trusted digital certificate.[87][88][89]

Multilevel execution policies

A company may want to enforce execution restriction globally within the company and/or certain parts of the company. It may want to set a policy for running signed scripts but allow certain parts of the company to set their own policies for zoned restrictions.

PowerShell allows script blocking policies to be enforced at multiple levels: Local machine, current user etc. A higher level policy overrides a lower level policy, e.g. if a policy is defined for the local machine it is in place for all users of the local machine, only if it is left undefined at the higher level can it be defined for the lower levels.

Restricted shell subset

Several shells can be started or be configured to start in a mode where only a limited set of commands and actions is available to the user. While not a security boundary (the command accessing a resource is blocked rather than the resource) this is nevertheless typically used to restrict users' actions before logging in.

A restricted mode is part of the POSIX specification for shells, and most of the Linux/Unix shells support such a mode where several of the built-in commands are disabled and only external commands from a certain directory can be invoked.[90][91]

PowerShell supports restricted modes through session configuration files or session configurations. A session configuration file can define visible (available) cmdlets, aliases, functions, path providers and more.[92]

Safe data subset

Scripts that invoke other scripts can be a security risk as they can potentially execute foreign code in the context of the user who launched the initial script. Scripts will usually be designed to exclusively include scripts from known safe locations; but in some instances, e.g. when offering the user a way to configure the environment or loading localized messages, the script may need to include other scripts/files.[93] One way to address this risk is for the shell to offer a safe subset of commands which can be executed by an included script.

PowerShell [https://technet.microsoft.com/en-us/library/hh848302.aspx data sections] can contain constants and expressions using a restricted subset of operators and commands.[94] PowerShell data sections are used when e.g. localized strings needs to be read from an external source while protecting against unwanted side effects.

References

1. ^A platform independent version based on the historical UNIX V7 original source code is available from Geoff Collyer
2. ^The historic UNIX V7 version is available under a BSD-style license through the Unix Heritage Society and others.
3. ^A [https://sourceforge.net/projects/schilytools/files/ platform independent version] based on the SVr4/Solaris source code is available from Jörg Schilling
4. ^{{citation |url=https://www.freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/index.html |chapter-url=https://www.freebsd.org/doc/en_US.ISO8859-1/articles/linux-users/shells.html |title=FreeBSD Quickstart Guide for Linux Users |chapter=Chapter 2. Default Shell |author-first=John |author-last=Ferrell |publisher=The FreeBSD Documentation Project |access-date=2015-07-24}}
5. ^{{cite web |url=https://sourceforge.net/p/schillix-on/schillix-on/ci/default/tree/usr/src/cmd/sh/ |title=SchilliX-ON / SchilliX-ON Mercurial / [b1d9a2] /usr/src/cmd/sh |publisher=Sourceforge.net |access-date=2015-07-02}}
6. ^Since mid 1990s
7. ^if compiled with -DACCT
8. ^{{cite book |author=IEEE and The Open Group |title=IEEE 1003.1 Standard for Information Technology – Portable Operating System Interface (POSIX): Shell and Utilities, Issue 7 |date=2008}}
9. ^As part of IEEE Std.1003.2-1992 (POSIX.2); integrated into IEEE Std.1003.1 with the 2001 revision.
10. ^{{Cite newsgroup|title=Bash is in beta release!|author-first=Brian|author-last=Fox|editor-first=Leonard H.|editor-last=Tower Jr.|date=1989-06-07|newsgroup=gnu.announce|message-id=8906080235.AA01983@wheat-chex.ai.mit.edu|url=https://groups.google.com/group/gnu.announce/msg/a509f48ffb298c35?hl=en|access-date=2010-10-28}}
11. ^{{citation |url=http://tldp.org/LDP/abs/html/bashver4.html |title=Advanced Bash-Scripting Guide |chapter=Chapter 37.3.2. Bash, version 4.2 |author-first=Mendel |author-last=Cooper |publisher=The Linux Documentation Project |access-date=2015-04-30}}, "Bash now supports the \\u and \\U Unicode escape."
12. ^{{Cite newsgroup|author-first=Ken|author-last=Greer|title=C shell with command and filename recognition/completion|date=1983-10-03|newsgroup=net.sources|url=https://groups.google.com/group/net.sources/msg/7073bf41cc5da330?hl=en|access-date=2010-12-29}}
13. ^{{cite journal|author-last=Sussman|author-first=Ann|title=Hamilton C Shell Speeds Development Of OS/2 Applications|journal=PC Week|date=1988-12-26|issue=Dec 26 1988 - Jan 2 1989|page=37|url=https://hamiltonlabs.com/archives/Hamilton-C-Shell-Speeds-Development-of-OS-2-Applications-Ann-Sussman-PC-Week-Dec-26-1988.pdf|access-date=2010-11-22}}
14. ^{{Cite newsgroup|author-first=Ron|author-last=Gomes|title=Toronto USENIX Conference Schedule (tentative)|date=1983-06-09|newsgroup=net.usenix|url=https://groups.google.com/group/net.usenix/msg/fa6e1f7de3b63bba?hl=en|access-date=2010-12-29}}
15. ^{{Cite newsgroup|author-first=Guy|author-last=Harris|title=csh question|date=1983-10-10|newsgroup=net.flame|url=https://groups.google.com/group/net.flame/msg/4f868085b65af530?hl=en|access-date=2010-12-29}}
16. ^ksh93(1) man page
17. ^Default shell in OpenBSD is ksh (pdksh).
18. ^The zsh command line editor is fully configurable and can allow mouse support in various ways such as with Stéphane Chazelas's mouse.zsh.
19. ^zsh(1) man page and subpages
20. ^zshbuiltins(1) man page
21. ^{{cite web |url=https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=782228 |title=#782228 - busybox sh doesn't support multibyte characters in string handling - Debian Bug report logs |publisher=Bugs.debian.org |date=2015-04-09 |access-date=2015-07-02}}
22. ^MS-DOS and Windows component – covered by a valid license for MS-DOS or Microsoft Windows
23. ^OS/2 component – covered by a valid license for OS/2
24. ^Command extensions enabled, or "CMD /X".
25. ^Windows component – covered by a valid license for Microsoft Windows
26. ^{{cite web|url=http://h71000.www7.hp.com/doc/732final/9996/9996pro_contents.html|title=HP OpenVMS DCL Dictionary|access-date=2009-03-23}}
27. ^Windows PowerShell is installed with Windows 7, however, it is an optional download for users of Windows Vista or Windows XP.
28. ^{{cite web|title=Fish - The friendly interactive shell|author-first=Axel|author-last=Liljencrantz|date=2005-05-17|url=https://lwn.net/Articles/136232/|access-date=2013-04-08}}
29. ^current versions from Jörg Schilling
30. ^Alt-Shift-8 or Alt-* will expand to the full matching list of filenames
31. ^{{cite web |title=[Z Shell] Completion System |url=http://zsh.sourceforge.net/Doc/Release/Completion-System.html |publisher=Zsh.sourceforge.net |access-date=2015-02-24}}
32. ^e.g. via 3rd party such as [https://github.com/tarruda/zsh-autosuggestions zsh-autosuggestions]
33. ^zsh does not feature syntax highlighting, but a 3rd party project exists which offers this capability as an add-on: [https://github.com/zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting]
34. ^Available through the DOSKEY add-on
35. ^Available in DR-DOS through HISTORY
36. ^Alternatively available through the DOSKEY add-on as well
37. ^Alternatively available in DR-DOS through HISTORY as well
38. ^TCC has special prompt functions for Yes, No, Cancel, Close, Retry.
39. ^{{cite web|url=https://github.com/lzybkr/PSReadLine]|title=PSReadLine: A bash inspired readline implementation for PowerShell|first=Jason|last=Shirk|date=15 February 2018|publisher=|via=GitHub}}
40. ^{{Cite web |url=https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/core-modules/windows-powershell-5.0 |title=Archived copy |access-date=8 September 2016 |archive-url=https://web.archive.org/web/20160917093943/https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/core-modules/windows-powershell-5.0 |archive-date=17 September 2016 |dead-url=yes |df=dmy-all }}
41. ^[https://technet.microsoft.com/en-us/library/hh849855.aspx Push-Location] (with alias pushd) and [https://technet.microsoft.com/en-us/library/hh849842.aspx Pop-Location] (with alias popd) allows multiple location types (directories of file systems, organizational units of Active Directory, nodes of Windows Registry etc) to be pushed onto and popped from location stacks.
42. ^{{cite web |title=Windows PowerShell Integrated Scripting Environment (ISE) |url=https://technet.microsoft.com/en-us/library/dd819514.aspx?f=255&MSPPError=-2147217396 |publisher=Microsoft Technet |access-date=2015-09-12}}
43. ^The [https://technet.microsoft.com/en-us/library/ff730939.aspx $host.ui.PromptForChoice] function allows for a menu-style prompt for choices. The prompt works from background jobs as well as from remote sessions, displaying the menu prompt on the console of the controlling session.
44. ^The [https://technet.microsoft.com/en-us/library/hh849902.aspx Write-Progress] cmdlet writes a progress bar which can indicate percentage, remaining seconds etc. The progress bar messages work from background jobs or remote sessions in addition to interactive scripts, i.e. the progress bar is displayed on the console of the controlling session, not as part of the regular output.
45. ^The [https://technet.microsoft.com/en-us/library/hh849915.aspx Show-Command] cmdlet inspects the command definition and opens an interactive windows with a named input field for each parameter/switch
46. ^Handled by rio, GNU readline, editline or vrl
47. ^{{cite web |url=http://fishshell.com/docs/current/index.html#completion |title=fish: Documentation |at=Section Tab completion |access-date=2016-01-10}}
48. ^The fish shell is an interactive character based input/output surface
49. ^{{cite web |url=http://zsh.sourceforge.net/Doc/Release/Completion-System.html |title=zsh: 20. Completion System |publisher=Zsh.sourceforge.net |date=2013-03-06 |accessdate=2013-08-18}}
50. ^{{cite web |title=Use PowerShell to Make Mandatory Parameters |url=http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/22/use-powershell-to-make-mandatory-parameters.aspx |publisher=Blogs.technet.com |access-date=2015-02-24}}
51. ^{{cite web |url=http://jpsoft.com/take-command-windows-scripting.html |title=#1 Windows Command Line Replacement - Windows CMD Command Prompt Commands |publisher=JP Software |access-date=2013-08-18}}
52. ^{{cite web |url=https://technet.microsoft.com/en-us/library/hh849182.aspx |title=Windows PowerShell 3.0 Integrated Scripting Environment (ISE) |publisher=Technet.microsoft.com |access-date=2013-08-18}}
53. ^{{cite web |url=http://www.powershellmagazine.com/2011/09/28/powershell-v3-ise-and-ise-scripting-model-changes-improvements/ |title=PowerShell v3 ISE and ISE scripting model changes & improvements |publisher=PowerShell Magazine |date=2011-09-28 |access-date=2013-08-18}}
54. ^{{cite web |url=http://linux.die.net/man/1/pv |title=pv(1): monitor progress of data through pipe - Linux man page |publisher=Linux.die.net |access-date=2015-02-24}}
55. ^{{cite web |url=https://github.com/zsh-users/zsh-syntax-highlighting |title=zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh |website=GitHub |access-date=2013-08-18}}
56. ^{{cite web |url=https://technet.microsoft.com/en-us/library/hh849915.aspx |title=Show-Command |publisher=Technet.microsoft.com |access-date=2013-08-18}}
57. ^Ash Variants
58. ^{{cite web |url=https://ss64.com/nt/set.html |title=Set - Environment Variable | Windows CMD |publisher=SS64.com |access-date=2015-02-24}}
59. ^{{cite web |url=https://stackoverflow.com/questions/18462169/how-to-loop-through-array-in-batch |title=How to loop through array in batch? |publisher=Stack Overflow |access-date=2015-02-24}}
60. ^The .NET System.Math class defines mathematical functions that can be used through the shortcut [Math], e.g. [Math]::Sin for the sinus function.[https://technet.microsoft.com/en-us/library/dd347632.aspx]
61. ^{{Citation|url=https://hamiltonlabs.com/UserGuide/31-Wildcarding.htm|title=Hamilton C shell Language reference: Wildcarding and pattern matching|access-date=2013-10-29|publisher=Hamilton Laboratories|quote=... Indefinite Directory: match any number of directory levels – zero or more – whatever it takes to make the rest of the pattern match.}}
62. ^{{cite book|author-last1=Seebach|author-first1=Peter|title=Beginning Portable Shell Scripting: From Novice to Professional|url=https://books.google.com/books?id=53zaxy423xcC|series=Expert's voice in open source|publisher=Apress|publication-date=2008|page=149|isbn=9781430210436|access-date=2014-09-17|quote=Brace expansion is available in ksh93, pdksh, bash, and zsh.}}
63. ^Zsh offers a variety of globbing options.
64. ^Not available as a shell built-in. External FINDSTR /R command is available in most Windows releases.
65. ^PowerShell leverages the full .NET regular expression engine which features named captures, zero-width lookahead/-behind, greedy/non-greedy, character classes, level counting etc.
66. ^10 xautomation and xdotool can be used to generate keystrokes under X Window System; or a program can be run in a pseudoterminal to be able to control it (as with the expect tool).
67. ^{{cite book |title=4DOS 8.00 online help |author-first1=Hardin |author-last1=Brothers |author-first2=Tom |author-last2=Rawson |author-first3=Rex C. |author-last3=Conn |author-first4=Matthias |author-last4=Paul |author-first5=Charles E. |author-last5=Dye |author-first6=Luchezar I. |author-last6=Georgiev |date=2002-02-27}}
68. ^{{cite web|url=https://github.com/fish-shell/fish-shell/issues/1040|title=find a way to make `psub --fifo` safe from deadlock · Issue #1040 · fish-shell/fish-shell|website=GitHub}}
69. ^The shell can use the stty utility to suppress echoing of typed characters to the screen. This requires multiple steps: 1. reading the current echo state, 2. switching echo off, 3. reading the input, 4. switching echo state back to the original state.
70. ^10 11 The execute permission is enforced by a separate program, the program loader, by refusing to invoke the interpreter (possibly a shell) specified by the script's hashbang. The interpreter does not enforce the execute permission if invoked directly as the program loader would, with the file as an argument; this only requires read permission, as does piping the file as input to the interpreter, in which case the interpreter cannot see the execute permission.
71. ^Under DR-DOS the password separator for file and directory passwords is a semicolon. This is also supported under 4DOS for as long as the command does not support include lists. Under 4DOS, the password separator must be doubled for all commands supporting include lists in order to distinguish passwords from include lists. Commands not supporting include lists accept both forms. DR-DOS 7.02 and higher optionally accept a doubled semicolon as well, so that doubled semicolons work under both COMMAND.COM and 4DOS regardless of the command executed.
72. ^DR-DOS supports file passwords for read/write/delete and optionally execute permissions. Files are not protected by default, but the system can be set up so that f.e. batch scripts require a password to read.
73. ^INPUT /P and INKEY /P echoes back asterisks for each typed character
74. ^Read-Host -AsSecureString reads a string of characters from the input device into an encrypted string, one character at a time thus ensuring that there is no memory image of the clear text which could be gleaned from scanning memory, or from crash dumps, memory dumps, paging files, log files or similar.
75. ^PowerShell script files (.ps1 files) are by default associated with the Notepad editor, not with the PowerShell execution engine. Invoking a .ps1 file will launch Notepad rather than executing the script.
76. ^{{cite web |url=https://technet.microsoft.com/en-us/library/hh847748.aspx |title=About Execution Policies |publisher=Technet.microsoft.com |access-date=2015-02-24}}
77. ^Startup scripts per computer/user can import modules and expose a subset the commands/functions available in the modules.
78. ^{{cite web |url=https://technet.microsoft.com/en-us/library/hh848302.aspx |title=About Data Sections |publisher=Technet.microsoft.com |access-date=2015-02-24}}
79. ^{{cite web |url=http://manpages.ubuntu.com/manpages/precise/man1/rc.1.html |title=Ubuntu Manpage: rc - shell |publisher=Manpages.ubuntu.com |date=2003-07-17 |access-date=2015-02-24}}
80. ^{{cite web |author-last=Provos |author-first=Niels |title=Encrypting Virtual Memory |url=http://www.openbsd.org/papers/swapencrypt.ps |publisher=Center for Information Technology Integration, University of Michigan |access-date=2012-12-20}}
81. ^{{cite web |url=https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html |title=bash - GNU Bourne-Again SHell |quote=read -s Silent mode. If input is coming from a terminal, characters are not echoed.}}
82. ^{{cite web |url=https://technet.microsoft.com/en-us/library/ee176935.aspx |title=Using the Read-Host Cmdlet |quote=By adding the -assecurestring parameter you can mask the data entered at the prompt}}
83. ^{{cite web |title=Linux / Unix Command: stty |url=http://linux.about.com/od/commands/l/blcmdl1_stty.htm |publisher=Linux.about.com |access-date=2015-02-24}}
84. ^{{cite book |author-last1=Albing |author-first1=Carl |title=Bash cookbook |year=2007 |publisher=O'Reilly Media |location=Sebastopol, California |isbn=978-0-596-52678-8 |edition=1st |author-last2=Vossen |author-first2=J. P. |author-last3=Newham |author-first3=Cameron |page=65 |chapter=3.8. Prompting for a Password |quote=Be aware that if you read a password into an environment variable it is in memory in plain text, and thus may be accessed via a core dump or /proc/core. It is also in the process environment, which may be accessible by other processes.}}
85. ^{{cite web |author-last=Holmes |author-first=Lee |title=SecureStrings in PowerShell |url=http://www.leeholmes.com/blog/2006/06/01/securestrings-in-powershell/ |access-date=2012-12-18}}
86. ^{{cite web |url=http://www.windowsecurity.com/articles/PowerShell-Security.html |title=PowerShell Security :: Windows OS Security :: Articles & Tutorials |publisher=WindowSecurity.com |access-date=2013-08-18}}
87. ^{{cite web |url=http://www.hanselman.com/blog/SigningPowerShellScripts.aspx |title=Signing PowerShell Scripts |publisher=Hanselman.com |access-date=2015-12-24}}
88. ^{{cite web |url=http://blogs.technet.com/b/heyscriptingguy/archive/2010/06/17/hey-scripting-guy-how-can-i-sign-windows-powershell-scripts-with-an-enterprise-windows-pki-part-2-of-2.aspx |title=Hey, Scripting Guy! How Can I Sign Windows PowerShell Scripts with an Enterprise Windows PKI? (Part 2 of 2) - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs |publisher=Blogs.technet.com |access-date=2013-08-18}}
89. ^{{cite web |url=https://technet.microsoft.com/en-us/library/ee176949.aspx |title=Running Windows PowerShell Scripts |publisher=Technet.microsoft.com |access-date=2013-08-18}}
90. ^{{cite web |url=http://pwet.fr/man/linux/commandes/posix/sh |title=man sh - shell, the standard command language interpreter / posix |language=French |publisher=Pwet.fr |access-date=2013-08-18}}
91. ^{{cite web |url=https://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html |title=Bash Reference Manual: The Restricted Shell |publisher=Gnu.org |date=2010-12-28 |access-date=2013-08-18}}
92. ^{{cite web |url=https://technet.microsoft.com/en-us/library/hh849712.aspx |title=New-PSSessionConfigurationFile |publisher=Technet.microsoft.com |access-date=2013-08-18}}
93. ^{{cite book |author-last1=Albing |author-first1=Carl |title=Bash cookbook |year=2007 |publisher=O'Reilly Media |location=Sebastopol, California, USA |isbn=978-0-596-52678-8 |edition=1st |author-last2=Vossen |author-first2=J. P. |author-last3=Newham |author-first3=Cameron |quote=[…] is hardly what one thinks of as a passive list of configured variables. It can run other commands (e.g., cat) and use if statements to vary its choices. It even ends by echoing a message. Be careful when you source something, as it's a wide open door into your script.}}
94. ^{{cite web |title=About Data Sections |url=https://technet.microsoft.com/en-us/library/hh848302.aspx |publisher=Microsoft |access-date=2012-12-18}}

External links

  • [https://web.archive.org/web/20141010000744/http://w3.linux-magazine.com/issue/78/Bash_vs._Vista_PowerShell.pdf Linux Magazine: Bash vs. Vista PowerShell]
  • IEEE. 1003.1 Standard for Information Technology – Portable Operating System Interface (POSIX): Shell and Utilities, Issue 7
{{Use dmy dates|date=April 2012}}{{DEFAULTSORT:Comparison Of Command Shells}}

2 : Command shells|Software comparisons

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 19:23:04