⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 article.ms

📁 android-w.song.android.widget
💻 MS
📖 第 1 页 / 共 3 页
字号:
.B pushd ,.B popd ,and.B dirsbuiltins..B Pushdand.B popdinsert and remove directories from the stack, respectively, and.B dirslists the stack contents.  On systems that allow fine-grained controlof resources, the.B ulimitbuiltin can be used to tune these settings..B Ulimitallows a user to control,among other things, whether core dumps are to be generated,how much memory the shell or a child process is allowed to allocate,and how large a file created by a child process can grow.  The.B suspendcommand will stop the shell process when job control is active; mostother shells do not allow themselves to be stopped like that..B Type,the Bash answer to.B whichand .B whence,shows what will happen when a word is typed as a command:.SE$ type exportexport is a shell builtin$ type -t exportbuiltin$ type bashbash is /bin/bash$ type cdcd is a functioncd (){    builtin cd ${1+"$@"} && xtitle $HOST: $PWD}.EE.LPVariousmodes tell what a command word is (reserved word, alias, function, builtin,or file) or which version of a command will be executed based ona user's search path.  Some of this functionality has been adoptedby POSIX.2 and folded into the.B commandutility..NH 2Editing and Completion.PPOne area in which Bash shines is command line editing.  Bash uses the.I readlinelibrary to read and edit lines when interactive.  Readline is apowerful and flexible input facility that a user can configure toindividual tastes.  It allows lines to be edited using either emacsor vi commands, where those commands are appropriate.  The fullcapability of emacs is not present \- there is no way to executea named command with M-x, for instance \- but the existing commandsare more than adequate.  The vi mode is compliant withthe command line editing standardized by POSIX.2..PPReadline is fully customizable.  In addition to the basic commandsand key bindings, the library allows users to define additionalkey bindings using a startup file.  The .I inputrcfile, which defaults to the file.I ~/.inputrc ,is read each time readline initializes, permitting users tomaintain a consistent interface across a set of programs.  Readlineincludes an extensible interface, so each program using thelibrary can add its own bindable commands and program-specifickey bindings.  Bash uses this facility to add bindingsthat perform history expansion or shell word expansions on the currentinput line..PPReadline interprets a number ofvariables which further tune its behavior.  Variablesexist to control whether or not eight-bit characters are directlyread as input or converted to meta-prefixed key sequences (ameta-prefixed key sequence consists of the character with theeighth bit zeroed, preceded by the.I meta-prefixcharacter, usually escape, which selects an alternate keymap), todecide whether to output characters with the eighth bit setdirectly or as a meta-prefixed key sequence, whether or not towrap to a new screen line when a line being edited is longer thanthe screen width, the keymap to which subsequent key bindings shouldapply, or even what happens when readline wants toring the terminal's bell.  All of these variables can be set inthe inputrc file..PPThe startup file understands a set of Cpreprocessor-like conditional constructs which allow variables orkey bindings to be assigned based on the application using readline,the terminal currently being used, or the editing mode.  Users canadd program-specific bindings to make their lives easier:  I havebindings that let me edit the value of.B $PATHand double-quote the current or previous word:.SE# Macros that are convenient for shell interaction$if Bash# edit the path"\eC-xp": "PATH=${PATH}\ee\eC-e\eC-a\eef\eC-f"# prepare to type a quoted word -- insert open and close double# quotes and move to just after the open quote"\eC-x\e"": "\e"\e"\eC-b"# Quote the current or previous word"\eC-xq": "\eeb\e"\eef\e""$endif.EE.LPThere is a readlinecommand to re-read the file, so users can edit the file, changesome bindings, and begin to use them almost immediately..PPBash implements the.B bindbuiltin for more dyamic control of readline than the startup filepermits..B Bindis used in several ways.  In.I listmode, it can display the current key bindings, list all thereadline editing directives available for binding, list which keysinvoke a given directive, or output the current set of keybindings in a format that can be incorporated directly into an inputrcfile.  In.I batchmode, it reads a series of key bindings directly from a file andpasses them to readline.  In its most common usage,.B bindtakes a single string and passes it directly to readline, whichinterprets the line as if it had just been read from the inputrc file.Both key bindings and variable assignments may appear in thestring given to.B bind ..PPThe readline library also provides an interface for \fIword completion\fP.When the.I completioncharacter (usually TAB) is typed, readline looks at the word currentlybeing entered and computes the set of filenames of which the currentword is a valid prefix.If there is only one possible completion, therest of the characters are inserted directly, otherwise the common prefix of the set of filenames is added to the current word.A second TAB character entered immediately after a non-uniquecompletion causes readline to list the possible completions; there isan option to have the list displayed immediately.Readline provides hooks so that applications can provide specific typesof completion before the default filename completion is attempted.This is quite flexible, though it is not completely user-programmable.Bash, for example, can complete filenames, command names (including aliases,builtins, shell reserved words, shell functions, and executables foundin the file system), shell variables, usernames, and hostnames.  Ituses a set of heuristics that, while not perfect, is generally quitegood at determining what type of completion to attempt..NH 2History.PPAccess to the list of commands previously entered (the \fIcommand history\fP)is provided jointly by Bash and the readline library.  Bash providesvariables (\fB$HISTFILE\fP, \fB$HISTSIZE\fP, and \fB$HISTCONTROL\fP)and the.B historyand.B fcbuiltins to manipulate the history list.The value of.B $HISTFILEspecifes the file where Bash writes the command history on exit andreads it on startup..B $HISTSIZEis used to limit the number of commands saved in the history..B $HISTCONTROLprovides a crude form of control over which commands are saved onthe history list: a value of.I ignorespacemeans to not save commands which begin with a space; a value of.I ignoredupsmeans to not save commands identical to the last command saved.\fB$HISTCONTROL\fP was named \fB$history_control\fP in earlierversions of Bash; the old name is still accepted for backwardscompatibility.  The.B historycommand can read or write files containing the history listand display the current list contents.  The.B fcbuiltin, adopted from POSIX.2 and the Korn Shell, allows displayand re-execution, with optional editing,of commands from the history list.  The readlinelibrary offers a set of commands to search the history list fora portion of the current input line or a string typed by the user.Finally, the.I historylibrary, generally incorporated directly into the readline library,implements a facility for history recall, expansion, and re-executionof previous commands very similar to csh(\*Qbang history\*U, so called because the exclamation pointintroduces a history substitution):.SE$ echo a b c d ea b c d e$ !! f g h iecho a b c d e f g h ia b c d e f g h i$ !-2echo a b c d ea b c d e$ echo !-2:1-4echo a b c da b c d.EE.LPThe command history is onlysaved when the shell is interactive, so it is not available for useby shell scripts..NH 2New Shell Variables.PPThere are a number of convenience variables that Bash interpretsto make life easier.  These include.B FIGNORE ,which is a set of filename suffixes identifying files to exclude whencompleting filenames;.B HOSTTYPE ,which is automatically set to a string describing the type ofhardware on which Bash is currently executing;.B command_oriented_history ,which directs Bash to save all lines of a multiple-linecommand such as a \fIwhile\fP or \fIfor\fP loop in a singlehistory entry, allowing easy re-editing; and.B IGNOREEOF ,whose value indicates the number of consecutive EOF characters thatan interactive shell will read before exiting \- an easy way to keepyourself from being logged out accidentally.  The.B auto_resumevariable alters the way the shell treats simple command names:if job control is active, and this variable is set, single-wordsimple commands without redirections cause the shell to firstlook for and restart a suspended job with that name beforestarting a new process..NH 2Brace Expansion.PPSince sh offers no convenient way to generate arbitrary strings thatshare a common prefix or suffix (filename expansion requires thatthe filenames exist), Bash implements \fIbrace expansion\fP, acapability picked up from csh.Brace expansion is similar to filename expansion, but the stringsgenerated need not correspond to existing files.  A brace expressionconsists of an optional.I preamble ,followed by a pair of braces enclosing a series of comma-separatedstrings, and an optional.I postamble .The preamble is prepended to each string within the braces, and thepostamble is then appended to each resulting string:.SE$ echo a{d,c,b}eade ace abe.EE.LPAs this example demonstrates, the results of brace expansion are notsorted, as they are by filename expansion..NH 2Process Substitution.PPOn systems that can support it, Bash provides a facility known as\fIprocess substitution\fP.  Process substitution is similar to commandsubstitution in that its specification includes a command to execute,but the shell does not collect the command's output and insert it intothe command line.  Rather, Bash opens a pipe to the command, whichis run in the background.  The shell uses named pipes (FIFOs) or the.I /dev/fdmethod of naming open files to expand the processsubstitution to a filename which connects to the pipe when opened.This filename becomes the result of the expansion.  Process substitutioncan be used to compare the outputs of two different versions of anapplication as part of a regression test:.SE$ cmp <(old_prog) <(new_prog).EE.NH 2Prompt Customization.PPOne of the more popular interactive features that Bash provides isthe ability to customize the prompt.  Both.B $PS1and.B $PS2,the primary and secondary prompts, are expanded before beingdisplayed.  Parameter and variable expansion is performed whenthe prompt string is expanded, so any shell variable can beput into the prompt (e.g., .B $SHLVL ,which indicates how deeply the current shell is nested).Bash specially interprets characters in the prompt stringpreceded by a backslash.  Some of these backslash escapes arereplaced with the current time, the date, the current working directory,the username, and the command number or history number of the commandbeing entered.  There is even a backslash escape to cause the shellto change its prompt when running as root after an \fIsu\fP.Before printing each primary prompt, Bash expands the variable .B $PROMPT_COMMAND and, if it has a value, executes the expanded value as a command,allowing additional prompt customization.  For example, this assignmentcauses the current user, the current host, the time, the lastcomponent of the current working directory, the level of shellnesting, and the history number of the current command to be embeddedinto the primary prompt:.SE$ PS1='\eu@\eh [\et] \eW($SHLVL:\e!)\e$ 'chet@odin [21:03:44] documentation(2:636)$ cd ..chet@odin [21:03:54] src(2:637)$.EE.LPThe string being assigned is surrounded by single quotes so that ifit is exported, the value of.B $SHLVLwill be updated by a child shell:.SEchet@odin [21:17:35] src(2:638)$ export PS1chet@odin [21:17:40] src(2:639)$ bashchet@odin [21:17:46] src(3:696)$.EE.LPThe \fP\e$\fP escape is displayedas \*Q\fB$\fP\*U when running as a normal user, but as \*Q\fB#\fP\*U whenrunning as root..NH 2File System Views.PPSince Berkeley introduced symbolic links in 4.2 BSD, one of their mostannoying properties has been the \*Qwarping\*U to a completelydifferent area of the file system when using.B cd ,and the resultant non-intuitive behavior of \*Q\fBcd ..\fP\*U.The \s-1UNIX\s+1 kernel treats symbolic links.I physically .When the kernel is translating a pathnamein which one component is a symbolic link, it replaces all or partof the pathname while processing the link.  If the contents of the symboliclink begin with a slash, the kernel replaces thepathname entirely; if not, the link contents replacethe current component.  In either case, the symbolic linkis visible.  If the link value is an absolute pathname,the user finds himself in a completely different part of the filesystem..PPBash provides a.I logicalview of the file system.  In this default mode, command and filenamecompletion and builtin commands such as.B cdand.B pushdwhich change the current working directory transparently followsymbolic links as if they were directories.The.B $PWDvariable, which holds the shell's idea of the current working directory,depends on the path used to reach the directory rather than itsphysical location in the local file system hierarchy.  For example:.SE$ cd /usr/local/bin$ echo $PWD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -