ksh

Από The Stelios Files
Αναθεώρηση ως προς 16:14, 8 Απριλίου 2022 από τον Admin (συζήτηση | συνεισφορές)
(διαφορά) ← Παλαιότερη αναθεώρηση | Τελευταία αναθεώρηση (διαφορά) | Νεότερη αναθεώρηση → (διαφορά)

1 Σύνταξη

ksh [-i] [ {+|-} {a e f h k m n p t u v x} ] [-o Option ... ] [-c String | -s | -r | File [ Parameter ] ]

2 Περιγραφή

Η εντολή ksh καλεί το φλοιό Korn (KornShell), το οποίο είναι ένας διαδραστικός διερμηνέας εντολών και μια γλώσσα προγραμματισμού εντολών. Το κέλυφος εκτελεί εντολές είτε διαδραστικά από ένα πληκτρολόγιο τερματικού είτε από ένα αρχείο.

Το κέλυφος Korn (Korn shell) είναι προς τα πίσω συμβατό με το κέλυφος Bourne (Bourne shell) (καλείται με την εντολή bsh) και περιέχει τα περισσότερα από τα χαρακτηριστικά του κελύφους Bourne καθώς και πολλά από τα καλύτερα χαρακτηριστικά του κελύφους C (C shell) .

Μια βελτιωμένη έκδοση του κελύφους Korn, που ονομάζεται ksh93, είναι επίσης διαθέσιμη. Το βελτιωμένο κέλυφος Korn έχει πρόσθετες λειτουργίες που δεν είναι διαθέσιμες στο κέλυφος Korn.

Επιπλέον, είναι διαθέσιμη μια περιορισμένη έκδοση του κελύφους Korn, που ονομάζεται rksh. Το περιορισμένο κέλυφος Korn επιτρέπει στους διαχειριστές να παρέχουν ένα περιβάλλον ελεγχόμενης εκτέλεσης για τους χρήστες.

3 Σημαίες

Είδος Περιγραφή
-a Exports automatically all subsequent parameters that are defined.
-c String Causes the Korn shell to read commands from the String variable. This flag cannot be used with the -s flag or with the File[Parameter] parameter.
-e
Executes the ERR trap, if set, and exits if a command has a nonzero exit status, unless in the following conditions:
  • The simple command is contained in a "&&" or "||" list.
  • The simple command immediately follows "if", "while" or "until".
  • The simple command is contained in a pipeline following "!".
This mode is disabled when profiles are read.
-f Disables file name substitution.
-h Designates each command as a tracked alias when first encountered.
-i Indicates that the shell is interactive. An interactive shell is also indicated if shell input and output are attached to a terminal (as determined by the ioctl subroutine). In this case, the TERM environment variable is ignored (so that the kill 0 command does not kill an interactive shell) and the INTR signal is caught and ignored (so that a wait state can be interrupted). In all cases, the QUIT signal is ignored by the shell.
-k Places all parameter assignment arguments in the environment for a command, not just those arguments that precede the command name.
-m Runs background jobs in a separate process and prints a line upon completion. The exit status of background jobs is reported in a completion message. On systems with job control, this flag is turned on automatically for interactive shells.
-n Reads commands and checks them for syntax errors, but does not execute them. This flag is ignored for interactive shells.
-o Option
Prints the current option settings and an error message if you do not specify an argument. You can use this flag to enable any of the following options:
allexport
Same as the -a flag.
errexit
Same as the -e flag.
bgnice
Runs all background jobs at a lower priority. This is the default mode.
emacs
Enters an emacs-style inline editor for command entry.
gmacs
Enters a gmacs-style inline editor for command entry.
ignoreeof
Does not exit the shell when it encounters an end-of-file character. You must use the exit command, or override the flag and exit the shell by pressing the Ctrl-D key sequence more than 11 times.
keyword
Same as the -k flag.
markdirs
Appends a / (slash) to all directory names that are a result of filename substitution.
monitor
Same as the -m flag.
noclobber
Prevents redirection from truncating existing files. When you specify this option, use the redirection symbol >| (right caret, pipe symbol) to truncate a file.
noexec
Same as the -n flag.
noglob
Same as the -f flag.
nolog
Prevents function definitions from being saved in the history file.
nounset
Same as the -u flag.
privileged
Same as the -p flag.
verbose
Same as the -v flag.
trackall
Same as the -h flag.
vi
Enters the insert mode of a vi-style inline editor for command entry. Entering escape character 033 puts the editor into the move mode. A return sends the line.
viraw
Processes each character as it is typed in vi mode.
xtrace
Same as the -x flag.
You can set more than one option on a single ksh command line.
-p Disables the processing of the $HOME/.profile file when you use the shell as a login shell.
-r
Runs a restricted shell. With a restricted shell you cannot:
  • Change the current working directory.
  • Set the value of the SHELLENV, or PATH variable.
  • Specify the pathname of a command that contains a / (slash).
  • Redirect output of a command with > (right caret), >| (right caret, pipe symbol), <> (left caret, right caret), or >> (two right carets).
Using this flag is the same as issuing the rksh command.
-s Causes the ksh command to read commands from the standard input. Shell output, except for the output of the special commands, is written to file descriptor 2. This parameter cannot be used with the -c flag or with the File[Parameter] parameter.
-t Exits after reading and executing one command.
-u Treats unset parameters as errors when substituting.
-v Prints shell input lines as they are read.
-x Prints executed commands and their arguments.

4 Πηγή