Use zsh syntax in code blocks

This commit is contained in:
Jeffrey Serio 2022-08-24 08:22:41 -05:00
parent 4faab81391
commit 18be5de345
38 changed files with 36430 additions and 45608 deletions

View File

@ -3,40 +3,27 @@
<head> <head>
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <title>Page not found - Zsh Manual</title>
<base href="/"> <base href="/">
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -44,9 +31,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -97,7 +82,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -105,8 +90,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -122,28 +106,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -154,7 +131,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -174,9 +150,7 @@
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -184,56 +158,29 @@
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Arithmetic Evaluation - Zsh Manual</title> <title>Arithmetic Evaluation - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html" class="active"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html" class="active"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -172,354 +149,283 @@
<li><a href="#11-arithmetic-evaluation">11 Arithmetic Evaluation</a></li> <li><a href="#11-arithmetic-evaluation">11 Arithmetic Evaluation</a></li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Arithmetic-Evaluation"></span> <p><span id="Arithmetic-Evaluation"></span> <span
<span id="Arithmetic-Evaluation-1"></span></p> id="Arithmetic-Evaluation-1"></span></p>
<h1 id="11-arithmetic-evaluation"><a class="header" href="#11-arithmetic-evaluation">11 Arithmetic Evaluation</a></h1> <h1 id="11-arithmetic-evaluation"><a class="header" href="#11-arithmetic-evaluation">11 Arithmetic Evaluation</a></h1>
<p><span id="index-arithmetic-evaluation"></span> <p><span id="index-arithmetic-evaluation"></span> <span
<span id="index-evaluation_002c-arithmetic"></span> id="index-evaluation_002c-arithmetic"></span> <span
<span id="index-let_002c-use-of"></span></p> id="index-let_002c-use-of"></span></p>
<p>The shell can perform integer and floating point arithmetic, either <p>The shell can perform integer and floating point arithmetic, either
using the builtin <code>let</code>, or via a substitution of the form using the builtin let, or via a substitution of the form $((<code>...</code>)). For
<code>$((``...``))</code>. For integers, the shell is usually compiled to use integers, the shell is usually compiled to use 8-byte precision where
8-byte precision where this is available, otherwise precision is 4 this is available, otherwise precision is 4 bytes. This can be tested,
bytes. This can be tested, for example, by giving the command <code>print - $(( 12345678901 ))</code>; if the number appears unchanged, the precision is for example, by giving the command print - $(( 12345678901 )); if the
at least 8 bytes. Floating point arithmetic always uses the double number appears unchanged, the precision is at least 8 bytes. Floating
type with whatever corresponding precision is provided by the compiler point arithmetic always uses the double type with whatever
and the library.</p> corresponding precision is provided by the compiler and the library.</p>
<p>The <code>let</code> builtin command takes arithmetic expressions as arguments; <p>The let builtin command takes arithmetic expressions as arguments; each
each is evaluated separately. Since many of the arithmetic operators, as is evaluated separately. Since many of the arithmetic operators, as well
well as spaces, require quoting, an alternative form is provided: for as spaces, require quoting, an alternative form is provided: for any
any command which begins with a <code>((</code>, all the characters until a command which begins with a ((, all the characters until a matching
matching <code>))</code> are treated as a quoted expression and arithmetic )) are treated as a double-quoted expression and arithmetic expansion
expansion performed as for an argument of <code>let</code>. More precisely, performed as for an argument of let. More precisely, ((<code>...</code>)) is
<code>((``...``))</code> is equivalent to <code>let &quot;``...``&quot;</code>. The return status equivalent to let &quot;<code>...</code>&quot;. The return status is 0 if the arithmetic
is 0 if the arithmetic value of the expression is non-zero, 1 if it is value of the expression is non-zero, 1 if it is zero, and 2 if an error
zero, and 2 if an error occurred.</p> occurred.</p>
<p>For example, the following statement</p> <p>For example, the following statement</p>
<div class="example"> <div class="example">
<pre><code class="language-example">(( val = 2 + 1 )) <pre><code class="language-zsh">(( val = 2 + 1 ))
</code></pre> </code></pre>
</div> </div>
<p>is equivalent to</p> <p>is equivalent to</p>
<div class="example"> <div class="example">
<pre><code class="language-example">let &quot;val = 2 + 1&quot; <pre><code class="language-zsh">let &quot;val = 2 + 1&quot;
</code></pre> </code></pre>
</div> </div>
<p>both assigning the value 3 to the shell variable <code>val</code> and returning a <p>both assigning the value 3 to the shell variable val and returning a
zero status.</p> zero status.</p>
<p><span id="index-arithmetic-base"></span> <p><span id="index-arithmetic-base"></span> <span
<span id="index-bases_002c-in-arithmetic"></span></p> id="index-bases_002c-in-arithmetic"></span></p>
<p>Integers can be in bases other than 10. A leading <code>0x</code> or <code>0X</code> <p>Integers can be in bases other than 10. A leading 0x or 0X denotes
denotes hexadecimal and a leading <code>0b</code> or <code>0B</code> binary. Integers may hexadecimal and a leading 0b or 0B binary. Integers may also be of
also be of the form <code>base``#``n</code>, where <code>base</code> is a decimal number the form <code>base</code>#<code>n</code>, where <code>base</code> is a decimal number between two and
between two and thirty-six representing the arithmetic base and <code>n</code> is a thirty-six representing the arithmetic base and <code>n</code> is a number in that
number in that base (for example, <code>16#ff</code> is 255 in hexadecimal). The base (for example, 16#ff is 255 in hexadecimal). The <code>base</code># may also
<code>base``#</code> may also be omitted, in which case base 10 is used. For be omitted, in which case base 10 is used. For backwards compatibility
backwards compatibility the form <code>[``base``]``n</code> is also accepted.</p> the form [<code>base</code>]<code>n</code> is also accepted.</p>
<p>An integer expression or a base given in the form <code>base``#``n</code> may <p>An integer expression or a base given in the form <code>base</code>#<code>n</code> may
contain underscores (<code>_</code>) after the leading digit for visual guidance; contain underscores (_) after the leading digit for visual guidance;
these are ignored in computation. Examples are <code>1_000_000</code> or these are ignored in computation. Examples are 1_000_000 or 0xffff_ffff
<code>0xffff_ffff</code> which are equivalent to <code>1000000</code> and <code>0xffffffff</code> which are equivalent to 1000000 and 0xffffffff respectively.</p>
respectively.</p>
<p>It is also possible to specify a base to be used for output in the form <p>It is also possible to specify a base to be used for output in the form
<code>[#``base``]</code>, for example <code>[#16]</code>. This is used when outputting [#<code>base</code>], for example [#16]. This is used when outputting
arithmetical substitutions or when assigning to scalar parameters, but arithmetical substitutions or when assigning to scalar parameters, but
an explicitly defined integer or floating point parameter will not be an explicitly defined integer or floating point parameter will not be
affected. If an integer variable is implicitly defined by an arithmetic affected. If an integer variable is implicitly defined by an arithmetic
expression, any base specified in this way will be set as the variables expression, any base specified in this way will be set as the variables
output arithmetic base as if the option <code>-i</code> <code>base</code> to the <code>typeset</code> output arithmetic base as if the option -i <code>base</code> to the typeset
builtin had been used. The expression has no precedence and if it occurs builtin had been used. The expression has no precedence and if it occurs
more than once in a mathematical expression, the last encountered is more than once in a mathematical expression, the last encountered is
used. For clarity it is recommended that it appear at the beginning of used. For clarity it is recommended that it appear at the beginning of
an expression. As an example:</p> an expression. As an example:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">typeset -i 16 y <pre><code class="language-zsh">typeset -i 16 y
print $(( [#8] x = 32, y = 32 )) print $(( [#8] x = 32, y = 32 ))
print $x $y print $x $y
</code></pre> </code></pre>
</div> </div>
<p>outputs first <code>8#40</code>, the rightmost value in the given output base, <p>outputs first 8#40, the rightmost value in the given output base, and
and then <code>8#40 16#20</code>, because <code>y</code> has been explicitly declared to then 8#40 16#20, because y has been explicitly declared to have output
have output base 16, while <code>x</code> (assuming it does not already exist) is base 16, while x (assuming it does not already exist) is implicitly
implicitly typed by the arithmetic evaluation, where it acquires the typed by the arithmetic evaluation, where it acquires the output base 8.</p>
output base 8.</p>
<p>The <code>base</code> may be replaced or followed by an underscore, which may <p>The <code>base</code> may be replaced or followed by an underscore, which may
itself be followed by a positive integer (if it is missing the value 3 itself be followed by a positive integer (if it is missing the value 3
is used). This indicates that underscores should be inserted into the is used). This indicates that underscores should be inserted into the
output string, grouping the number for visual clarity. The following output string, grouping the number for visual clarity. The following
integer specifies the number of digits to group together. For example:</p> integer specifies the number of digits to group together. For example:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">setopt cbases <pre><code class="language-zsh">setopt cbases
print $(( [#16_4] 65536 ** 2 )) print $(( [#16_4] 65536 ** 2 ))
</code></pre> </code></pre>
</div> </div>
<p>outputs <code>0x1_0000_0000</code>.</p> <p>outputs 0x1_0000_0000.</p>
<p>The feature can be used with floating point numbers, in which case the <p>The feature can be used with floating point numbers, in which case the
base must be omitted; grouping is away from the decimal point. For base must be omitted; grouping is away from the decimal point. For
example,</p> example,</p>
<div class="example"> <div class="example">
<pre><code class="language-example">zmodload zsh/mathfunc <pre><code class="language-zsh">zmodload zsh/mathfunc
print $(( [#_] sqrt(1e7) )) print $(( [#_] sqrt(1e7) ))
</code></pre> </code></pre>
</div> </div>
<p>outputs <code>3_162.277_660_168_379_5</code> (the number of decimal places shown <p>outputs 3_162.277_660_168_379_5 (the number of decimal places shown
may vary).</p> may vary).</p>
<p><span id="index-C_005fBASES_002c-use-of"></span> <p><span id="index-C_005fBASES_002c-use-of"></span> <span
<span id="index-OCTAL_005fZEROES_002c-use-of"></span></p> id="index-OCTAL_005fZEROES_002c-use-of"></span></p>
<p>If the <code>C_BASES</code> option is set, hexadecimal numbers are output in the <p>If the C_BASES option is set, hexadecimal numbers are output in the
standard C format, for example <code>0xFF</code> instead of the usual <code>16#FF</code>. standard C format, for example 0xFF instead of the usual 16#FF. If
If the option <code>OCTAL_ZEROES</code> is also set (it is not by default), octal the option OCTAL_ZEROES is also set (it is not by default), octal
numbers will be treated similarly and hence appear as <code>077</code> instead of numbers will be treated similarly and hence appear as 077 instead of
<code>8#77</code>. This option has no effect on the output of bases other than 8#77. This option has no effect on the output of bases other than
hexadecimal and octal, and these formats are always understood on input.</p> hexadecimal and octal, and these formats are always understood on input.</p>
<p>When an output base is specified using the <code>[#``base``]</code> syntax, an <p>When an output base is specified using the [#<code>base</code>] syntax, an
appropriate base prefix will be output if necessary, so that the value appropriate base prefix will be output if necessary, so that the value
output is valid syntax for input. If the <code>#</code> is doubled, for example output is valid syntax for input. If the # is doubled, for example
<code>[##16]</code>, then no base prefix is output.</p> [##16], then no base prefix is output.</p>
<p>Floating point constants are recognized by the presence of a decimal <p>Floating point constants are recognized by the presence of a decimal
point or an exponent. The decimal point may be the first character of point or an exponent. The decimal point may be the first character of
the constant, but the exponent character <code>e</code> or <code>E</code> may not, as it will the constant, but the exponent character e or E may not, as it will be
be taken for a parameter name. All numeric parts (before and after the taken for a parameter name. All numeric parts (before and after the
decimal point and in the exponent) may contain underscores after the decimal point and in the exponent) may contain underscores after the
leading digit for visual guidance; these are ignored in computation.</p> leading digit for visual guidance; these are ignored in computation.</p>
<p><span id="index-arithmetic-operators"></span> <p><span id="index-arithmetic-operators"></span> <span
<span id="index-operators_002c-arithmetic"></span></p> id="index-operators_002c-arithmetic"></span></p>
<p>An arithmetic expression uses nearly the same syntax and associativity <p>An arithmetic expression uses nearly the same syntax and associativity
of expressions as in C.</p> of expressions as in C.</p>
<p>In the native mode of operation, the following operators are supported <p>In the native mode of operation, the following operators are supported
(listed in decreasing order of precedence):</p> (listed in decreasing order of precedence):</p>
<ul> <p>+ - ! ~ ++ <br />
<li>
<p><code>+ - ! ~ ++ </code><br />
unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement</p> unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement</p>
</li> <p>&lt;&lt; &gt;&gt;<br />
<li>
<p><code>&lt;&lt; &gt;&gt;</code><br />
bitwise shift left, right</p> bitwise shift left, right</p>
</li> <p>&amp;<br />
<li>
<p><code>&amp;</code><br />
bitwise AND</p> bitwise AND</p>
</li> <p>^<br />
<li>
<p><code>^</code><br />
bitwise XOR</p> bitwise XOR</p>
</li> <p>|<br />
<li>
<p><code>|</code><br />
bitwise OR</p> bitwise OR</p>
</li> <p>**<br />
<li>
<p><code>**</code><br />
exponentiation</p> exponentiation</p>
</li> <p>* / %<br />
<li>
<p><code>* / %</code><br />
multiplication, division, modulus (remainder)</p> multiplication, division, modulus (remainder)</p>
</li> <p>+ -<br />
<li>
<p><code>+ -</code><br />
addition, subtraction</p> addition, subtraction</p>
</li> <p>&lt; &gt; &lt;= &gt;=<br />
<li>
<p><code>&lt; &gt; &lt;= &gt;=</code><br />
comparison</p> comparison</p>
</li> <p>== !=<br />
<li>
<p><code>== !=</code><br />
equality and inequality</p> equality and inequality</p>
</li> <p>&amp;&amp;<br />
<li>
<p><code>&amp;&amp;</code><br />
logical AND</p> logical AND</p>
</li> <p>|| ^^<br />
<li>
<p><code>|| ^^</code><br />
logical OR, XOR</p> logical OR, XOR</p>
</li> <p>? :<br />
<li>
<p><code>? :</code><br />
ternary operator</p> ternary operator</p>
</li> <p>= += -= *= /= %= &amp;= ^= |= &lt;&lt;= &gt;&gt;= &amp;&amp;= ||= ^^= **=<br />
<li>
<p><code>= += -= *= /= %= &amp;= ^= |= &lt;&lt;= &gt;&gt;= &amp;&amp;= ||= ^^= **=</code><br />
assignment</p> assignment</p>
</li> <p>,<br />
<li>
<p><code>,</code><br />
comma operator</p> comma operator</p>
</li> <p>The operators &amp;&amp;, ||, &amp;&amp;=, and ||= are short-circuiting, and
</ul> only one of the latter two expressions in a ternary operator is
<p>The operators <code>&amp;&amp;</code>, <code>||</code>, <code>&amp;&amp;=</code>, and <code>||=</code> are short-circuiting,
and only one of the latter two expressions in a ternary operator is
evaluated. Note the precedence of the bitwise AND, OR, and XOR evaluated. Note the precedence of the bitwise AND, OR, and XOR
operators.</p> operators.</p>
<p>With the option <code>C_PRECEDENCES</code> the precedences (but no other <p>With the option C_PRECEDENCES the precedences (but no other properties)
properties) of the operators are altered to be the same as those in most of the operators are altered to be the same as those in most other
other languages that support the relevant operators:</p> languages that support the relevant operators:</p>
<ul> <p>+ - ! ~ ++ <br />
<li>
<p><code>+ - ! ~ ++ </code><br />
unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement</p> unary plus/minus, logical NOT, complement, {pre,post}{in,de}crement</p>
</li> <p>**<br />
<li>
<p><code>**</code><br />
exponentiation</p> exponentiation</p>
</li> <p>* / %<br />
<li>
<p><code>* / %</code><br />
multiplication, division, modulus (remainder)</p> multiplication, division, modulus (remainder)</p>
</li> <p>+ -<br />
<li>
<p><code>+ -</code><br />
addition, subtraction</p> addition, subtraction</p>
</li> <p>&lt;&lt; &gt;&gt;<br />
<li>
<p><code>&lt;&lt; &gt;&gt;</code><br />
bitwise shift left, right</p> bitwise shift left, right</p>
</li> <p>&lt; &gt; &lt;= &gt;=<br />
<li>
<p><code>&lt; &gt; &lt;= &gt;=</code><br />
comparison</p> comparison</p>
</li> <p>== !=<br />
<li>
<p><code>== !=</code><br />
equality and inequality</p> equality and inequality</p>
</li> <p>&amp;<br />
<li>
<p><code>&amp;</code><br />
bitwise AND</p> bitwise AND</p>
</li> <p>^<br />
<li>
<p><code>^</code><br />
bitwise XOR</p> bitwise XOR</p>
</li> <p>|<br />
<li>
<p><code>|</code><br />
bitwise OR</p> bitwise OR</p>
</li> <p>&amp;&amp;<br />
<li>
<p><code>&amp;&amp;</code><br />
logical AND</p> logical AND</p>
</li> <p>^^<br />
<li>
<p><code>^^</code><br />
logical XOR</p> logical XOR</p>
</li> <p>||<br />
<li>
<p><code>||</code><br />
logical OR</p> logical OR</p>
</li> <p>? :<br />
<li>
<p><code>? :</code><br />
ternary operator</p> ternary operator</p>
</li> <p>= += -= *= /= %= &amp;= ^= |= &lt;&lt;= &gt;&gt;= &amp;&amp;= ||= ^^= **=<br />
<li>
<p><code>= += -= *= /= %= &amp;= ^= |= &lt;&lt;= &gt;&gt;= &amp;&amp;= ||= ^^= **=</code><br />
assignment</p> assignment</p>
</li> <p>,<br />
<li>
<p><code>,</code><br />
comma operator</p> comma operator</p>
</li>
</ul>
<p>Note the precedence of exponentiation in both cases is below that of <p>Note the precedence of exponentiation in both cases is below that of
unary operators, hence <code>-3**2</code> evaluates as <code>9</code>, not <code>-9</code>. Use unary operators, hence -3**2 evaluates as 9, not -9. Use
parentheses where necessary: <code>-(3**2)</code>. This is for compatibility with parentheses where necessary: -(3**2). This is for compatibility with
other shells.</p> other shells.</p>
<p><span id="index-mathematical-functions_002c-use-of"></span> <p><span id="index-mathematical-functions_002c-use-of"></span> <span
<span id="index-functions_002c-math_002c-use-of"></span></p> id="index-functions_002c-math_002c-use-of"></span></p>
<p>Mathematical functions can be called with the syntax <p>Mathematical functions can be called with the syntax <code>func</code>(<code>args</code>),
<code>func``(``args``)</code>, where the function decides if the <code>args</code> is where the function decides if the <code>args</code> is used as a string or a
used as a string or a comma-separated list of arithmetic expressions. comma-separated list of arithmetic expressions. The shell currently
The shell currently defines no mathematical functions by default, but defines no mathematical functions by default, but the module
the module <code>zsh/mathfunc</code> may be loaded with the <code>zmodload</code> builtin to zsh/mathfunc may be loaded with the zmodload builtin to provide standard
provide standard floating point mathematical functions.</p> floating point mathematical functions.</p>
<p>An expression of the form <code>##``x</code> where <code>x</code> is any character sequence <p>An expression of the form ##<code>x</code> where <code>x</code> is any character sequence
such as <code>a</code>, <code>^A</code>, or <code>\M-\C-x</code> gives the value of this character such as a, ^A, or \M-\C-x gives the value of this character and
and an expression of the form <code>#``name</code> gives the value of the first an expression of the form #<code>name</code> gives the value of the first
character of the contents of the parameter <code>name</code>. Character values are character of the contents of the parameter <code>name</code>. Character values are
according to the character set used in the current locale; for multibyte according to the character set used in the current locale; for multibyte
character handling the option <code>MULTIBYTE</code> must be set. Note that this character handling the option MULTIBYTE must be set. Note that this form
form is different from <code>$#``name</code>, a standard parameter substitution is different from $#<code>name</code>, a standard parameter substitution which
which gives the length of the parameter <code>name</code>. <code>#\</code> is accepted gives the length of the parameter <code>name</code>. #\ is accepted instead of
instead of <code>##</code>, but its use is deprecated.</p> ##, but its use is deprecated.</p>
<p>Named parameters and subscripted arrays can be referenced by name within <p>Named parameters and subscripted arrays can be referenced by name within
an arithmetic expression without using the parameter expansion syntax. an arithmetic expression without using the parameter expansion syntax.
For example,</p> For example,</p>
<div class="example"> <div class="example">
<pre><code class="language-example">((val2 = val1 * 2)) <pre><code class="language-zsh">((val2 = val1 * 2))
</code></pre> </code></pre>
</div> </div>
<p>assigns twice the value of <code>$val1</code> to the parameter named <code>val2</code>.</p> <p>assigns twice the value of $val1 to the parameter named val2.</p>
<p>An internal integer representation of a named parameter can be specified <p>An internal integer representation of a named parameter can be specified
with the <code>integer</code> builtin. with the integer builtin. <span
<span id="index-parameters_002c-integer"></span> id="index-parameters_002c-integer"></span> <span
<span id="index-integer-parameters"></span> id="index-integer-parameters"></span> <span
<span id="index-integer_002c-use-of"></span> Arithmetic evaluation is id="index-integer_002c-use-of"></span> Arithmetic evaluation is
performed on the value of each assignment to a named parameter declared performed on the value of each assignment to a named parameter declared
integer in this manner. Assigning a floating point number to an integer integer in this manner. Assigning a floating point number to an integer
results in rounding towards zero.</p> results in rounding towards zero.</p>
<p><span id="index-parameters_002c-floating-point"></span> <p><span id="index-parameters_002c-floating-point"></span> <span
<span id="index-floating-point-parameters"></span> id="index-floating-point-parameters"></span> <span
<span id="index-float_002c-use-of"></span></p> id="index-float_002c-use-of"></span></p>
<p>Likewise, floating point numbers can be declared with the <code>float</code> <p>Likewise, floating point numbers can be declared with the float builtin;
builtin; there are two types, differing only in their output format, as there are two types, differing only in their output format, as described
described for the <code>typeset</code> builtin. The output format can be bypassed for the typeset builtin. The output format can be bypassed by using
by using arithmetic substitution instead of the parameter substitution, arithmetic substitution instead of the parameter substitution, i.e.
i.e. <code>${``float``}</code> uses the defined format, but <code>$((``float``))</code> ${<code>float</code>} uses the defined format, but $((<code>float</code>)) uses a generic
uses a generic floating point format.</p> floating point format.</p>
<p>Promotion of integer to floating point values is performed where <p>Promotion of integer to floating point values is performed where
necessary. In addition, if any operator which requires an integer necessary. In addition, if any operator which requires an integer (&amp;,
(<code>&amp;</code>, <code>|</code>, <code>^</code>, <code>&lt;&lt;</code>, <code>&gt;&gt;</code> and their equivalents with |, ^, &lt;&lt;, &gt;&gt; and their equivalents with assignment) is given
assignment) is given a floating point argument, it will be silently a floating point argument, it will be silently rounded towards zero
rounded towards zero except for <code>~</code> which rounds down.</p> except for ~ which rounds down.</p>
<p>Users should beware that, in common with many other programming <p>Users should beware that, in common with many other programming
languages but not software designed for calculation, the evaluation of languages but not software designed for calculation, the evaluation of
an expression in zsh is taken a term at a time and promotion of integers an expression in zsh is taken a term at a time and promotion of integers
to floating point does not occur in terms only containing integers. A to floating point does not occur in terms only containing integers. A
typical result of this is that a division such as <code>6/8</code> is truncated, in typical result of this is that a division such as 6/8 is truncated, in
this being rounded towards 0. The <code>FORCE_FLOAT</code> shell option can be used this being rounded towards 0. The FORCE_FLOAT shell option can be used
in scripts or functions where floating point evaluation is required in scripts or functions where floating point evaluation is required
throughout.</p> throughout.</p>
<p>Scalar variables can hold integer or floating point values at different <p>Scalar variables can hold integer or floating point values at different
times; there is no memory of the numeric type in this case.</p> times; there is no memory of the numeric type in this case.</p>
<p>If a variable is first assigned in a numeric context without previously <p>If a variable is first assigned in a numeric context without previously
being declared, it will be implicitly typed as <code>integer</code> or <code>float</code> and being declared, it will be implicitly typed as integer or float and
retain that type either until the type is explicitly changed or until retain that type either until the type is explicitly changed or until
the end of the scope. This can have unforeseen consequences. For the end of the scope. This can have unforeseen consequences. For
example, in the loop</p> example, in the loop</p>
<div class="example"> <div class="example">
<pre><code class="language-example">for (( f = 0; f &lt; 1; f += 0.1 )); do <pre><code class="language-zsh">for (( f = 0; f &lt; 1; f += 0.1 )); do
# use $f # use $f
done done
</code></pre> </code></pre>
</div> </div>
<p>if <code>f</code> has not already been declared, the first assignment will cause it <p>if f has not already been declared, the first assignment will cause it
to be created as an integer, and consequently the operation <code>f += 0.1</code> to be created as an integer, and consequently the operation f += 0.1
will always cause the result to be truncated to zero, so that the loop will always cause the result to be truncated to zero, so that the loop
will fail. A simple fix would be to turn the initialization into <code>f = 0.0</code>. It is therefore best to declare numeric variables with explicit will fail. A simple fix would be to turn the initialization into f =
0.0. It is therefore best to declare numeric variables with explicit
types.</p> types.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Jobs-&amp;-Signals.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="Jobs-_0026-Signals.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Conditional-Expressions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Conditional-Expressions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -527,64 +433,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Jobs-&amp;-Signals.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<a rel="prev" href="Jobs-_0026-Signals.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Conditional-Expressions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Conditional-Expressions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Command Execution - Zsh Manual</title> <title>Command Execution - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html" class="active"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html" class="active"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -172,55 +149,55 @@
<li><a href="#8-command-execution">8 Command Execution</a></li> <li><a href="#8-command-execution">8 Command Execution</a></li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Command-Execution"></span> <p><span id="Command-Execution"></span> <span
<span id="Command-Execution-1"></span></p> id="Command-Execution-1"></span></p>
<h1 id="8-command-execution"><a class="header" href="#8-command-execution">8 Command Execution</a></h1> <h1 id="8-command-execution"><a class="header" href="#8-command-execution">8 Command Execution</a></h1>
<p><span id="index-command-execution"></span> <p><span id="index-command-execution"></span> <span
<span id="index-execution_002c-of-commands"></span> id="index-execution_002c-of-commands"></span> <span
<span id="index-command-not-found_002c-handling-of"></span> id="index-command-not-found_002c-handling-of"></span> <span
<span id="index-command_005fnot_005ffound_005fhandler"></span></p> id="index-command_005fnot_005ffound_005fhandler"></span></p>
<p>If a command name contains no slashes, the shell attempts to locate it. <p>If a command name contains no slashes, the shell attempts to locate it.
If there exists a shell function by that name, the function is invoked If there exists a shell function by that name, the function is invoked
as described in <a href="Functions.html#Functions">Functions</a>. If there exists a as described in <a href="Functions.html#Functions">Functions</a>. If there exists a
shell builtin by that name, the builtin is invoked.</p> shell builtin by that name, the builtin is invoked.</p>
<p><span id="index-path_002c-use-of"></span></p> <p><span id="index-path_002c-use-of"></span></p>
<p>Otherwise, the shell searches each element of <code>$path</code> for a search is <p>Otherwise, the shell searches each element of $path for a</p>
unsuccessful, the shell prints an error message and returns a nonzero <p>If execution fails: an error message is printed, and one of the
exit status.</p> following values is returned.</p>
<p>127</p>
<p>The search was unsuccessful. The error message is command not found:
<code>cmd</code>.</p>
<p>126</p>
<p>directory or special file, or is not a script and is in a format
unrecognized by the operating system. The exact conditions and error
message are operating system-dependent; see execve(2).</p>
<p>and the file is not a directory, it is assumed to be a shell script. <p>and the file is not a directory, it is assumed to be a shell script.
<code>/bin/sh</code> is spawned to execute it. If the program is a file beginning /bin/sh is spawned to execute it. If the program is a file beginning
with <code>#!</code>, the remainder of the first line specifies an interpreter with #!, the remainder of the first line specifies an interpreter for
for the program. The shell will execute the specified interpreter on the program. The shell will execute the specified interpreter on
operating systems that do</p> operating systems that do</p>
<p>If no external command is found but a function <p>If no external command is found but a function command_not_found_handler
<code>command_not_found_handler</code> exists the shell executes this function with exists the shell executes this function with all command line arguments.
all command line arguments. The return status of the function becomes The return status of the function becomes the status of the command.
the status of the command. If the function wishes to mimic the behaviour
of the shell when the command is not found, it should print the message
<code>command not found:</code> <code>cmd</code> to standard error and return status 127.
Note that the handler is executed in a subshell forked to execute an Note that the handler is executed in a subshell forked to execute an
external command, hence changes to directories, shell parameters, etc. external command, hence changes to directories, shell parameters, etc.
have no effect on the main shell.</p> have no effect on the main shell.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Redirection.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Redirection.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Functions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Functions.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -228,64 +205,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Redirection.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Redirection.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Functions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Functions.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Conditional Expressions - Zsh Manual</title> <title>Conditional Expressions - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html" class="active"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html" class="active"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -172,299 +149,208 @@
<li><a href="#12-conditional-expressions">12 Conditional Expressions</a></li> <li><a href="#12-conditional-expressions">12 Conditional Expressions</a></li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Conditional-Expressions"></span> <p><span id="Conditional-Expressions"></span> <span
<span id="Conditional-Expressions-1"></span></p> id="Conditional-Expressions-1"></span></p>
<h1 id="12-conditional-expressions"><a class="header" href="#12-conditional-expressions">12 Conditional Expressions</a></h1> <h1 id="12-conditional-expressions"><a class="header" href="#12-conditional-expressions">12 Conditional Expressions</a></h1>
<p><span id="index-conditional-expressions"></span> <p><span id="index-conditional-expressions"></span> <span
<span id="index-expressions_002c-conditional"></span></p> id="index-expressions_002c-conditional"></span></p>
<p>A <em>conditional expression</em> is used with the <code>[[</code> compound command to <p>A <em>conditional expression</em> is used with the [[ compound command to
test attributes of files and to compare strings. Each expression can be test attributes of files and to compare strings. Each expression can be
constructed from one or more of the following unary or binary constructed from one or more of the following unary or binary
expressions:</p> expressions:</p>
<ul> <p>-a <code>file</code><br />
<li>
<p><code>-a</code> <code>file</code><br />
true if <code>file</code> exists.</p> true if <code>file</code> exists.</p>
</li> <p>-b <code>file</code><br />
<li>
<p><code>-b</code> <code>file</code><br />
true if <code>file</code> exists and is a block special file.</p> true if <code>file</code> exists and is a block special file.</p>
</li> <p>-c <code>file</code><br />
<li>
<p><code>-c</code> <code>file</code><br />
true if <code>file</code> exists and is a character special file.</p> true if <code>file</code> exists and is a character special file.</p>
</li> <p>-d <code>file</code><br />
<li>
<p><code>-d</code> <code>file</code><br />
true if <code>file</code> exists and is a directory.</p> true if <code>file</code> exists and is a directory.</p>
</li> <p>-e <code>file</code><br />
<li>
<p><code>-e</code> <code>file</code><br />
true if <code>file</code> exists.</p> true if <code>file</code> exists.</p>
</li> <p>-f <code>file</code><br />
<li>
<p><code>-f</code> <code>file</code><br />
true if <code>file</code> exists and is a regular file.</p> true if <code>file</code> exists and is a regular file.</p>
</li> <p>-g <code>file</code><br />
<li>
<p><code>-g</code> <code>file</code><br />
true if <code>file</code> exists and has its setgid bit set.</p> true if <code>file</code> exists and has its setgid bit set.</p>
</li> <p>-h <code>file</code><br />
<li>
<p><code>-h</code> <code>file</code><br />
true if <code>file</code> exists and is a symbolic link.</p> true if <code>file</code> exists and is a symbolic link.</p>
</li> <p>-k <code>file</code><br />
<li>
<p><code>-k</code> <code>file</code><br />
true if <code>file</code> exists and has its sticky bit set.</p> true if <code>file</code> exists and has its sticky bit set.</p>
</li> <p>-n <code>string</code><br />
<li>
<p><code>-n</code> <code>string</code><br />
true if length of <code>string</code> is non-zero.</p> true if length of <code>string</code> is non-zero.</p>
</li> <p>-o <code>option</code><br />
<li> true if option named <code>option</code> is on. <code>option</code> may be a single character,
<p><code>-o</code> <code>option</code><br /> in which case it is a single letter option name. (See <a href="Options.html#Specifying-Options">Specifying
true if option named <code>option</code> is on. <code>option</code> may be a single Options</a>.)</p>
character, in which case it is a single letter option name. (See <p>When no option named <code>option</code> exists, and the POSIX_BUILTINS option
<a href="Options.html#Specifying-Options">Specifying Options</a>.)</p> hasnt been set, return 3 with a warning. If that option is set, return
<p>When no option named <code>option</code> exists, and the <code>POSIX_BUILTINS</code> 1 with no warning.</p>
option hasnt been set, return 3 with a warning. If that option is <p>-p <code>file</code><br />
set, return 1 with no warning.</p>
</li>
<li>
<p><code>-p</code> <code>file</code><br />
true if <code>file</code> exists and is a FIFO special file (named pipe).</p> true if <code>file</code> exists and is a FIFO special file (named pipe).</p>
</li> <p>-r <code>file</code><br />
<li>
<p><code>-r</code> <code>file</code><br />
true if <code>file</code> exists and is readable by current process.</p> true if <code>file</code> exists and is readable by current process.</p>
</li> <p>-s <code>file</code><br />
<li>
<p><code>-s</code> <code>file</code><br />
true if <code>file</code> exists and has size greater than zero.</p> true if <code>file</code> exists and has size greater than zero.</p>
</li> <p>-t <code>fd</code><br />
<li>
<p><code>-t</code> <code>fd</code><br />
true if file descriptor number <code>fd</code> is open and associated with a true if file descriptor number <code>fd</code> is open and associated with a
terminal device. (note: <code>fd</code> is not optional)</p> terminal device. (note: <code>fd</code> is not optional)</p>
</li> <p>-u <code>file</code><br />
<li>
<p><code>-u</code> <code>file</code><br />
true if <code>file</code> exists and has its setuid bit set.</p> true if <code>file</code> exists and has its setuid bit set.</p>
</li> <p>-v <code>varname</code><br />
<li>
<p><code>-v</code> <code>varname</code><br />
true if shell variable <code>varname</code> is set.</p> true if shell variable <code>varname</code> is set.</p>
</li> <p>-w <code>file</code><br />
<li> -x <code>file</code><br />
<p><code>-w</code> <code>file</code><br /> -z <code>string</code><br />
<code>-x</code> <code>file</code><br />
<code>-z</code> <code>string</code><br />
true if length of <code>string</code> is zero.</p> true if length of <code>string</code> is zero.</p>
</li> <p>-L <code>file</code><br />
<li>
<p><code>-L</code> <code>file</code><br />
true if <code>file</code> exists and is a symbolic link.</p> true if <code>file</code> exists and is a symbolic link.</p>
</li> <p>-O <code>file</code><br />
<li>
<p><code>-O</code> <code>file</code><br />
true if <code>file</code> exists and is owned by the effective user ID of this true if <code>file</code> exists and is owned by the effective user ID of this
process.</p> process.</p>
</li> <p>-G <code>file</code><br />
<li> true if <code>file</code> exists and its group matches the effective group ID of
<p><code>-G</code> <code>file</code><br /> this process.</p>
true if <code>file</code> exists and its group matches the effective group ID <p>-S <code>file</code><br />
of this process.</p>
</li>
<li>
<p><code>-S</code> <code>file</code><br />
true if <code>file</code> exists and is a socket.</p> true if <code>file</code> exists and is a socket.</p>
</li> <p>-N <code>file</code><br />
<li>
<p><code>-N</code> <code>file</code><br />
true if <code>file</code> exists and its access time is not newer than its true if <code>file</code> exists and its access time is not newer than its
modification time.</p> modification time.</p>
</li> <p><code>file1</code> -nt <code>file2</code><br />
<li>
<p><code>file1</code> <code>-nt</code> <code>file2</code><br />
true if <code>file1</code> exists and is newer than <code>file2</code>.</p> true if <code>file1</code> exists and is newer than <code>file2</code>.</p>
</li> <p><code>file1</code> -ot <code>file2</code><br />
<li>
<p><code>file1</code> <code>-ot</code> <code>file2</code><br />
true if <code>file1</code> exists and is older than <code>file2</code>.</p> true if <code>file1</code> exists and is older than <code>file2</code>.</p>
</li> <p><code>file1</code> -ef <code>file2</code><br />
<li>
<p><code>file1</code> <code>-ef</code> <code>file2</code><br />
true if <code>file1</code> and <code>file2</code> exist and refer to the same file.</p> true if <code>file1</code> and <code>file2</code> exist and refer to the same file.</p>
</li> <p><code>string</code> = <code>pattern</code><br />
<li> <code>string</code> == <code>pattern</code><br />
<p><code>string</code> <code>=</code> <code>pattern</code><br />
<code>string</code> <code>==</code> <code>pattern</code><br />
true if <code>string</code> matches <code>pattern</code>. The two forms are exactly true if <code>string</code> matches <code>pattern</code>. The two forms are exactly
equivalent. The <code>=</code> form is the traditional shell syntax (and equivalent. The = form is the traditional shell syntax (and hence the
hence the only one generally used with the <code>test</code> and <code>[</code> builtins); only one generally used with the test and [ builtins); the == form
the <code>==</code> form provides compatibility with other sorts of computer provides compatibility with other sorts of computer language.</p>
language.</p> <p><code>string</code> != <code>pattern</code><br />
</li>
<li>
<p><code>string</code> <code>!=</code> <code>pattern</code><br />
true if <code>string</code> does not match <code>pattern</code>.</p> true if <code>string</code> does not match <code>pattern</code>.</p>
</li> <p><code>string</code> =~ <code>regexp</code><br />
<li> true if <code>string</code> matches the regular expression <code>regexp</code>. If the option
<p><code>string</code> <code>=~</code> <code>regexp</code><br /> RE_MATCH_PCRE is set <code>regexp</code> is tested as a PCRE regular expression
true if <code>string</code> matches the regular expression <code>regexp</code>. If the using the zsh/pcre module, else it is tested as a POSIX extended regular
option <code>RE_MATCH_PCRE</code> is set <code>regexp</code> is tested as a PCRE regular expression using the zsh/regex module. Upon successful match, some
expression using the <code>zsh/pcre</code> module, else it is tested as a POSIX variables will be updated; no variables are changed if the matching
extended regular expression using the <code>zsh/regex</code> module. Upon fails.</p>
successful match, some variables will be updated; no variables are <p>If the option BASH_REMATCH is not set the scalar parameter MATCH is set
changed if the matching fails.</p> to the substring that matched the pattern and the integer parameters
<p>If the option <code>BASH_REMATCH</code> is not set the scalar parameter <code>MATCH</code> MBEGIN and MEND to the index of the start and end, respectively, of the
is set to the substring that matched the pattern and the integer match in <code>string</code>, such that if <code>string</code> is contained in variable var
parameters <code>MBEGIN</code> and <code>MEND</code> to the index of the start and end, the expression ${var[$MBEGIN,$MEND]} is identical to $MATCH. The
respectively, of the match in <code>string</code>, such that if <code>string</code> is setting of the option KSH_ARRAYS is respected. Likewise, the array match
contained in variable <code>var</code> the expression <code>${var[$MBEGIN,$MEND]}</code> is set to the substrings that matched parenthesised subexpressions and
is identical to <code>$MATCH</code>. The setting of the option <code>KSH_ARRAYS</code> the arrays mbegin and mend to the indices of the start and end
is respected. Likewise, the array <code>match</code> is set to the substrings positions, respectively, of the substrings within <code>string</code>. The arrays
that matched parenthesised subexpressions and the arrays <code>mbegin</code> are not set if there were no parenthesised subexpressions. For example,
and <code>mend</code> to the indices of the start and end positions, if the string a short string is matched against the regular expression
respectively, of the substrings within <code>string</code>. The arrays are not s(...)t, then (assuming the option KSH_ARRAYS is not set) MATCH,
set if there were no parenthesised subexpressions. For example, if MBEGIN and MEND are short, 3 and 7, respectively, while match, mbegin
the string <code>a short string</code> is matched against the regular and mend are single entry arrays containing the strings hor, 4 and
expression <code>s(...)t</code>, then (assuming the option <code>KSH_ARRAYS</code> is 6, respectively.</p>
not set) <code>MATCH</code>, <code>MBEGIN</code> and <code>MEND</code> are <code>short</code>, <code>3</code> and <code>7</code>, <p>If the option BASH_REMATCH is set the array BASH_REMATCH is set to the
respectively, while <code>match</code>, <code>mbegin</code> and <code>mend</code> are single entry substring that matched the pattern followed by the substrings that
arrays containing the strings <code>hor</code>, <code>4</code> and <code>6</code>, matched parenthesised subexpressions within the pattern.</p>
respectively.</p> <p><code>string1</code> &lt; <code>string2</code><br />
<p>If the option <code>BASH_REMATCH</code> is set the array <code>BASH_REMATCH</code> is set true if <code>string1</code> comes before <code>string2</code> based on ASCII value of their
to the substring that matched the pattern followed by the substrings characters.</p>
that matched parenthesised subexpressions within the pattern.</p> <p><code>string1</code> &gt; <code>string2</code><br />
</li> true if <code>string1</code> comes after <code>string2</code> based on ASCII value of their
<li> characters.</p>
<p><code>string1</code> <code>&lt;</code> <code>string2</code><br /> <p><code>exp1</code> -eq <code>exp2</code><br />
true if <code>string1</code> comes before <code>string2</code> based on ASCII value of
their characters.</p>
</li>
<li>
<p><code>string1</code> <code>&gt;</code> <code>string2</code><br />
true if <code>string1</code> comes after <code>string2</code> based on ASCII value of
their characters.</p>
</li>
<li>
<p><code>exp1</code> <code>-eq</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically equal to <code>exp2</code>. Note that for purely true if <code>exp1</code> is numerically equal to <code>exp2</code>. Note that for purely
numeric comparisons use of the <code>((``...``))</code> builtin described in numeric comparisons use of the ((<code>...</code>)) builtin described in
<a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation">Arithmetic <a href="Arithmetic-Evaluation.html#Arithmetic-Evaluation">Arithmetic
Evaluation</a> is Evaluation</a> is more
more convenient than conditional expressions.</p> convenient than conditional expressions.</p>
</li> <p><code>exp1</code> -ne <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>-ne</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically not equal to <code>exp2</code>.</p> true if <code>exp1</code> is numerically not equal to <code>exp2</code>.</p>
</li> <p><code>exp1</code> -lt <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>-lt</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically less than <code>exp2</code>.</p> true if <code>exp1</code> is numerically less than <code>exp2</code>.</p>
</li> <p><code>exp1</code> -gt <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>-gt</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically greater than <code>exp2</code>.</p> true if <code>exp1</code> is numerically greater than <code>exp2</code>.</p>
</li> <p><code>exp1</code> -le <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>-le</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically less than or equal to <code>exp2</code>.</p> true if <code>exp1</code> is numerically less than or equal to <code>exp2</code>.</p>
</li> <p><code>exp1</code> -ge <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>-ge</code> <code>exp2</code><br />
true if <code>exp1</code> is numerically greater than or equal to <code>exp2</code>.</p> true if <code>exp1</code> is numerically greater than or equal to <code>exp2</code>.</p>
</li> <p>( <code>exp</code> )<br />
<li>
<p><code>(</code> <code>exp</code> <code>)</code><br />
true if <code>exp</code> is true.</p> true if <code>exp</code> is true.</p>
</li> <p>! <code>exp</code><br />
<li>
<p><code>!</code> <code>exp</code><br />
true if <code>exp</code> is false.</p> true if <code>exp</code> is false.</p>
</li> <p><code>exp1</code> &amp;&amp; <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>&amp;&amp;</code> <code>exp2</code><br />
true if <code>exp1</code> and <code>exp2</code> are both true.</p> true if <code>exp1</code> and <code>exp2</code> are both true.</p>
</li> <p><code>exp1</code> || <code>exp2</code><br />
<li>
<p><code>exp1</code> <code>||</code> <code>exp2</code><br />
true if either <code>exp1</code> or <code>exp2</code> is true.</p> true if either <code>exp1</code> or <code>exp2</code> is true.</p>
</li>
</ul>
<p>For compatibility, if there is a single argument that is not <p>For compatibility, if there is a single argument that is not
syntactically significant, typically a variable, the condition is syntactically significant, typically a variable, the condition is
treated as a test for whether the expression expands as a string of treated as a test for whether the expression expands as a string of
non-zero length. In other words, <code>[[ $var ]]</code> is the same as <code>[[ -n $var ]]</code>. It is recommended that the second, explicit, form be used where non-zero length. In other words, [[ $var ]] is the same as [[ -n
possible.</p> $var ]]. It is recommended that the second, explicit, form be used
where possible.</p>
<p>Normal shell expansion is performed on the <code>file</code>, <code>string</code> and <p>Normal shell expansion is performed on the <code>file</code>, <code>string</code> and
<code>pattern</code> arguments, but the result of each expansion is constrained to <code>pattern</code> arguments, but the result of each expansion is constrained to
be a single word, similar to the effect of double quotes.</p> be a single word, similar to the effect of double quotes.</p>
<p>Filename generation is not performed on any form of argument to <p>Filename generation is not performed on any form of argument to
conditions. However, it can be forced in any case where normal shell conditions. However, it can be forced in any case where normal shell
expansion is valid and when the option <code>EXTENDED_GLOB</code> is in effect by expansion is valid and when the option EXTENDED_GLOB is in effect by
using an explicit glob qualifier of the form <code>(#q)</code> at the end of the using an explicit glob qualifier of the form (#q) at the end of the
string. A normal glob qualifier expression may appear between the <code>q</code> string. A normal glob qualifier expression may appear between the q
and the closing parenthesis; if none appears the expression has no and the closing parenthesis; if none appears the expression has no
effect beyond causing filename generation. The results of filename effect beyond causing filename generation. The results of filename
generation are joined together to form a single word, as with the generation are joined together to form a single word, as with the
results of other forms of expansion.</p> results of other forms of expansion.</p>
<p>This special use of filename generation is only available with the <code>[[</code> <p>This special use of filename generation is only available with the [[
syntax. If the condition occurs within the <code>[</code> or <code>test</code> builtin syntax. If the condition occurs within the [ or test builtin commands
commands then globbing occurs instead as part of normal command line then globbing occurs instead as part of normal command line expansion
expansion before the condition is evaluated. In this case it may before the condition is evaluated. In this case it may generate multiple
generate multiple words which are likely to confuse the syntax of the words which are likely to confuse the syntax of the test command.</p>
test command.</p>
<p>For example,</p> <p>For example,</p>
<div class="example"> <div class="example">
<pre><code class="language-example">[[ -n file*(#qN) ]] <pre><code class="language-zsh">[[ -n file*(#qN) ]]
</code></pre> </code></pre>
</div> </div>
<p>produces status zero if and only if there is at least one file in the <p>produces status zero if and only if there is at least one file in the
current directory beginning with the string <code>file</code>. The globbing current directory beginning with the string file. The globbing
qualifier <code>N</code> ensures that the expression is empty if there is no qualifier N ensures that the expression is empty if there is no matching
matching file.</p> file.</p>
<p>Pattern metacharacters are active for the <code>pattern</code> arguments; the <p>Pattern metacharacters are active for the <code>pattern</code> arguments; the
patterns are the same as those used for filename generation, see patterns are the same as those used for filename generation, see
<a href="Expansion.html#Filename-Generation">Filename Generation</a>, but there is <a href="Expansion.html#Filename-Generation">Filename Generation</a>, but there is
no special behaviour of <code>/</code> nor initial dots, and no glob qualifiers no special behaviour of / nor initial dots, and no glob qualifiers are
are allowed.</p> allowed.</p>
<p>In each of the above expressions, if <code>file</code> is of the form <p>In each of the above expressions, if <code>file</code> is of the form
<code>/dev/fd/``n</code>, where <code>n</code> is an integer, then the test applied to the /dev/fd/<code>n</code>, where <code>n</code> is an integer, then the test applied to the
open file whose descriptor number is <code>n</code>, even if the underlying system open file whose descriptor number is <code>n</code>, even if the underlying system
does not support the <code>/dev/fd</code> directory.</p> does not support the /dev/fd directory.</p>
<p>In the forms which do numeric comparison, the expressions <code>exp</code> undergo <p>In the forms which do numeric comparison, the expressions <code>exp</code> undergo
arithmetic expansion as if they were enclosed in <code>$((``...``))</code>.</p> arithmetic expansion as if they were enclosed in $((<code>...</code>)).</p>
<p>For example, the following:</p> <p>For example, the following:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">[[ ( -f foo || -f bar ) &amp;&amp; $report = y* ]] &amp;&amp; print File exists. <pre><code class="language-zsh">[[ ( -f foo || -f bar ) &amp;&amp; $report = y* ]] &amp;&amp; print File exists.
</code></pre> </code></pre>
</div> </div>
<p>tests if either file <code>foo</code> or file <code>bar</code> exists, and if so, if the value <p>tests if either file foo or file bar exists, and if so, if the value of
of the parameter <code>report</code> begins with <code>y</code>; if the complete condition the parameter report begins with y; if the complete condition is true,
is true, the message <code>File exists.</code> is printed.</p> the message File exists. is printed.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Arithmetic-Evaluation.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Arithmetic-Evaluation.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Prompt-Expansion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Prompt-Expansion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -472,64 +358,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Arithmetic-Evaluation.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Arithmetic-Evaluation.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Prompt-Expansion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Prompt-Expansion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Files - Zsh Manual</title> <title>Files - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html" class="active"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html" class="active"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -177,96 +154,89 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Files"></span> <span id="Files-1"></span></p> <p><span id="Files"></span> <span id="Files-2"></span></p>
<h1 id="5-files"><a class="header" href="#5-files">5 Files</a></h1> <h1 id="5-files"><a class="header" href="#5-files">5 Files</a></h1>
<hr /> <hr />
<p><span id="Startup_002fShutdown-Files"></span></p> <p><span id="Startup_002fShutdown-Files"></span></p>
<h2 id="51-startupshutdown-files"><a class="header" href="#51-startupshutdown-files">5.1 Startup/Shutdown Files</a></h2> <h2 id="51-startupshutdown-files"><a class="header" href="#51-startupshutdown-files">5.1 Startup/Shutdown Files</a></h2>
<p><span id="index-files_002c-startup"></span> <p><span id="index-files_002c-startup"></span> <span
<span id="index-startup-files"></span> id="index-startup-files"></span> <span
<span id="index-files_002c-shutdown"></span> id="index-files_002c-shutdown"></span> <span
<span id="index-shutdown-files"></span> id="index-shutdown-files"></span> <span
<span id="index-RCS_002c-use-of"></span> id="index-RCS_002c-use-of"></span> <span
<span id="index-GLOBAL_005fRCS_002c-use-of"></span> id="index-GLOBAL_005fRCS_002c-use-of"></span> <span
<span id="index-NO_005fRCS_002c-use-of"></span> id="index-NO_005fRCS_002c-use-of"></span> <span
<span id="index-NO_005fGLOBAL_005fRCS_002c-use-of"></span> id="index-NO_005fGLOBAL_005fRCS_002c-use-of"></span> <span
<span id="index-ZDOTDIR_002c-use-of"></span> id="index-ZDOTDIR_002c-use-of"></span> <span id="index-zshenv"></span></p>
<span id="index-zshenv"></span></p> <p>Commands are first read from /etc/zshenv; this cannot be overridden.
<p>Commands are first read from <code>/etc/zshenv</code>; this cannot be overridden. Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the
Subsequent behaviour is modified by the <code>RCS</code> and <code>GLOBAL_RCS</code> options; former affects all startup files, while the second only affects global
the former affects all startup files, while the second only affects startup files (those shown here with an path starting with a /). If one
global startup files (those shown here with an path starting with a of the options is unset at any point, any subsequent startup file(s) of
<code>/</code>). If one of the options is unset at any point, any subsequent the corresponding type will not be read. It is also possible for a file
startup file(s) of the corresponding type will not be read. It is also in $ZDOTDIR to re-enable GLOBAL_RCS. Both RCS and GLOBAL_RCS are set by
possible for a file in <code>$ZDOTDIR</code> to re-enable <code>GLOBAL_RCS</code>. Both <code>RCS</code> default.</p>
and <code>GLOBAL_RCS</code> are set by default.</p> <p>Commands are then read from $ZDOTDIR/.zshenv. <span
<p>Commands are then read from <code>$ZDOTDIR/.zshenv</code>. id="index-LOGIN_002c-use-of"></span> <span id="index-zprofile"></span>
<span id="index-LOGIN_002c-use-of"></span> If the shell is a login shell, commands are read from /etc/zprofile and
<span id="index-zprofile"></span> If the shell is a login shell, then $ZDOTDIR/.zprofile. <span id="index-zshrc"></span> Then, if the
commands are read from <code>/etc/zprofile</code> and then <code>$ZDOTDIR/.zprofile</code>. shell is interactive, commands are read from /etc/zshrc and then
<span id="index-zshrc"></span> Then, if the shell is interactive, $ZDOTDIR/.zshrc. <span id="index-zlogin"></span> Finally, if the shell
commands are read from <code>/etc/zshrc</code> and then <code>$ZDOTDIR/.zshrc</code>. is a login shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.</p>
<span id="index-zlogin"></span> Finally, if the shell is a login shell,
<code>/etc/zlogin</code> and <code>$ZDOTDIR/.zlogin</code> are read.</p>
<p><span id="index-zlogout"></span></p> <p><span id="index-zlogout"></span></p>
<p>When a login shell exits, the files <code>$ZDOTDIR/.zlogout</code> and then <p>When a login shell exits, the files $ZDOTDIR/.zlogout and then
<code>/etc/zlogout</code> are read. This happens with either an explicit exit via /etc/zlogout are read. This happens with either an explicit exit via the
the <code>exit</code> or <code>logout</code> commands, or an implicit exit by reading exit or logout commands, or an implicit exit by reading end-of-file from
end-of-file from the terminal. However, if the shell terminates due to the terminal. However, if the shell terminates due to execing another
<code>exec</code>ing another process, the logout files are not read. These are process, the logout files are not read. These are also affected by the
also affected by the <code>RCS</code> and <code>GLOBAL_RCS</code> options. Note also that the RCS and GLOBAL_RCS options. Note also that the RCS option affects the
<code>RCS</code> option affects the saving of history files, i.e. if <code>RCS</code> is unset saving of history files, i.e. if RCS is unset when the shell exits, no
when the shell exits, no history file will be saved.</p> history file will be saved.</p>
<p><span id="index-HOME_002c-use-of"></span></p> <p><span id="index-HOME_002c-use-of"></span></p>
<p>If <code>ZDOTDIR</code> is unset, <code>HOME</code> is used instead. Files listed above as <p>If ZDOTDIR is unset, HOME is used instead. Files listed above as being
being in <code>/etc</code> may be in another directory, depending on the in /etc may be in another directory, depending on the installation.</p>
installation.</p> <p>As /etc/zshenv is run for all instances of zsh, it is important that it
<p>As <code>/etc/zshenv</code> is run for all instances of zsh, it is important that be kept as small as possible. In particular, it is a good idea to put
it be kept as small as possible. In particular, it is a good idea to put
code that does not need to be run for every single shell behind a test code that does not need to be run for every single shell behind a test
of the form <code>if [[ -o rcs ]]; then ...</code> so that it will not be of the form if [[ -o rcs ]]; then ... so that it will not be
executed when zsh is invoked with the <code>-f</code> option.</p> executed when zsh is invoked with the -f option.</p>
<hr /> <hr />
<p><span id="Files-2"></span></p> <p><span id="Files-1"></span></p>
<h2 id="52-files"><a class="header" href="#52-files">5.2 Files</a></h2> <h2 id="52-files"><a class="header" href="#52-files">5.2 Files</a></h2>
<p><span id="index-files-used"></span></p> <p><span id="index-files-used"></span></p>
<p><code>$ZDOTDIR/.zshenv</code></p> <p>$ZDOTDIR/.zshenv</p>
<p><code>$ZDOTDIR/.zprofile</code></p> <p>$ZDOTDIR/.zprofile</p>
<p><code>$ZDOTDIR/.zshrc</code></p> <p>$ZDOTDIR/.zshrc</p>
<p><code>$ZDOTDIR/.zlogin</code></p> <p>$ZDOTDIR/.zlogin</p>
<p><code>$ZDOTDIR/.zlogout</code></p> <p>$ZDOTDIR/.zlogout</p>
<p><code>${TMPPREFIX}*</code> (default is /tmp/zsh*)</p> <p>${TMPPREFIX}* (default is /tmp/zsh*)</p>
<p><code>/etc/zshenv</code></p> <p>/etc/zshenv</p>
<p><code>/etc/zprofile</code></p> <p>/etc/zprofile</p>
<p><code>/etc/zshrc</code></p> <p>/etc/zshrc</p>
<p><code>/etc/zlogin</code></p> <p>/etc/zlogin</p>
<p><code>/etc/zlogout</code> (installation-specific - <code>/etc</code> is the default)</p> <p>/etc/zlogout (installation-specific - /etc is the default)</p>
<p>Any of these files may be pre-compiled with the <code>zcompile</code> builtin <p>Any of these files may be pre-compiled with the zcompile builtin command
command (<a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin (<a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin
Commands</a>). If a Commands</a>). If a
compiled file exists (named for the original file plus the <code>.zwc</code> compiled file exists (named for the original file plus the .zwc
extension) and it is newer than the original file, the compiled file extension) and it is newer than the original file, the compiled file
will be used instead.</p> will be used instead.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Invocation.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Invocation.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Shell-Grammar.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Shell-Grammar.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -274,64 +244,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Invocation.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Invocation.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Shell-Grammar.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Shell-Grammar.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Functions - Zsh Manual</title> <title>Functions - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html" class="active"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html" class="active"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -183,98 +160,89 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Functions"></span> <span id="Functions-3"></span></p> <p><span id="Functions"></span> <span id="Functions-4"></span></p>
<h1 id="9-functions"><a class="header" href="#9-functions">9 Functions</a></h1> <h1 id="9-functions"><a class="header" href="#9-functions">9 Functions</a></h1>
<p><span id="index-functions"></span> <p><span id="index-functions"></span> <span
<span id="index-function_002c-use-of"></span></p> id="index-function_002c-use-of"></span></p>
<p>Shell functions are defined with the <code>function</code> reserved word or the <p>Shell functions are defined with the function reserved word or the
special syntax <code>funcname</code> <code>()</code>. Shell functions are read in and stored special syntax <code>funcname</code> (). Shell functions are read in and stored
internally. Alias names are resolved when the function is read. internally. Alias names are resolved when the function is read.
Functions are executed like commands with the arguments passed as Functions are executed like commands with the arguments passed as
positional parameters. (See <a href="Command-Execution.html#Command-Execution">Command positional parameters. (See <a href="Command-Execution.html#Command-Execution">Command
Execution</a>.)</p> Execution</a>.)</p>
<p>Functions execute in the same process as the caller and share all files <p>Functions execute in the same process as the caller and share all files
and present working directory with the caller. A trap on <code>EXIT</code> set and present working directory with the caller. A trap on EXIT set inside
inside a function is executed after the function completes in the a function is executed after the function completes in the environment
environment of the caller.</p> of the caller.</p>
<p><span id="index-return_002c-use-of"></span></p> <p><span id="index-return_002c-use-of"></span></p>
<p>The <code>return</code> builtin is used to return from function calls.</p> <p>The return builtin is used to return from function calls.</p>
<p><span id="index-functions_002c-use-of"></span></p> <p><span id="index-functions_002c-use-of"></span></p>
<p>Function identifiers can be listed with the <code>functions</code> builtin. <p>Function identifiers can be listed with the functions builtin. <span
<span id="index-unfunction_002c-use-of"></span> Functions can be id="index-unfunction_002c-use-of"></span> Functions can be undefined
undefined with the <code>unfunction</code> builtin.</p> with the unfunction builtin.</p>
<hr /> <hr />
<p><span id="Autoloading-Functions"></span></p> <p><span id="Autoloading-Functions"></span></p>
<h2 id="91-autoloading-functions"><a class="header" href="#91-autoloading-functions">9.1 Autoloading Functions</a></h2> <h2 id="91-autoloading-functions"><a class="header" href="#91-autoloading-functions">9.1 Autoloading Functions</a></h2>
<p><span id="index-autoloading-functions"></span> <p><span id="index-autoloading-functions"></span> <span
<span id="index-functions_002c-autoloading"></span> id="index-functions_002c-autoloading"></span> <span
<span id="index-autoload_002c-use-of"></span> id="index-autoload_002c-use-of"></span> <span
<span id="index-fpath_002c-use-of"></span></p> id="index-fpath_002c-use-of"></span></p>
<p>A function can be marked as <em>undefined</em> using the <code>autoload</code> builtin (or <p>A function can be marked as <em>undefined</em> using the autoload builtin (or
<code>functions -u</code> or <code>typeset -fu</code>). Such a function has no body. When functions -u or typeset -fu). Such a function has no body. When the
the function is first executed, the shell searches for its definition function is first executed, the shell searches for its definition using
using the elements of the <code>fpath</code> variable. Thus to define functions for the elements of the fpath variable. Thus to define functions for
autoloading, a typical sequence is:</p> autoloading, a typical sequence is:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">fpath=(~/myfuncs $fpath) <pre><code class="language-zsh">fpath=(~/myfuncs $fpath)
autoload myfunc1 myfunc2 ... autoload myfunc1 myfunc2 ...
</code></pre> </code></pre>
</div> </div>
<p>The usual alias expansion during reading will be suppressed if the <p>The usual alias expansion during reading will be suppressed if the
<code>autoload</code> builtin or its equivalent is given the option <code>-U</code>. This is autoload builtin or its equivalent is given the option -U. This is
recommended for the use of functions supplied with the zsh distribution. recommended for the use of functions supplied with the zsh distribution.
<span id="index-zcompile_002c-use-of"></span> Note that for functions <span id="index-zcompile_002c-use-of"></span> Note that for functions
precompiled with the <code>zcompile</code> builtin command the flag <code>-U</code> must be precompiled with the zcompile builtin command the flag -U must be
provided when the <code>.zwc</code> file is created, as the corresponding provided when the .zwc file is created, as the corresponding information
information is compiled into the latter.</p> is compiled into the latter.</p>
<p>For each <code>element</code> in <code>fpath</code>, the shell looks for three possible files, <p>For each <code>element</code> in fpath, the shell looks for three possible files,
the newest of which is used to load the definition for the function:</p> the newest of which is used to load the definition for the function:</p>
<ul> <p><code>element</code>.zwc<br />
<li> A file created with the zcompile builtin command, which is expected to
<p><code>element``.zwc</code><br /> contain the definitions for all functions in the directory named
A file created with the <code>zcompile</code> builtin command, which is <code>element</code>. The file is treated in the same manner as a directory
expected to contain the definitions for all functions in the containing files for functions and is searched for the definition of the
directory named <code>element</code>. The file is treated in the same manner as function. If the definition is not found, the search for a definition
a directory containing files for functions and is searched for the proceeds with the other two possibilities described below.</p>
definition of the function. If the definition is not found, the <p>If <code>element</code> already includes a .zwc extension (i.e. the extension was
search for a definition proceeds with the other two possibilities explicitly given by the user), <code>element</code> is searched for the definition
described below.</p> of the function without comparing its age to that of other files; in
<p>If <code>element</code> already includes a <code>.zwc</code> extension (i.e. the extension fact, there does not need to be any directory named <code>element</code> without
was explicitly given by the user), <code>element</code> is searched for the the suffix. Thus including an element such as /usr/local/funcs.zwc in
definition of the function without comparing its age to that of fpath will speed up the search for functions, with the disadvantage that
other files; in fact, there does not need to be any directory named functions included must be explicitly recompiled by hand before the
<code>element</code> without the suffix. Thus including an element such as shell notices any changes.</p>
<code>/usr/local/funcs.zwc</code> in <code>fpath</code> will speed up the search for <p><code>element</code>/<code>function</code>.zwc<br />
functions, with the disadvantage that functions included must be A file created with zcompile, which is expected to contain the
explicitly recompiled by hand before the shell notices any changes.</p> definition for <code>function</code>. It may include other function definitions as
</li> well, but those are neither loaded nor executed; a file found in this
<li> way is searched <em>only</em> for the definition of <code>function</code>.</p>
<p><code>element``/``function``.zwc</code><br /> <p><code>element</code>/<code>function</code><br />
A file created with <code>zcompile</code>, which is expected to contain the A file of zsh command text, taken to be the definition for <code>function</code>.</p>
definition for <code>function</code>. It may include other function definitions
as well, but those are neither loaded nor executed; a file found in
this way is searched <em>only</em> for the definition of <code>function</code>.</p>
</li>
<li>
<p><code>element``/``function</code><br />
A file of zsh command text, taken to be the definition for
<code>function</code>.</p>
</li>
</ul>
<p>In summary, the order of searching is, first, in the <em>parents of</em> <p>In summary, the order of searching is, first, in the <em>parents of</em>
directories in <code>fpath</code> for the newer of either a compiled directory or a directories in fpath for the newer of either a compiled directory or a
directory in <code>fpath</code>; second, if more than one of these contains a directory in fpath; second, if more than one of these contains a
definition for the function that is sought, the leftmost in the <code>fpath</code> definition for the function that is sought, the leftmost in the fpath is
is chosen; and third, within a directory, the newer of either a compiled chosen; and third, within a directory, the newer of either a compiled
function or an ordinary function definition is used.</p> function or an ordinary function definition is used.</p>
<p><span id="index-KSH_005fAUTOLOAD_002c-use-of"></span></p> <p><span id="index-KSH_005fAUTOLOAD_002c-use-of"></span></p>
<p>If the <code>KSH_AUTOLOAD</code> option is set, or the file contains only a simple <p>If the KSH_AUTOLOAD option is set, or the file contains only a simple
definition of the function, the files contents will be executed. This definition of the function, the files contents will be executed. This
will normally define the function in question, but may also perform will normally define the function in question, but may also perform
initialization, which is executed in the context of the function initialization, which is executed in the context of the function
execution, and may therefore define local parameters. It is an error if execution, and may therefore define local parameters. It is an error if
the function is not defined by loading the file.</p> the function is not defined by loading the file.</p>
<p>Otherwise, the function body (with no surrounding <code>funcname``() {``...``}</code>) is taken to be the complete contents of the file. This <p>Otherwise, the function body (with no surrounding <code>funcname</code>()
{<code>...</code>}) is taken to be the complete contents of the file. This
processing of the file results in the function being re-defined, the processing of the file results in the function being re-defined, the
function itself is not re-executed. To force the shell to perform function itself is not re-executed. To force the shell to perform
initialization and then call the function defined, the file should initialization and then call the function defined, the file should
@ -282,23 +250,23 @@ contain initialization code (which will be executed then discarded) in
addition to a complete function definition (which will be retained for addition to a complete function definition (which will be retained for
subsequent calls to the function), and a call to the shell function, subsequent calls to the function), and a call to the shell function,
including any arguments, at the end.</p> including any arguments, at the end.</p>
<p>For example, suppose the autoload file <code>func</code> contains</p> <p>For example, suppose the autoload file func contains</p>
<div class="example"> <div class="example">
<pre><code class="language-example">func() { print This is func; } <pre><code class="language-zsh">func() { print This is func; }
print func is initialized print func is initialized
</code></pre> </code></pre>
</div> </div>
<p>then <code>func; func</code> with <code>KSH_AUTOLOAD</code> set will produce both messages <p>then func; func with KSH_AUTOLOAD set will produce both messages on
on the first call, but only the message <code>This is func</code> on the second the first call, but only the message This is func on the second and
and subsequent calls. Without <code>KSH_AUTOLOAD</code> set, it will produce the subsequent calls. Without KSH_AUTOLOAD set, it will produce the
initialization message on the first call, and the other message on the initialization message on the first call, and the other message on the
second and subsequent calls.</p> second and subsequent calls.</p>
<p>It is also possible to create a function that is not marked as <p>It is also possible to create a function that is not marked as
autoloaded, but which loads its own definition by searching <code>fpath</code>, by autoloaded, but which loads its own definition by searching fpath, by
using <code>autoload -X</code> within a shell function. For example, the using autoload -X within a shell function. For example, the following
following are equivalent:</p> are equivalent:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">myfunc() { <pre><code class="language-zsh">myfunc() {
autoload -X autoload -X
} }
myfunc args... myfunc args...
@ -306,42 +274,41 @@ myfunc args...
</div> </div>
<p>and</p> <p>and</p>
<div class="example"> <div class="example">
<pre><code class="language-example">unfunction myfunc # if myfunc was defined <pre><code class="language-zsh">unfunction myfunc # if myfunc was defined
autoload myfunc autoload myfunc
myfunc args... myfunc args...
</code></pre> </code></pre>
</div> </div>
<p>In fact, the <code>functions</code> command outputs <code>builtin autoload -X</code> as the <p>In fact, the functions command outputs builtin autoload -X as the body
body of an autoloaded function. This is done so that</p> of an autoloaded function. This is done so that</p>
<div class="example"> <div class="example">
<pre><code class="language-example">eval &quot;$(functions)&quot; <pre><code class="language-zsh">eval &quot;$(functions)&quot;
</code></pre> </code></pre>
</div> </div>
<p>produces a reasonable result. A true autoloaded function can be <p>produces a reasonable result. A true autoloaded function can be
identified by the presence of the comment <code># undefined</code> in the body, identified by the presence of the comment # undefined in the body,
because all comments are discarded from defined functions.</p> because all comments are discarded from defined functions.</p>
<p>To load the definition of an autoloaded function <code>myfunc</code> without <p>To load the definition of an autoloaded function myfunc without
executing <code>myfunc</code>, use:</p> executing myfunc, use:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">autoload +X myfunc <pre><code class="language-zsh">autoload +X myfunc
</code></pre> </code></pre>
</div> </div>
<hr /> <hr />
<p><span id="Anonymous-Functions"></span></p> <p><span id="Anonymous-Functions"></span></p>
<h2 id="92-anonymous-functions"><a class="header" href="#92-anonymous-functions">9.2 Anonymous Functions</a></h2> <h2 id="92-anonymous-functions"><a class="header" href="#92-anonymous-functions">9.2 Anonymous Functions</a></h2>
<p><span id="index-anonymous-functions"></span> <p><span id="index-anonymous-functions"></span> <span
<span id="index-functions_002c-anonymous"></span></p> id="index-functions_002c-anonymous"></span></p>
<p>If no name is given for a function, it is anonymous and is handled <p>If no name is given for a function, it is anonymous and is handled
specially. Either form of function definition may be used: a <code>()</code> with specially. Either form of function definition may be used: a () with
no preceding name, or a <code>function</code> with an immediately following open no preceding name, or a function with an immediately following open
brace. The function is executed immediately at the point of definition brace. The function is executed immediately at the point of definition
and is not stored for future use. The function name is set to and is not stored for future use. The function name is set to (anon).</p>
<code>(anon)</code>.</p>
<p>Arguments to the function may be specified as words following the <p>Arguments to the function may be specified as words following the
closing brace defining the function, hence if there are none no closing brace defining the function, hence if there are none no
arguments (other than <code>$0</code>) are set. This is a difference from the way arguments (other than $0) are set. This is a difference from the way
other functions are parsed: normal function definitions may be followed other functions are parsed: normal function definitions may be followed
by certain keywords such as <code>else</code> or <code>fi</code>, which will be treated as by certain keywords such as else or fi, which will be treated as
arguments to anonymous functions, so that a newline or semicolon is arguments to anonymous functions, so that a newline or semicolon is
needed to force keyword interpretation.</p> needed to force keyword interpretation.</p>
<p>Note also that the argument list of any enclosing script or function is <p>Note also that the argument list of any enclosing script or function is
@ -354,7 +321,7 @@ particularly convenient in start-up files as these do not provide their
own local variable scope.</p> own local variable scope.</p>
<p>For example,</p> <p>For example,</p>
<div class="example"> <div class="example">
<pre><code class="language-example">variable=outside <pre><code class="language-zsh">variable=outside
function { function {
local variable=inside local variable=inside
print &quot;I am $variable with arguments $*&quot; print &quot;I am $variable with arguments $*&quot;
@ -364,13 +331,13 @@ print &quot;I am $variable&quot;
</div> </div>
<p>outputs the following:</p> <p>outputs the following:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">I am inside with arguments this and that <pre><code class="language-zsh">I am inside with arguments this and that
I am outside I am outside
</code></pre> </code></pre>
</div> </div>
<p>Note that function definitions with arguments that expand to nothing, <p>Note that function definitions with arguments that expand to nothing,
for example <code>name=; function $name { ``...`` }</code>, are not treated for example name=; function $name { <code>...</code> }, are not treated as
as anonymous functions. Instead, they are treated as normal function anonymous functions. Instead, they are treated as normal function
definitions where the definition is silently discarded.</p> definitions where the definition is silently discarded.</p>
<hr /> <hr />
<p><span id="Special-Functions"></span></p> <p><span id="Special-Functions"></span></p>
@ -379,44 +346,44 @@ definitions where the definition is silently discarded.</p>
<hr /> <hr />
<p><span id="Hook-Functions"></span></p> <p><span id="Hook-Functions"></span></p>
<h3 id="931-hook-functions"><a class="header" href="#931-hook-functions">9.3.1 Hook Functions</a></h3> <h3 id="931-hook-functions"><a class="header" href="#931-hook-functions">9.3.1 Hook Functions</a></h3>
<p><span id="index-functions_002c-hook"></span> <p><span id="index-functions_002c-hook"></span> <span
<span id="index-hook-functions"></span></p> id="index-hook-functions"></span></p>
<p>For the functions below, it is possible to define an array that has the <p>For the functions below, it is possible to define an array that has the
same name as the function with <code>_functions</code> appended. Any element in same name as the function with _functions appended. Any element in
such an array is taken as the name of a function to execute; it is such an array is taken as the name of a function to execute; it is
executed in the same context and with the same arguments as the basic executed in the same context and with the same arguments and same
function. For example, if <code>$chpwd_functions</code> is an array containing the initial value of $? as the basic function. For example, if
values <code>mychpwd</code>, <code>chpwd_save_dirstack</code>, then the shell attempts to $chpwd_functions is an array containing the values mychpwd,
execute the functions <code>chpwd</code>, <code>mychpwd</code> and chpwd_save_dirstack, then the shell attempts to execute the functions
<code>chpwd_save_dirstack</code>, in that order. Any function that does not chpwd, mychpwd and chpwd_save_dirstack, in that order. Any
exist is silently ignored. A function found by this mechanism is function that does not exist is silently ignored. A function found by
referred to elsewhere as a hook function. An error in any function this mechanism is referred to elsewhere as a <em>hook function</em>. An error
causes subsequent functions not to be run. Note further that an error in in any function causes subsequent functions not to be run. Note further
a <code>precmd</code> hook causes an immediately following <code>periodic</code> function not that an error in a precmd hook causes an immediately following periodic
to run (though it may run at the next opportunity).</p> function not to run (though it may run at the next opportunity).</p>
<p><span id="index-chpwd"></span> <p><span id="index-chpwd"></span> <span
<span id="index-chpwd_005ffunctions"></span></p> id="index-chpwd_005ffunctions"></span></p>
<p><code>chpwd</code></p> <p>chpwd</p>
<p>Executed whenever the current working directory is changed.</p> <p>Executed whenever the current working directory is changed.</p>
<p><span id="index-periodic"></span> <p><span id="index-periodic"></span> <span
<span id="index-periodic_005ffunctions"></span></p> id="index-periodic_005ffunctions"></span></p>
<p><code>periodic</code></p> <p>periodic</p>
<p><span id="index-PERIOD"></span></p> <p><span id="index-PERIOD"></span></p>
<p>If the parameter <code>PERIOD</code> is set, this function is executed every <p>If the parameter PERIOD is set, this function is executed every $PERIOD
<code>$PERIOD</code> seconds, just before a prompt. Note that if multiple functions seconds, just before a prompt. Note that if multiple functions are
are defined using the array <code>periodic_functions</code> only one period is defined using the array periodic_functions only one period is applied to
applied to the complete set of functions, and the scheduled time is not the complete set of functions, and the scheduled time is not reset if
reset if the list of functions is altered. Hence the set of functions is the list of functions is altered. Hence the set of functions is always
always called together.</p> called together.</p>
<p><span id="index-precmd"></span> <p><span id="index-precmd"></span> <span
<span id="index-precmd_005ffunctions"></span></p> id="index-precmd_005ffunctions"></span></p>
<p><code>precmd</code></p> <p>precmd</p>
<p>Executed before each prompt. Note that precommand functions are not <p>Executed before each prompt. Note that precommand functions are not
re-executed simply because the command line is redrawn, as happens, for re-executed simply because the command line is redrawn, as happens, for
example, when a notification about an exiting job is displayed.</p> example, when a notification about an exiting job is displayed.</p>
<p><span id="index-preexec"></span> <p><span id="index-preexec"></span> <span
<span id="index-preexec_005ffunctions"></span></p> id="index-preexec_005ffunctions"></span></p>
<p><code>preexec</code></p> <p>preexec</p>
<p>Executed just after a command has been read and is about to be executed. <p>Executed just after a command has been read and is about to be executed.
If the history mechanism is active (regardless of whether the line was If the history mechanism is active (regardless of whether the line was
discarded from the history buffer), the string that the user typed is discarded from the history buffer), the string that the user typed is
@ -426,9 +393,9 @@ passed in two different forms: the second argument is a single-line,
size-limited version of the command (with things like function bodies size-limited version of the command (with things like function bodies
elided); the third argument contains the full text that is being elided); the third argument contains the full text that is being
executed.</p> executed.</p>
<p><span id="index-zshaddhistory"></span> <p><span id="index-zshaddhistory"></span> <span
<span id="index-zshaddhistory_005ffunctions"></span></p> id="index-zshaddhistory_005ffunctions"></span></p>
<p><code>zshaddhistory</code></p> <p>zshaddhistory</p>
<p><span id="index-history_002c-hook-when-line-is-saved"></span></p> <p><span id="index-history_002c-hook-when-line-is-saved"></span></p>
<p>Executed when a history line has been read interactively, but before it <p>Executed when a history line has been read interactively, but before it
is executed. The sole argument is the complete history line (so that any is executed. The sole argument is the complete history line (so that any
@ -441,109 +408,97 @@ it immediately.</p>
<p>If any of the hook functions returns status 2 the history line will be <p>If any of the hook functions returns status 2 the history line will be
saved on the internal history list, but not written to the history file. saved on the internal history list, but not written to the history file.
In case of a conflict, the first non-zero status value is taken.</p> In case of a conflict, the first non-zero status value is taken.</p>
<p>A hook function may call <code>fc -p</code> <code>...</code> to switch the history context <p>A hook function may call fc -p <code>...</code> to switch the history context so
so that the history is saved in a different file from the that in the that the history is saved in a different file from that in the global
global <code>HISTFILE</code> parameter. This is handled specially: the history HISTFILE parameter. This is handled specially: the history context is
context is automatically restored after the processing of the history automatically restored after the processing of the history line is
line is finished.</p> finished.</p>
<p>The following example function works with one of the options <p>The following example function works with one of the options
<code>INC_APPEND_HISTORY</code> or <code>SHARE_HISTORY</code> set, in order that the line is INC_APPEND_HISTORY or SHARE_HISTORY set, in order that the line is
written out immediately after the history entry is added. It first adds written out immediately after the history entry is added. It first adds
the history line to the normal history with the newline stripped, which the history line to the normal history with the newline stripped, which
is usually the correct behaviour. Then it switches the history context is usually the correct behaviour. Then it switches the history context
so that the line will be written to a history file in the current so that the line will be written to a history file in the current
directory.</p> directory.</p>
<div class="example"> <div class="example">
<pre><code class="language-example">zshaddhistory() { <pre><code class="language-zsh">zshaddhistory() {
print -sr -- ${1%%$'\n'} print -sr -- ${1%%$'\n'}
fc -p .zsh_local_history fc -p .zsh_local_history
} }
</code></pre> </code></pre>
</div> </div>
<p><span id="index-zshexit"></span> <p><span id="index-zshexit"></span> <span
<span id="index-zshexit_005ffunctions"></span></p> id="index-zshexit_005ffunctions"></span></p>
<p><code>zshexit</code></p> <p>zshexit</p>
<p>Executed at the point where the main shell is about to exit normally. <p>Executed at the point where the main shell is about to exit normally.
This is not called by exiting subshells, nor when the <code>exec</code> precommand This is not called by exiting subshells, nor when the exec precommand
modifier is used before an external command. Also, unlike <code>TRAPEXIT</code>, it modifier is used before an external command. Also, unlike TRAPEXIT, it
is not called when functions exit.</p> is not called when functions exit.</p>
<hr /> <hr />
<p><span id="Trap-Functions"></span></p> <p><span id="Trap-Functions"></span></p>
<h3 id="932-trap-functions"><a class="header" href="#932-trap-functions">9.3.2 Trap Functions</a></h3> <h3 id="932-trap-functions"><a class="header" href="#932-trap-functions">9.3.2 Trap Functions</a></h3>
<p>The functions below are treated specially but do not have corresponding <p>The functions below are treated specially but do not have corresponding
hook arrays.</p> hook arrays.</p>
<ul> <p>TRAP<code>NAL</code><br />
<li> <span id="index-signals_002c-trapping"></span> <span
<p><code>TRAP``NAL</code><br /> id="index-trapping-signals"></span></p>
<span id="index-signals_002c-trapping"></span>
<span id="index-trapping-signals"></span></p>
<p>If defined and non-null, this function will be executed whenever the <p>If defined and non-null, this function will be executed whenever the
shell catches a signal <code>SIG``NAL</code>, where <code>NAL</code> is a signal name as shell catches a signal SIG<code>NAL</code>, where <code>NAL</code> is a signal name as
specified for the <code>kill</code> builtin. The signal number will be passed specified for the kill builtin. The signal number will be passed as the
as the first parameter to the function.</p> first parameter to the function.</p>
<p>If a function of this form is defined and null, the shell and <p>If a function of this form is defined and null, the shell and processes
processes spawned by it will ignore <code>SIG``NAL</code>.</p> spawned by it will ignore SIG<code>NAL</code>.</p>
<p>The return status from the function is handled specially. If it is <p>The return status from the function is handled specially. If it is zero,
zero, the signal is assumed to have been handled, and execution the signal is assumed to have been handled, and execution continues
continues normally. Otherwise, the shell will behave as interrupted normally. Otherwise, the shell will behave as interrupted except that
except that the return status of the trap is retained.</p> the return status of the trap is retained.</p>
<p>Programs terminated by uncaught signals typically return the status <p>Programs terminated by uncaught signals typically return the status 128
128 plus the signal number. Hence the following causes the handler plus the signal number. Hence the following causes the handler for
for <code>SIGINT</code> to print a message, then mimic the usual effect of the SIGINT to print a message, then mimic the usual effect of the signal.</p>
signal.</p>
<div class="example"> <div class="example">
<pre><code class="language-example">TRAPINT() { <pre><code class="language-zsh">TRAPINT() {
print &quot;Caught SIGINT, aborting.&quot; print &quot;Caught SIGINT, aborting.&quot;
return $(( 128 + $1 )) return $(( 128 + $1 ))
} }
</code></pre> </code></pre>
</div> </div>
<p>The functions <code>TRAPZERR</code>, <code>TRAPDEBUG</code> and <code>TRAPEXIT</code> are never <p>The functions TRAPZERR, TRAPDEBUG and TRAPEXIT are never executed inside
executed inside other traps.</p> other traps.</p>
<p><span id="index-TRAPDEBUG"></span></p> <p><span id="index-TRAPDEBUG"></span></p>
</li> <p>TRAPDEBUG<br />
<li> If the option DEBUG_BEFORE_CMD is set (as it is by default), executed
<p><code>TRAPDEBUG</code><br /> before each command; otherwise executed after each command. See the
If the option <code>DEBUG_BEFORE_CMD</code> is set (as it is by default), description of the trap builtin in <a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin
executed before each command; otherwise executed after each command.
See the description of the <code>trap</code> builtin in <a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin
Commands</a> for Commands</a> for
details of additional features provided in debug traps.</p> details of additional features provided in debug traps.</p>
<p><span id="index-TRAPEXIT"></span></p> <p><span id="index-TRAPEXIT"></span></p>
</li> <p>TRAPEXIT<br />
<li>
<p><code>TRAPEXIT</code><br />
Executed when the shell exits, or when the current function exits if Executed when the shell exits, or when the current function exits if
defined inside a function. The value of <code>$?</code> at the start of defined inside a function. The value of $? at the start of execution is
execution is the exit status of the shell or the return status of the exit status of the shell or the return status of the function
the function exiting.</p> exiting.</p>
<p><span id="index-TRAPZERR"></span> <span id="index-TRAPERR"></span></p> <p><span id="index-TRAPZERR"></span> <span id="index-TRAPERR"></span></p>
</li> <p>TRAPZERR<br />
<li>
<p><code>TRAPZERR</code><br />
Executed whenever a command has a non-zero exit status. However, the Executed whenever a command has a non-zero exit status. However, the
function is not executed if the command occurred in a sublist function is not executed if the command occurred in a sublist followed
followed by <code>&amp;&amp;</code> or <code>||</code>; only the final command in a sublist of by &amp;&amp; or ||; only the final command in a sublist of this type
this type causes the trap to be executed. The function <code>TRAPERR</code> causes the trap to be executed. The function TRAPERR acts the same as
acts the same as <code>TRAPZERR</code> on systems where there is no <code>SIGERR</code> TRAPZERR on systems where there is no SIGERR (this is the usual case).</p>
(this is the usual case).</p>
</li>
</ul>
<p><span id="index-trap_002c-use-of"></span></p> <p><span id="index-trap_002c-use-of"></span></p>
<p>The functions beginning <code>TRAP</code> may alternatively be defined with the <p>The functions beginning TRAP may alternatively be defined with the
<code>trap</code> builtin: this may be preferable for some uses. Setting a trap trap builtin: this may be preferable for some uses. Setting a trap with
with one form removes any trap of the other form for the same signal; one form removes any trap of the other form for the same signal;
removing a trap in either form removes all traps for the same signal. removing a trap in either form removes all traps for the same signal.
The forms</p> The forms</p>
<div class="example"> <div class="example">
<pre><code class="language-example">TRAPNAL() { <pre><code class="language-zsh">TRAPNAL() {
# code # code
} }
</code></pre> </code></pre>
</div> </div>
<p>(function traps) and</p> <p>(function traps) and</p>
<div class="example"> <div class="example">
<pre><code class="language-example">trap ' <pre><code class="language-zsh">trap '
# code # code
' NAL ' NAL
</code></pre> </code></pre>
@ -563,25 +518,21 @@ zsh behaviour; list traps are reset, in accordance with POSIX
behaviour.</li> behaviour.</li>
</ul> </ul>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Command-Execution.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Command-Execution.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Jobs-&amp;-Signals.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="Jobs-_0026-Signals.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -589,64 +540,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Command-Execution.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Command-Execution.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Jobs-&amp;-Signals.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<a rel="next" href="Jobs-_0026-Signals.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Introduction - Zsh Manual</title> <title>Introduction - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html" class="active"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html" class="active"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -198,117 +175,105 @@ mechanism, and a host of other features.</p>
<p><span id="Author"></span> <span id="Author-1"></span></p> <p><span id="Author"></span> <span id="Author-1"></span></p>
<h2 id="21-author"><a class="header" href="#21-author">2.1 Author</a></h2> <h2 id="21-author"><a class="header" href="#21-author">2.1 Author</a></h2>
<p><span id="index-author"></span></p> <p><span id="index-author"></span></p>
<p>Zsh was originally written by Paul Falstad <code>&lt;pf@zsh.org&gt;</code>. Zsh is now <p>Zsh was originally written by Paul Falstad. Zsh is now maintained by the
maintained by the members of the zsh-workers mailing list members of the zsh-workers mailing list &lt;zsh-workers@zsh.org&gt;. The
<code>&lt;zsh-workers@zsh.org&gt;</code>. The development is currently coordinated by development is currently coordinated by Peter Stephenson &lt;pws@zsh.org&gt;.
Peter Stephenson <code>&lt;pws@zsh.org&gt;</code>. The coordinator can be contacted at The coordinator can be contacted at &lt;coordinator@zsh.org&gt;, but matters
<code>&lt;coordinator@zsh.org&gt;</code>, but matters relating to the code should relating to the code should generally go to the mailing list.</p>
generally go to the mailing list.</p>
<hr /> <hr />
<p><span id="Availability"></span> <span id="Availability-1"></span></p> <p><span id="Availability"></span> <span id="Availability-1"></span></p>
<h2 id="22-availability"><a class="header" href="#22-availability">2.2 Availability</a></h2> <h2 id="22-availability"><a class="header" href="#22-availability">2.2 Availability</a></h2>
<p>Zsh is available from the following HTTP and anonymous FTP site.</p> <p>Zsh is available from the following HTTP and anonymous FTP site.</p>
<p><span id="index-FTP-sites-for-zsh"></span> <p><span id="index-FTP-sites-for-zsh"></span> <span
<span id="index-acquiring-zsh-by-FTP"></span> id="index-acquiring-zsh-by-FTP"></span> <span
<span id="index-availability-of-zsh"></span></p> id="index-availability-of-zsh"></span></p>
<p><code>ftp://ftp.zsh.org/pub/</code><br /> <p><a href="ftp://ftp.zsh.org/pub/">ftp://ftp.zsh.org/pub/</a><br />
<code>https://www.zsh.org/pub/</code> )</p> <a href="https://www.zsh.org/pub/">https://www.zsh.org/pub/</a></p>
<p>The up-to-date source code is available via Git from Sourceforge. See <p>The up-to-date source code is available via Git from Sourceforge. See
<code>https://sourceforge.net/projects/zsh/</code> for details. A summary of <a href="https://sourceforge.net/projects/zsh/">https://sourceforge.net/projects/zsh/</a> for details. A summary of
instructions for the archive can be found at instructions for the archive can be found at
<code>http://zsh.sourceforge.net/</code>.</p> <a href="https://zsh.sourceforge.io/">https://zsh.sourceforge.io/</a>.</p>
<hr /> <hr />
<p><span id="Mailing-Lists"></span> <span id="Mailing-Lists-1"></span></p> <p><span id="Mailing-Lists"></span> <span id="Mailing-Lists-1"></span></p>
<h2 id="23-mailing-lists"><a class="header" href="#23-mailing-lists">2.3 Mailing Lists</a></h2> <h2 id="23-mailing-lists"><a class="header" href="#23-mailing-lists">2.3 Mailing Lists</a></h2>
<p><span id="index-mailing-lists"></span></p> <p><span id="index-mailing-lists"></span></p>
<p>Zsh has 3 mailing lists:</p> <p>Zsh has several mailing lists:</p>
<ul> <p>&lt;zsh-announce@zsh.org&gt;<br />
<li> Announcements about releases, major changes in the shell and the monthly
<p><code>&lt;zsh-announce@zsh.org&gt;</code><br /> posting of the Zsh FAQ. (moderated)</p>
Announcements about releases, major changes in the shell and the <p>&lt;zsh-users@zsh.org&gt;<br />
monthly posting of the Zsh FAQ. (moderated)</p>
</li>
<li>
<p><code>&lt;zsh-users@zsh.org&gt;</code><br />
User discussions.</p> User discussions.</p>
</li> <p>&lt;zsh-workers@zsh.org&gt;<br />
<li>
<p><code>&lt;zsh-workers@zsh.org&gt;</code><br />
Hacking, development, bug reports and patches.</p> Hacking, development, bug reports and patches.</p>
</li> <p>&lt;zsh-security@zsh.org&gt;<br />
</ul> Private mailing list (the general public cannot subscribe to it) for
discussing bug reports with security implications, i.e., potential
vulnerabilities.</p>
<p>If you find a security problem in zsh itself, please mail this address.</p>
<p>To subscribe or unsubscribe, send mail to the associated administrative <p>To subscribe or unsubscribe, send mail to the associated administrative
address for the mailing list.</p> address for the mailing list.</p>
<p><code>&lt;zsh-announce-subscribe@zsh.org&gt;</code></p> <p>&lt;zsh-announce-subscribe@zsh.org&gt;</p>
<p><code>&lt;zsh-users-subscribe@zsh.org&gt;</code></p> <p>&lt;zsh-users-subscribe@zsh.org&gt;</p>
<p><code>&lt;zsh-workers-subscribe@zsh.org&gt;</code></p> <p>&lt;zsh-workers-subscribe@zsh.org&gt;</p>
<p><code>&lt;zsh-announce-unsubscribe@zsh.org&gt;</code></p> <p>&lt;zsh-announce-unsubscribe@zsh.org&gt;</p>
<p><code>&lt;zsh-users-unsubscribe@zsh.org&gt;</code></p> <p>&lt;zsh-users-unsubscribe@zsh.org&gt;</p>
<p><code>&lt;zsh-workers-unsubscribe@zsh.org&gt;</code></p> <p>&lt;zsh-workers-unsubscribe@zsh.org&gt;</p>
<p>YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED. All <p>YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED. All
submissions to zsh-announce are automatically forwarded to zsh-users. submissions to zsh-announce are automatically forwarded to zsh-users.
All submissions to zsh-users are automatically forwarded to zsh-workers.</p> All submissions to zsh-users are automatically forwarded to zsh-workers.</p>
<p>If you have problems subscribing/unsubscribing to any of the mailing <p>If you have problems subscribing/unsubscribing to any of the mailing
lists, send mail to <code>&lt;listmaster@zsh.org&gt;</code>. The mailing lists are lists, send mail to &lt;listmaster@zsh.org&gt;.</p>
maintained by Karsten Thygesen <code>&lt;karthy@kom.auc.dk&gt;</code>.</p>
<p>The mailing lists are archived; the archives can be accessed via the <p>The mailing lists are archived; the archives can be accessed via the
administrative addresses listed above. There is also a hypertext administrative addresses listed above. There is also a hypertext archive
archive, maintained by Geoff Wing <code>&lt;gcw@zsh.org&gt;</code>, available at available at <a href="https://www.zsh.org/mla/">https://www.zsh.org/mla/</a>.</p>
<code>https://www.zsh.org/mla/</code>.</p>
<hr /> <hr />
<p><span id="The-Zsh-FAQ"></span> <span id="The-Zsh-FAQ-1"></span></p> <p><span id="The-Zsh-FAQ"></span> <span id="The-Zsh-FAQ-1"></span></p>
<h2 id="24-the-zsh-faq"><a class="header" href="#24-the-zsh-faq">2.4 The Zsh FAQ</a></h2> <h2 id="24-the-zsh-faq"><a class="header" href="#24-the-zsh-faq">2.4 The Zsh FAQ</a></h2>
<p>Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter <p>Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter
Stephenson <code>&lt;pws@zsh.org&gt;</code>. It is regularly posted to the newsgroup Stephenson &lt;pws@zsh.org&gt;. It is regularly posted to the newsgroup
comp.unix.shell and the zsh-announce mailing list. The latest version comp.unix.shell and the zsh-announce mailing list. The latest version
can be found at any of the Zsh FTP sites, or at can be found at any of the Zsh FTP sites, or at
<code>http://www.zsh.org/FAQ/</code>. The contact address for FAQ-related matters <a href="https://www.zsh.org/FAQ/">https://www.zsh.org/FAQ/</a>. The contact address for FAQ-related matters
is <code>&lt;faqmaster@zsh.org&gt;</code>.</p> is &lt;faqmaster@zsh.org&gt;.</p>
<hr /> <hr />
<p><span id="The-Zsh-Web-Page"></span> <p><span id="The-Zsh-Web-Page"></span> <span
<span id="The-Zsh-Web-Page-1"></span></p> id="The-Zsh-Web-Page-1"></span></p>
<h2 id="25-the-zsh-web-page"><a class="header" href="#25-the-zsh-web-page">2.5 The Zsh Web Page</a></h2> <h2 id="25-the-zsh-web-page"><a class="header" href="#25-the-zsh-web-page">2.5 The Zsh Web Page</a></h2>
<p>Zsh has a web page which is located at <code>https://www.zsh.org/</code>. This is <p>Zsh has a web page which is located at <a href="https://www.zsh.org/">https://www.zsh.org/</a>. The
maintained by Karsten Thygesen <code>&lt;karthy@zsh.org&gt;</code>, of SunSITE Denmark. contact address for web-related matters is &lt;webmaster@zsh.org&gt;.</p>
The contact address for web-related matters is <code>&lt;webmaster@zsh.org&gt;</code>.</p>
<hr /> <hr />
<p><span id="The-Zsh-Userguide"></span> <p><span id="The-Zsh-Userguide"></span> <span
<span id="The-Zsh-Userguide-1"></span></p> id="The-Zsh-Userguide-1"></span></p>
<h2 id="26-the-zsh-userguide"><a class="header" href="#26-the-zsh-userguide">2.6 The Zsh Userguide</a></h2> <h2 id="26-the-zsh-userguide"><a class="header" href="#26-the-zsh-userguide">2.6 The Zsh Userguide</a></h2>
<p>A userguide is currently in preparation. It is intended to complement <p>A userguide is currently in preparation. It is intended to complement
the manual, with explanations and hints on issues where the manual can the manual, with explanations and hints on issues where the manual can
be cabbalistic, hierographic, or downright mystifying (for example, the be cabbalistic, hierographic, or downright mystifying (for example, the
word hierographic does not exist). It can be viewed in its current word hierographic does not exist). It can be viewed in its current
state at <code>http://zsh.sourceforge.net/Guide/</code>. At the time of writing, state at <a href="https://zsh.sourceforge.io/Guide/">https://zsh.sourceforge.io/Guide/</a>. At the time of writing,
chapters dealing with startup files and their contents and the new chapters dealing with startup files and their contents and the new
completion system were essentially complete.</p> completion system were essentially complete.</p>
<hr /> <hr />
<p><span id="See-Also"></span> <span id="See-Also-1"></span></p> <p><span id="See-Also"></span> <span id="See-Also-1"></span></p>
<h2 id="27-see-also"><a class="header" href="#27-see-also">2.7 See Also</a></h2> <h2 id="27-see-also"><a class="header" href="#27-see-also">2.7 See Also</a></h2>
<p>man page sh(1), man page csh(1), man page tcsh(1), man page rc(1), man <p>sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)</p>
page bash(1), man page ksh(1)</p>
<p>IEEE Standard for information Technology - Part 2: Shell and Utilities, <p>IEEE Standard for information Technology - Part 2: Shell and Utilities,
IEEE Inc, 1993, ISBN 1-55937-255-9.</p> IEEE Inc, 1993, ISBN 1-55937-255-9.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="The-Z-Shell-Manual.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="The-Z-Shell-Manual.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Roadmap.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Roadmap.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -316,64 +281,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="The-Z-Shell-Manual.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="The-Z-Shell-Manual.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Roadmap.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Roadmap.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Invocation - Zsh Manual</title> <title>Invocation - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html" class="active"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html" class="active"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -178,177 +155,170 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Invocation"></span> <span id="Invocation-1"></span></p> <p><span id="Invocation"></span> <span id="Invocation-2"></span></p>
<h1 id="4-invocation"><a class="header" href="#4-invocation">4 Invocation</a></h1> <h1 id="4-invocation"><a class="header" href="#4-invocation">4 Invocation</a></h1>
<p><span id="index-invocation"></span></p> <p><span id="index-invocation"></span></p>
<hr /> <hr />
<p><span id="Invocation-2"></span></p> <p><span id="Invocation-1"></span></p>
<h2 id="41-invocation"><a class="header" href="#41-invocation">4.1 Invocation</a></h2> <h2 id="41-invocation"><a class="header" href="#41-invocation">4.1 Invocation</a></h2>
<p><span id="index-shell-options"></span> <p><span id="index-shell-options"></span> <span
<span id="index-options_002c-shell"></span> id="index-options_002c-shell"></span> <span
<span id="index-shell-flags"></span> id="index-shell-flags"></span> <span id="index-flags_002c-shell"></span></p>
<span id="index-flags_002c-shell"></span></p>
<p>The following flags are interpreted by the shell when invoked to <p>The following flags are interpreted by the shell when invoked to
determine where the shell will read commands from:</p> determine where the shell will read commands from:</p>
<ul> <p>-c<br />
<li>
<p><code>-c</code><br />
Take the first argument as a command to execute, rather than reading Take the first argument as a command to execute, rather than reading
commands from a script or standard input. If any further arguments commands from a script or standard input. If any further arguments are
are given, the first one is assigned to <code>$0</code>, rather than being used given, the first one is assigned to $0, rather than being used as a
as a positional parameter.</p> positional parameter.</p>
</li> <p>-i<br />
<li> Force shell to be interactive. It is still possible to specify a script
<p><code>-i</code><br /> to execute.</p>
Force shell to be interactive. It is still possible to specify a <p>-s<br />
script to execute.</p> Force shell to read commands from the standard input. If the -s flag is
</li> not present and an argument is given, the first argument is taken to be
<li> the pathname of a script to execute.</p>
<p><code>-s</code><br />
Force shell to read commands from the standard input. If the <code>-s</code>
flag is not present and an argument is given, the first argument is
taken to be the pathname of a script to execute.</p>
</li>
</ul>
<p>If there are any remaining arguments after option processing, and <p>If there are any remaining arguments after option processing, and
neither of the options <code>-c</code> or <code>-s</code> was supplied, the first argument is neither of the options -c or -s was supplied, the first argument is
taken as the file name of a script containing shell commands to be taken as the file name of a script containing shell commands to be
executed. If the option <code>PATH_SCRIPT</code> is set, and the file name does not executed. If the option PATH_SCRIPT is set, and the file name does not
contain a directory path (i.e. there is no <code>/</code> in the name), first the contain a directory path (i.e. there is no / in the name), first the
current directory and then the command path given by the variable <code>PATH</code> current directory and then the command path given by the variable PATH
are searched for the script. If the option is not set or the file name are searched for the script. If the option is not set or the file name
contains a <code>/</code> it is used directly.</p> contains a / it is used directly.</p>
<p>After the first one or two arguments have been appropriated as described <p>After the first one or two arguments have been appropriated as described
above, the remaining arguments are assigned to the positional above, the remaining arguments are assigned to the positional
parameters.</p> parameters.</p>
<p>For further options, which are common to invocation and the <code>set</code> <p>For further options, which are common to invocation and the set builtin,
builtin, see <a href="Options.html#Options">Options</a>.</p> see <a href="Options.html#Options">Options</a>.</p>
<p>The long option <code>-``-emulate</code> followed (in a separate word) by an <p>The long option --emulate followed (in a separate word) by an
emulation mode may be passed to the shell. The emulation modes are those emulation mode may be passed to the shell. The emulation modes are those
described for the <code>emulate</code> builtin, see <a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin described for the emulate builtin, see <a href="Shell-Builtin-Commands.html#Shell-Builtin-Commands">Shell Builtin
Commands</a>. The Commands</a>. The
<code>-``-emulate</code> option must precede any other options (which might --emulate option must precede any other options (which might otherwise
otherwise be overridden), but following options are honoured, so may be be overridden), but following options are honoured, so may be used to
used to modify the requested emulation mode. Note that certain extra modify the requested emulation mode. Note that certain extra steps are
steps are taken to ensure a smooth emulation when this option is used taken to ensure a smooth emulation when this option is used compared
compared with the <code>emulate</code> command within the shell: for example, with the emulate command within the shell: for example, variables that
variables that conflict with POSIX usage such as <code>path</code> are not defined conflict with POSIX usage such as path are not defined within the shell.</p>
within the shell.</p> <p>Options may be specified by name using the -o option. -o acts like a
<p>Options may be specified by name using the <code>-o</code> option. <code>-o</code> acts like a
single-letter option, but takes a following string as the option name. single-letter option, but takes a following string as the option name.
For example,</p> For example,</p>
<div class="example"> <div class="example">
<pre><code class="language-example">zsh -x -o shwordsplit scr <pre><code class="language-zsh">zsh -x -o shwordsplit scr
</code></pre> </code></pre>
</div> </div>
<p>runs the script <code>scr</code>, setting the <code>XTRACE</code> option by the corresponding <p>runs the script scr, setting the XTRACE option by the corresponding
letter <code>-x</code> and the <code>SH_WORD_SPLIT</code> option by name. Options may be letter -x and the SH_WORD_SPLIT option by name. Options may be turned
turned <em>off</em> by name by using <code>+o</code> instead of <code>-o</code>. <code>-o</code> can be stacked <em>off</em> by name by using +o instead of -o. -o can be stacked up with
up with preceding single-letter options, so for example <code>-xo shwordsplit</code> or <code>-xoshwordsplit</code> is equivalent to <code>-x -o shwordsplit</code>.</p> preceding single-letter options, so for example -xo shwordsplit or
-xoshwordsplit is equivalent to -x -o shwordsplit.</p>
<p><span id="index-long-option"></span></p> <p><span id="index-long-option"></span></p>
<p>Options may also be specified by name in GNU long option style, <p>Options may also be specified by name in GNU long option style,
<code>-``-``option-name</code>. When this is done, <code>-</code> characters in the --<code>option-name</code>. When this is done, - characters in the option name
option name are permitted: they are translated into <code>_</code>, and thus are permitted: they are translated into _, and thus ignored. So, for
ignored. So, for example, <code>zsh -``-sh-word-split</code> invokes zsh with the example, zsh --sh-word-split invokes zsh with the SH_WORD_SPLIT option
<code>SH_WORD_SPLIT</code> option turned on. Like other option syntaxes, options turned on. Like other option syntaxes, options can be turned off by
can be turned off by replacing the initial <code>-</code> with a <code>+</code>; thus replacing the initial - with a +; thus +-sh-word-split is
<code>+-sh-word-split</code> is equivalent to <code>-``-no-sh-word-split</code>. Unlike equivalent to --no-sh-word-split. Unlike other option syntaxes,
other option syntaxes, GNU-style long options cannot be stacked with any GNU-style long options cannot be stacked with any other options, so for
other options, so for example <code>-x-shwordsplit</code> is an error, rather example -x-shwordsplit is an error, rather than being treated like -x
than being treated like <code>-x -``-shwordsplit</code>.</p> --shwordsplit.</p>
<p><span id="index-_002d_002dversion"></span> <p><span id="index-_002d_002dversion"></span> <span
<span id="index-_002d_002dhelp"></span></p> id="index-_002d_002dhelp"></span></p>
<p>The special GNU-style option <code>-``-version</code> is handled; it sends to <p>The special GNU-style option --version is handled; it sends to
standard output the shells version information, then exits standard output the shells version information, then exits
successfully. <code>-``-help</code> is also handled; it sends to standard output successfully. --help is also handled; it sends to standard output a
a list of options that can be used when invoking the shell, then exits list of options that can be used when invoking the shell, then exits
successfully.</p> successfully.</p>
<p>Option processing may be finished, allowing following arguments that <p>Option processing may be finished, allowing following arguments that
start with <code>-</code> or <code>+</code> to be treated as normal arguments, in two start with - or + to be treated as normal arguments, in two ways.
ways. Firstly, a lone <code>-</code> (or <code>+</code>) as an argument by itself ends Firstly, a lone - (or +) as an argument by itself ends option
option processing. Secondly, a special option <code>-``-</code> (or <code>+-</code>), processing. Secondly, a special option -- (or +-), which may be
which may be specified on its own (which is the standard POSIX usage) or specified on its own (which is the standard POSIX usage) or may be
may be stacked with preceding options (so <code>-x-</code> is equivalent to <code>-x -``-</code>). Options are not permitted to be stacked after <code>-``-</code> (so stacked with preceding options (so -x- is equivalent to -x --).
<code>-x-f</code> is an error), but note the GNU-style option form discussed Options are not permitted to be stacked after -- (so -x-f is an
above, where <code>-``-shwordsplit</code> is permitted and does not end option error), but note the GNU-style option form discussed above, where
processing.</p> --shwordsplit is permitted and does not end option processing.</p>
<p>Except when the sh/ksh emulation single-letter options are in effect, <p>Except when the sh/ksh emulation single-letter options are in effect,
the option <code>-b</code> (or <code>+b</code>) ends option processing. <code>-b</code> is like the option -b (or +b) ends option processing. -b is like --,
<code>-``-</code>, except that further single-letter options can be stacked except that further single-letter options can be stacked after the -b
after the <code>-b</code> and will take effect as normal.</p> and will take effect as normal.</p>
<hr /> <hr />
<p><span id="Compatibility"></span> <span id="Compatibility-1"></span></p> <p><span id="Compatibility"></span> <span id="Compatibility-1"></span></p>
<h2 id="42-compatibility"><a class="header" href="#42-compatibility">4.2 Compatibility</a></h2> <h2 id="42-compatibility"><a class="header" href="#42-compatibility">4.2 Compatibility</a></h2>
<p><span id="index-compatibility"></span> <p><span id="index-compatibility"></span> <span
<span id="index-sh-compatibility"></span> id="index-sh-compatibility"></span> <span
<span id="index-ksh-compatibility"></span></p> id="index-ksh-compatibility"></span></p>
<p>Zsh tries to emulate sh or ksh when it is invoked as <code>sh</code> or <code>ksh</code> <p>Zsh tries to emulate sh or ksh when it is invoked as sh or ksh
respectively; more precisely, it looks at the first letter of the name respectively; more precisely, it looks at the first letter of the name
by which it was invoked, excluding any initial <code>r</code> (assumed to stand by which it was invoked, excluding any initial r (assumed to stand for
for restricted), and if that is <code>b</code>, <code>s</code> or <code>k</code> it will emulate restricted), and if that is b, s or k it will emulate sh or ksh.
sh or ksh. Furthermore, if invoked as <code>su</code> (which happens on certain Furthermore, if invoked as su (which happens on certain systems when the
systems when the shell is executed by the <code>su</code> command), the shell will shell is executed by the su command), the shell will try to find an
try to find an alternative name from the <code>SHELL</code> environment variable alternative name from the SHELL environment variable and perform
and perform emulation based on that.</p> emulation based on that.</p>
<p>In sh and ksh compatibility modes the following parameters are not <p>In sh and ksh compatibility modes the following parameters are not
special and not initialized by the shell: <code>ARGC</code>, <code>argv</code>, <code>cdpath</code>, special and not initialized by the shell: ARGC, argv, cdpath, fignore,
<code>fignore</code>, <code>fpath</code>, <code>HISTCHARS</code>, <code>mailpath</code>, <code>MANPATH</code>, <code>manpath</code>, fpath, HISTCHARS, mailpath, MANPATH, manpath, path, prompt, PROMPT,
<code>path</code>, <code>prompt</code>, <code>PROMPT</code>, <code>PROMPT2</code>, <code>PROMPT3</code>, <code>PROMPT4</code>, <code>psvar</code>, PROMPT2, PROMPT3, PROMPT4, psvar, status.</p>
<code>status</code>, <code>watch</code>.</p>
<p><span id="index-ENV_002c-use-of"></span></p> <p><span id="index-ENV_002c-use-of"></span></p>
<p>The usual zsh startup/shutdown scripts are not executed. Login shells <p>The usual zsh startup/shutdown scripts are not executed. Login shells
source <code>/etc/profile</code> followed by <code>$HOME/.profile</code>. If the <code>ENV</code> source /etc/profile followed by $HOME/.profile. If the ENV environment
environment variable is set on invocation, <code>$ENV</code> is sourced after the variable is set on invocation, $ENV is sourced after the profile
profile scripts. The value of <code>ENV</code> is subjected to parameter expansion, scripts. The value of ENV is subjected to parameter expansion, command
command substitution, and arithmetic expansion before being interpreted substitution, and arithmetic expansion before being interpreted as a
as a pathname. Note that the <code>PRIVILEGED</code> option also affects the pathname. Note that the PRIVILEGED option also affects the execution of
execution of startup files.</p> startup files.</p>
<p>The following options are set if the shell is invoked as <code>sh</code> or <code>ksh</code>: <p>The following options are set if the shell is invoked as sh or ksh:
<code>NO_BAD_PATTERN</code>, <code>NO_BANG_HIST</code>, <code>NO_BG_NICE</code>, <code>NO_EQUALS</code>, NO_BAD_PATTERN, NO_BANG_HIST, NO_BG_NICE, NO_EQUALS,
<code>NO_FUNCTION_ARGZERO</code>, <code>GLOB_SUBST</code>, <code>NO_GLOBAL_EXPORT</code>, <code>NO_HUP</code>, NO_FUNCTION_ARGZERO, GLOB_SUBST, NO_GLOBAL_EXPORT, NO_HUP,
<code>INTERACTIVE_COMMENTS</code>, <code>KSH_ARRAYS</code>, <code>NO_MULTIOS</code>, <code>NO_NOMATCH</code>, INTERACTIVE_COMMENTS, KSH_ARRAYS, NO_MULTIOS, NO_NOMATCH, NO_NOTIFY,
<code>NO_NOTIFY</code>, <code>POSIX_BUILTINS</code>, <code>NO_PROMPT_PERCENT</code>, <code>RM_STAR_SILENT</code>, POSIX_BUILTINS, NO_PROMPT_PERCENT, RM_STAR_SILENT, SH_FILE_EXPANSION,
<code>SH_FILE_EXPANSION</code>, <code>SH_GLOB</code>, <code>SH_OPTION_LETTERS</code>, <code>SH_WORD_SPLIT</code>. SH_GLOB, SH_OPTION_LETTERS, SH_WORD_SPLIT. Additionally the BSD_ECHO and
Additionally the <code>BSD_ECHO</code> and <code>IGNORE_BRACES</code> options are set if zsh IGNORE_BRACES options are set if zsh is invoked as sh. Also, the
is invoked as <code>sh</code>. Also, the <code>KSH_OPTION_PRINT</code>, <code>LOCAL_OPTIONS</code>, KSH_OPTION_PRINT, LOCAL_OPTIONS, PROMPT_BANG, PROMPT_SUBST and
<code>PROMPT_BANG</code>, <code>PROMPT_SUBST</code> and <code>SINGLE_LINE_ZLE</code> options are set if SINGLE_LINE_ZLE options are set if zsh is invoked as ksh.</p>
zsh is invoked as <code>ksh</code>.</p> <p>Please note that, whilst reasonable efforts are taken to address
incompatibilities when they arise, zsh does not guarantee complete
emulation of other shells, nor POSIX compliance. For more information on
the differences between zsh and other shells, please refer to chapter 2
of the shell FAQ, <a href="https://www.zsh.org/FAQ/">https://www.zsh.org/FAQ/</a>.</p>
<hr /> <hr />
<p><span id="Restricted-Shell"></span> <p><span id="Restricted-Shell"></span> <span
<span id="Restricted-Shell-1"></span></p> id="Restricted-Shell-1"></span></p>
<h2 id="43-restricted-shell"><a class="header" href="#43-restricted-shell">4.3 Restricted Shell</a></h2> <h2 id="43-restricted-shell"><a class="header" href="#43-restricted-shell">4.3 Restricted Shell</a></h2>
<p><span id="index-restricted-shell"></span> <p><span id="index-restricted-shell"></span> <span
<span id="index-RESTRICTED"></span></p> id="index-RESTRICTED"></span></p>
<p>When the basename of the command used to invoke zsh starts with the <p>When the basename of the command used to invoke zsh starts with the
letter <code>r</code> or the <code>-r</code> command line option is supplied at letter r or the -r command line option is supplied at invocation,
invocation, the shell becomes restricted. Emulation mode is determined the shell becomes restricted. Emulation mode is determined after
after stripping the letter <code>r</code> from the invocation name. The following stripping the letter r from the invocation name. The following are
are disabled in restricted mode:</p> disabled in restricted mode:</p>
<ul> <ul>
<li>changing directories with the <code>cd</code> builtin</li> <li>changing directories with the cd builtin</li>
<li>changing or unsetting the <code>EGID</code>, <code>EUID</code>, <code>GID</code>, <code>HISTFILE</code>, <li>changing or unsetting the EGID, EUID, GID, HISTFILE, HISTSIZE, IFS,
<code>HISTSIZE</code>, <code>IFS</code>, <code>LD_AOUT_LIBRARY_PATH</code>, <code>LD_AOUT_PRELOAD</code>, LD_AOUT_LIBRARY_PATH, LD_AOUT_PRELOAD, LD_LIBRARY_PATH, LD_PRELOAD,
<code>LD_LIBRARY_PATH</code>, <code>LD_PRELOAD</code>, <code>MODULE_PATH</code>, <code>module_path</code>, MODULE_PATH, module_path, PATH, path, SHELL, UID and USERNAME
<code>PATH</code>, <code>path</code>, <code>SHELL</code>, <code>UID</code> and <code>USERNAME</code> parameters</li> parameters</li>
<li>specifying command names containing <code>/</code></li> <li>specifying command names containing /</li>
<li>specifying command pathnames using <code>hash</code></li> <li>specifying command pathnames using hash</li>
<li>redirecting output to files</li> <li>redirecting output to files</li>
<li>using the <code>exec</code> builtin command to replace the shell with another <li>using the exec builtin command to replace the shell with another
command</li> command</li>
<li>using <code>jobs -Z</code> to overwrite the shell process argument and <li>using jobs -Z to overwrite the shell process argument and
environment space</li> environment space</li>
<li>using the <code>ARGV0</code> parameter to override <code>argv[0]</code> for external <li>using the ARGV0 parameter to override argv[0] for external
commands</li> commands</li>
<li>turning off restricted mode with <code>set +r</code> or <code>unsetopt RESTRICTED</code></li> <li>turning off restricted mode with set +r or unsetopt RESTRICTED</li>
</ul> </ul>
<p>These restrictions are enforced after processing the startup files. The <p>These restrictions are enforced after processing the startup files. The
startup files should set up <code>PATH</code> to point to a directory of commands startup files should set up PATH to point to a directory of commands
which can be safely invoked in the restricted environment. They may also which can be safely invoked in the restricted environment. They may also
add further restrictions by disabling selected builtins.</p> add further restrictions by disabling selected builtins.</p>
<p>Restricted mode can also be activated any time by setting the <p>Restricted mode can also be activated any time by setting the RESTRICTED
<code>RESTRICTED</code> option. This immediately enables all the restrictions option. This immediately enables all the restrictions described above
described above even if the shell still has not processed all startup even if the shell still has not processed all startup files.</p>
files.</p>
<p>A shell <em>Restricted Mode</em> is an outdated way to restrict what users may <p>A shell <em>Restricted Mode</em> is an outdated way to restrict what users may
do: modern systems have better, safer and more reliable ways to confine do: modern systems have better, safer and more reliable ways to confine
user actions, such as <em>chroot jails</em>, <em>containers</em> and <em>zones</em>.</p> user actions, such as <em>chroot jails</em>, <em>containers</em> and <em>zones</em>.</p>
@ -357,51 +327,47 @@ may be removed in a future version of zsh.</p>
<p>It is important to realise that the restrictions only apply to the <p>It is important to realise that the restrictions only apply to the
shell, not to the commands it runs (except for some shell builtins). shell, not to the commands it runs (except for some shell builtins).
While a restricted shell can only run the restricted list of commands While a restricted shell can only run the restricted list of commands
accessible via the predefined <code>PATH</code> variable, it does not prevent accessible via the predefined PATH variable, it does not prevent those
those commands from running any other command.</p> commands from running any other command.</p>
<p>As an example, if <code>env</code> is among the list of <em>allowed</em> commands, then <p>As an example, if env is among the list of <em>allowed</em> commands, then it
it allows the user to run any command as <code>env</code> is not a shell</p> allows the user to run any command as env is not a shell</p>
<p>So when implementing a restricted shell framework it is important to be <p>So when implementing a restricted shell framework it is important to be
fully aware of what actions each of the <em>allowed</em> commands or features fully aware of what actions each of the <em>allowed</em> commands or features
(which may be regarded as <em>modules</em>) can perform.</p> (which may be regarded as <em>modules</em>) can perform.</p>
<p>Many commands can have their behaviour affected by environment <p>Many commands can have their behaviour affected by environment
variables. Except for the few listed above, zsh does not restrict the variables. Except for the few listed above, zsh does not restrict the
setting of environment variables.</p> setting of environment variables.</p>
<p>If a <code>perl</code>, <code>python</code>, <code>bash</code>, or other general purpose <p>If a perl, python, bash, or other general purpose interpreted
interpreted script it treated as a restricted command, the user can work script it treated as a restricted command, the user can work around the
around the restriction by setting specially crafted <code>PERL5LIB</code>, restriction by setting specially crafted PERL5LIB, PYTHONPATH,
<code>PYTHONPATH</code>, <code>BASHENV</code> (etc.) environment variables. On GNU BASHENV (etc.) environment variables. On GNU systems, any command can
systems, any command can be made to run arbitrary code when performing be made to run arbitrary code when performing character set conversion
character set conversion (including zsh itself) by setting a (including zsh itself) by setting a GCONV_PATH environment variable.
<code>GCONV_PATH</code> environment variable. Those are only a few examples.</p> Those are only a few examples.</p>
<p>Bear in mind that, contrary to some other shells, <code>readonly</code> is not a <p>Bear in mind that, contrary to some other shells, readonly is not a
security feature in zsh as it can be undone and so cannot be used to security feature in zsh as it can be undone and so cannot be used to
mitigate the above.</p> mitigate the above.</p>
<p>A restricted shell only works if the allowed commands are few and <p>A restricted shell only works if the allowed commands are few and
carefully written so as not to grant more access to users than intended. carefully written so as not to grant more access to users than intended.
It is also important to restrict what zsh module the user may load as It is also important to restrict what zsh module the user may load as
some of them, such as <code>zsh/system</code>, <code>zsh/mapfile</code> and <code>zsh/files</code>, some of them, such as zsh/system, zsh/mapfile and zsh/files, allow
allow bypassing most of the restrictions.</p> bypassing most of the restrictions.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Roadmap.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Roadmap.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Files.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Files.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -409,64 +375,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Roadmap.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Roadmap.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Files.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Files.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Jobs &amp; Signals - Zsh Manual</title> <title>Jobs &amp; Signals - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html" class="active"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html" class="active"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -177,157 +154,139 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Jobs-_0026-Signals"></span> <p><span id="Jobs-_0026-Signals"></span> <span
<span id="Jobs-_0026-Signals-1"></span></p> id="Jobs-_0026-Signals-1"></span></p>
<h1 id="10-jobs--signals"><a class="header" href="#10-jobs--signals">10 Jobs &amp; Signals</a></h1> <h1 id="10-jobs--signals"><a class="header" href="#10-jobs--signals">10 Jobs &amp; Signals</a></h1>
<hr /> <hr />
<p><span id="Jobs"></span></p> <p><span id="Jobs"></span></p>
<h2 id="101-jobs"><a class="header" href="#101-jobs">10.1 Jobs</a></h2> <h2 id="101-jobs"><a class="header" href="#101-jobs">10.1 Jobs</a></h2>
<p><span id="index-jobs"></span> <p><span id="index-jobs"></span> <span
<span id="index-MONITOR_002c-use-of"></span></p> id="index-MONITOR_002c-use-of"></span></p>
<p>If the <code>MONITOR</code> option is set, an interactive shell associates a <em>job</em> <p>If the MONITOR option is set, an interactive shell associates a <em>job</em>
with each pipeline. command, and assigns them small integer numbers. with each pipeline. command, and assigns them small integer numbers.
When a job is started asynchronously with <code>&amp;</code>, the shell prints a line When a job is started asynchronously with &amp;, the shell prints a line
to standard error which looks like:</p> to standard error which looks like:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">[1] 1234 <pre><code class="language-zsh">[1] 1234
</code></pre> </code></pre>
</div> </div>
<p>indicating that the job which was started asynchronously was job number <p>indicating that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process ID was 1234.</p> 1 and had one (top-level) process, whose process ID was 1234.</p>
<p>If a job is started with <code>&amp;|</code> or <code>&amp;!</code>, then that job is immediately <p>If a job is started with &amp;| or &amp;!, then that job is immediately
disowned. After startup, it to the job control features described here.</p> disowned. After startup, it to the job control features described here.</p>
<p>If you are running a job and wish to do something else you may hit the <p>If you are running a job and wish to do something else you may hit the
key ^Z (control-Z) which sends a <code>TSTP</code> signal to the current job: this key ^Z (control-Z) which sends a TSTP signal to the current job: this
key may be redefined by the <code>susp</code> option of the external <code>stty</code> key may be redefined by the susp option of the external stty command.
command. <span id="index-jobs_002c-suspending"></span> <span id="index-jobs_002c-suspending"></span> <span
<span id="index-suspending-jobs"></span> The shell will then normally id="index-suspending-jobs"></span> The shell will then normally indicate
indicate that the job has been suspended, and print another prompt. that the job has been suspended, and print another prompt. You can
You can then manipulate the state of this job, then manipulate the state of this job, <span
<span id="index-bg_002c-use-of"></span> putting it in the background id="index-bg_002c-use-of"></span> putting it in the background with the
with the <code>bg</code> command, or run some other commands and then eventually bg command, or run some other commands and then eventually bring the job
bring the job back into the foreground with back into the foreground with <span id="index-fg_002c-use-of"></span>
<span id="index-fg_002c-use-of"></span> the foreground command <code>fg</code>. A the foreground command fg. A ^Z takes effect immediately and is like an
^Z takes effect immediately and is like an interrupt in that pending interrupt in that pending output and unread input are discarded when it
output and unread input are discarded when it is typed.</p> is typed.</p>
<p>A job being run in the background will suspend if it tries to read from <p>A job being run in the background will suspend if it tries to read from
the terminal.</p> the terminal.</p>
<p>Note that if the job running in the foreground is a shell function, then <p>Note that if the job running in the foreground is a shell function, then
suspending it will have the effect of causing the shell to fork. This is suspending it will have the effect of causing the shell to fork. This is
necessary to separate the functions state from that of the parent shell necessary to separate the functions state from that of the parent shell
performing the job control, so that the latter can return to the command performing the job control, so that the latter can return to the command
line prompt. As a result, even if <code>fg</code> is used to continue the job the line prompt. As a result, even if fg is used to continue the job the
function will no longer be part of the parent shell, and any variables function will no longer be part of the parent shell, and any variables
set by the function will not be visible in the parent shell. Thus the set by the function will not be visible in the parent shell. Thus the
behaviour is different from the case where the function was never behaviour is different from the case where the function was never
suspended. Zsh is different from many other shells in this regard.</p> suspended. Zsh is different from many other shells in this regard.</p>
<p>One additional side effect is that use of <code>disown</code> with a job created by <p>One additional side effect is that use of disown with a job created by
suspending shell code in this fashion is delayed: the job can only be suspending shell code in this fashion is delayed: the job can only be
disowned once any process started from the parent shell has terminated. disowned once any process started from the parent shell has terminated.
At that point, the disowned job disappears silently from the job list.</p> At that point, the disowned job disappears silently from the job list.</p>
<p>The same behaviour is found when the shell is executing code as the <p>The same behaviour is found when the shell is executing code as the
right hand side of a pipeline or any complex shell construct such as right hand side of a pipeline or any complex shell construct such as if,
<code>if</code>, <code>for</code>, etc., in order that the entire block of code can be managed for, etc., in order that the entire block of code can be managed as a
as a single job. <span id="index-background-jobs_002c-I_002fO"></span> single job. <span id="index-background-jobs_002c-I_002fO"></span> <span
<span id="index-jobs_002c-background_002c-I_002fO"></span> Background id="index-jobs_002c-background_002c-I_002fO"></span> Background jobs are
jobs are normally allowed to produce output, but this can be disabled by normally allowed to produce output, but this can be disabled by giving
giving the command <code>stty tostop</code>. If you set this tty option, then the command stty tostop. If you set this tty option, then background
background jobs will suspend when they try to produce output like they jobs will suspend when they try to produce output like they do when they
do when they try to read input.</p> try to read input.</p>
<p>When a command is suspended and continued later with the <code>fg</code> or <code>wait</code> <p>When a command is suspended and continued later with the fg or wait
builtins, zsh restores tty modes that were in effect when it was builtins, zsh restores tty modes that were in effect when it was
suspended. This (intentionally) does not apply if the command is suspended. This (intentionally) does not apply if the command is
continued via <code>kill -CONT</code>, nor when it is continued with <code>bg</code>.</p> continued via kill -CONT, nor when it is continued with bg.</p>
<p><span id="index-jobs_002c-referring-to"></span> <p><span id="index-jobs_002c-referring-to"></span> <span
<span id="index-referring-to-jobs"></span></p> id="index-referring-to-jobs"></span></p>
<p>There are several ways to refer to jobs in the shell. A job can be <p>There are several ways to refer to jobs in the shell. A job can be
referred to by the process ID of any process of the job or by one of the referred to by the process ID of any process of the job or by one of the
following:</p> following:</p>
<ul> <p>%<code>number</code><br />
<li>
<p><code>%``number</code><br />
The job with the given number.</p> The job with the given number.</p>
</li> <p>%<code>string</code><br />
<li>
<p><code>%``string</code><br />
The last job whose command line begins with <code>string</code>.</p> The last job whose command line begins with <code>string</code>.</p>
</li> <p>%?<code>string</code><br />
<li>
<p><code>%?``string</code><br />
The last job whose command line contains <code>string</code>.</p> The last job whose command line contains <code>string</code>.</p>
</li> <p>%%<br />
<li>
<p><code>%%</code><br />
Current job.</p> Current job.</p>
</li> <p>%+<br />
<li> Equivalent to %%.</p>
<p><code>%+</code><br /> <p>%-<br />
Equivalent to <code>%%</code>.</p>
</li>
<li>
<p><code>%-</code><br />
Previous job.</p> Previous job.</p>
</li> <p>The shell learns immediately whenever a process changes state. <span
</ul> id="index-NOTIFY_002c-use-of"></span> It normally informs you whenever a
<p>The shell learns immediately whenever a process changes state. job becomes blocked so that no further progress is possible. If the
<span id="index-NOTIFY_002c-use-of"></span> It normally informs you NOTIFY option is not set, it waits until just before it prints a prompt
whenever a job becomes blocked so that no further progress is possible. before it informs you. All such notifications are sent directly to the
If the <code>NOTIFY</code> option is not set, it waits until just before it prints terminal, not to the standard output or standard error.</p>
a prompt before it informs you. All such notifications are sent directly
to the terminal, not to the standard output or standard error.</p>
<p>When the monitor mode is on, each background job that completes triggers <p>When the monitor mode is on, each background job that completes triggers
any trap set for <code>CHLD</code>.</p> any trap set for CHLD.</p>
<p>When you try to leave the shell while jobs are running or suspended, you <p>When you try to leave the shell while jobs are running or suspended, you
will be warned that You have suspended (running) jobs. You may use the will be warned that You have suspended (running) jobs. You may use the
<code>jobs</code> command to see what they are. If you do this or immediately try jobs command to see what they are. If you do this or immediately try to
to exit again, the shell will not warn you a second time; the suspended exit again, the shell will not warn you a second time; the suspended
jobs will be terminated, and the running jobs will be sent a <code>SIGHUP</code> jobs will be terminated, and the running jobs will be sent a SIGHUP
signal, if the <code>HUP</code> option is set. signal, if the HUP option is set. <span
<span id="index-HUP_002c-use-of"></span></p> id="index-HUP_002c-use-of"></span></p>
<p><span id="index-jobs_002c-disowning"></span> <p><span id="index-jobs_002c-disowning"></span> <span
<span id="index-disowning-jobs"></span> id="index-disowning-jobs"></span> <span
<span id="index-disown_002c-use-of"></span></p> id="index-disown_002c-use-of"></span></p>
<p>To avoid having the shell terminate the running jobs, either use the <p>To avoid having the shell terminate the running jobs, either use the
nohup command (see man page nohup(1)) or the <code>disown</code> builtin.</p> nohup(1) command or the disown builtin.</p>
<hr /> <hr />
<p><span id="Signals"></span></p> <p><span id="Signals"></span></p>
<h2 id="102-signals"><a class="header" href="#102-signals">10.2 Signals</a></h2> <h2 id="102-signals"><a class="header" href="#102-signals">10.2 Signals</a></h2>
<p>The <code>INT</code> and <code>QUIT</code> signals for an invoked command are ignored if the <p>The INT and QUIT signals for an invoked command are ignored if the
command is followed by <code>&amp;</code> and the <code>MONITOR</code> option is not active. The command is followed by &amp; and the MONITOR option is not active. The
shell itself always ignores the <code>QUIT</code> signal. Otherwise, signals have shell itself always ignores the QUIT signal. Otherwise, signals have the
the values inherited by the shell from its parent (but see the values inherited by the shell from its parent (but see the TRAP<code>NAL</code>
<code>TRAP``NAL</code> special functions in <a href="Functions.html#Functions">Functions</a>).</p> special functions in <a href="Functions.html#Functions">Functions</a>).</p>
<p><span id="index-exiting-shell_002c-and-asynchronous-jobs"></span> <p><span id="index-exiting-shell_002c-and-asynchronous-jobs"></span> <span
<span id="index-asynchronous-jobs_002c-and-exiting-shell"></span> id="index-asynchronous-jobs_002c-and-exiting-shell"></span> <span
<span id="index-jobs_002c-asynchronous_002c-and-exiting-shell"></span></p> id="index-jobs_002c-asynchronous_002c-and-exiting-shell"></span></p>
<p>Certain jobs are run asynchronously by the shell other than those <p>Certain jobs are run asynchronously by the shell other than those
explicitly put into the background; even in cases where the shell would explicitly put into the background; even in cases where the shell would
usually wait for such jobs, an explicit <code>exit</code> command or exit due to usually wait for such jobs, an explicit exit command or exit due to the
the option <code>ERR_EXIT</code> will cause the shell to exit without waiting. option ERR_EXIT will cause the shell to exit without waiting. Examples
Examples of such asynchronous jobs are process substitution, see of such asynchronous jobs are process substitution, see <a href="Expansion.html#Process-Substitution">Process
<a href="Expansion.html#Process-Substitution">Process Substitution</a>, and the Substitution</a>, and the handler
handler processes for multios, see the section Multios in processes for multios, see the section <em>Multios</em> in
<a href="Redirection.html#Redirection">Redirection</a>.</p> <a href="Redirection.html#Redirection">Redirection</a>.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Functions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Functions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Arithmetic-Evaluation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Arithmetic-Evaluation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -335,64 +294,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Functions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Functions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Arithmetic-Evaluation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Arithmetic-Evaluation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Prompt Expansion - Zsh Manual</title> <title>Prompt Expansion - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html" class="active"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html" class="active"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -184,34 +161,34 @@
<li><a href="#133-conditional-substrings-in-prompts">13.3 Conditional Substrings in Prompts</a></li> <li><a href="#133-conditional-substrings-in-prompts">13.3 Conditional Substrings in Prompts</a></li>
</ul> </ul>
</li> </li>
<li><a href="#"></a></li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Prompt-Expansion"></span> <p><span id="Prompt-Expansion"></span> <span
<span id="Prompt-Expansion-1"></span></p> id="Prompt-Expansion-1"></span></p>
<h1 id="13-prompt-expansion"><a class="header" href="#13-prompt-expansion">13 Prompt Expansion</a></h1> <h1 id="13-prompt-expansion"><a class="header" href="#13-prompt-expansion">13 Prompt Expansion</a></h1>
<hr /> <hr />
<p><span id="Expansion-of-Prompt-Sequences"></span></p> <p><span id="Expansion-of-Prompt-Sequences"></span></p>
<h2 id="131-expansion-of-prompt-sequences"><a class="header" href="#131-expansion-of-prompt-sequences">13.1 Expansion of Prompt Sequences</a></h2> <h2 id="131-expansion-of-prompt-sequences"><a class="header" href="#131-expansion-of-prompt-sequences">13.1 Expansion of Prompt Sequences</a></h2>
<p><span id="index-prompt-expansion"></span> <p><span id="index-prompt-expansion"></span> <span
<span id="index-expansion_002c-prompt"></span></p> id="index-expansion_002c-prompt"></span></p>
<p>Prompt sequences undergo a special form of expansion. This type of <p>Prompt sequences undergo a special form of expansion. This type of
expansion is also available using the <code>-P</code> option to the <code>print</code> expansion is also available using the -P option to the print builtin.</p>
builtin.</p>
<p><span id="index-PROMPT_005fSUBST_002c-use-of"></span></p> <p><span id="index-PROMPT_005fSUBST_002c-use-of"></span></p>
<p>If the <code>PROMPT_SUBST</code> option is set, the prompt string is first <p>If the PROMPT_SUBST option is set, the prompt string is first subjected
subjected to <em>parameter expansion</em>, <em>command substitution</em> and to <em>parameter expansion</em>, <em>command substitution</em> and <em>arithmetic
<em>arithmetic expansion</em>. See <a href="Expansion.html#Expansion">Expansion</a>.</p> expansion</em>. See <a href="Expansion.html#Expansion">Expansion</a>.</p>
<p>Certain escape sequences may be recognised in the prompt string.</p> <p>Certain escape sequences may be recognised in the prompt string.</p>
<p><span id="index-PROMPT_005fBANG_002c-use-of"></span></p> <p><span id="index-PROMPT_005fBANG_002c-use-of"></span></p>
<p>If the <code>PROMPT_BANG</code> option is set, a <code>!</code> in the prompt is replaced by <p>If the PROMPT_BANG option is set, a ! in the prompt is replaced by the
the current history event number. A literal <code>!</code> may then be current history event number. A literal ! may then be represented as
represented as <code>!!</code>.</p> !!.</p>
<p><span id="index-PROMPT_005fPERCENT_002c-use-of"></span></p> <p><span id="index-PROMPT_005fPERCENT_002c-use-of"></span></p>
<p>If the <code>PROMPT_PERCENT</code> option is set, certain escape sequences that <p>If the PROMPT_PERCENT option is set, certain escape sequences that start
start with <code>%</code> are expanded. Many escapes are followed by a single with % are expanded. Many escapes are followed by a single character,
character, although some of these take an optional integer argument that although some of these take an optional integer argument that should
should appear between the <code>%</code> and the next character of the sequence. appear between the % and the next character of the sequence. More
More complicated escape sequences are available to provide conditional complicated escape sequences are available to provide conditional
expansion.</p> expansion.</p>
<hr /> <hr />
<p><span id="Simple-Prompt-Escapes"></span></p> <p><span id="Simple-Prompt-Escapes"></span></p>
@ -219,470 +196,310 @@ expansion.</p>
<hr /> <hr />
<p><span id="Special-characters"></span></p> <p><span id="Special-characters"></span></p>
<h3 id="1321-special-characters"><a class="header" href="#1321-special-characters">13.2.1 Special characters</a></h3> <h3 id="1321-special-characters"><a class="header" href="#1321-special-characters">13.2.1 Special characters</a></h3>
<ul> <p>%%<br />
<li> A %.</p>
<p><code>%%</code><br /> <p>%)<br />
A <code>%</code>.</p> A ).</p>
</li>
<li>
<p><code>%)</code><br />
A <code>)</code>.</p>
</li>
</ul>
<hr /> <hr />
<p><span id="Login-information"></span></p> <p><span id="Login-information"></span></p>
<h3 id="1322-login-information"><a class="header" href="#1322-login-information">13.2.2 Login information</a></h3> <h3 id="1322-login-information"><a class="header" href="#1322-login-information">13.2.2 Login information</a></h3>
<ul> <p>%l<br />
<li> The line (tty) the user is logged in on, without /dev/ prefix. If the
<p><code>%l</code><br /> name starts with /dev/tty, that prefix is stripped.</p>
The line (tty) the user is logged in on, without <code>/dev/</code> prefix. <p>%M<br />
If the name starts with <code>/dev/tty</code>, that prefix is stripped.</p>
</li>
<li>
<p><code>%M</code><br />
The full machine hostname.</p> The full machine hostname.</p>
</li> <p>%m<br />
<li> The hostname up to the first .. An integer may follow the % to
<p><code>%m</code><br /> specify how many components of the hostname are desired. With a negative
The hostname up to the first <code>.</code>. An integer may follow the <code>%</code> integer, trailing components of the hostname are shown.</p>
to specify how many components of the hostname are desired. With a <p>%n<br />
negative integer, trailing components of the hostname are shown.</p> $USERNAME.</p>
</li> <p>%y<br />
<li> The line (tty) the user is logged in on, without /dev/ prefix. This
<p><code>%n</code><br /> does not treat /dev/tty names specially.</p>
<code>$USERNAME</code>.</p>
</li>
<li>
<p><code>%y</code><br />
The line (tty) the user is logged in on, without <code>/dev/</code> prefix.
This does not treat <code>/dev/tty</code> names specially.</p>
</li>
</ul>
<hr /> <hr />
<p><span id="Shell-state"></span></p> <p><span id="Shell-state"></span></p>
<h3 id="1323-shell-state"><a class="header" href="#1323-shell-state">13.2.3 Shell state</a></h3> <h3 id="1323-shell-state"><a class="header" href="#1323-shell-state">13.2.3 Shell state</a></h3>
<ul> <p>%#<br />
<li> A # if the shell is running with privileges, a % if not. Equivalent
<p><code>%#</code><br /> to %(!.#.%%). The definition of privileged, for these purposes, is
A <code>#</code> if the shell is running with privileges, a <code>%</code> if not. that either the effective user ID is zero, or, if POSIX.1e capabilities
Equivalent to <code>%(!.#.%%)</code>. The definition of privileged, for are supported, that capability vectors.</p>
these purposes, is that either the effective user ID is zero, or, if <p>%?<br />
POSIX.1e capabilities are supported, that capability vectors.</p> The return status of the last command executed just before the prompt.</p>
</li> <p>%_<br />
<li> The status of the parser, i.e. the shell constructs (like if and
<p><code>%?</code><br /> for) that have been started on the command line. If given an integer
The return status of the last command executed just before the number that many strings will be printed; zero or negative or no integer
prompt.</p> means print as many as there are. This is most useful in prompts PS2 for
</li> continuation lines and PS4 for debugging with the XTRACE option; in the
<li> latter case it will also work non-interactively.</p>
<p><code>%_</code><br /> <p>%^<br />
The status of the parser, i.e. the shell constructs (like <code>if</code> and The status of the parser in reverse. This is the same as %_ other
<code>for</code>) that have been started on the command line. If given an than the order of strings. It is often used in RPS2.</p>
integer number that many strings will be printed; zero or negative <p>%d<br />
or no integer means print as many as there are. This is most useful %/<br />
in prompts <code>PS2</code> for continuation lines and <code>PS4</code> for debugging with Current working directory. If an integer follows the %, it specifies a
the <code>XTRACE</code> option; in the latter case it will also work number of trailing components of the current working directory to show;
non-interactively.</p> zero means the whole path. A negative integer specifies leading
</li> components, i.e. %-1d specifies the first component.</p>
<li> <p>%~<br />
<p><code>%^</code><br /> As %d and %/, but if the current working directory starts with $HOME,
The status of the parser in reverse. This is the same as <code>%_</code> that part is replaced by a ~. Furthermore, if it has a named
other than the order of strings. It is often used in <code>RPS2</code>.</p> directory as its prefix, that part is replaced by a ~ followed by the
</li> name of the directory, but only if the result is shorter than the full
<li> path; <a href="Expansion.html#Filename-Expansion">Filename Expansion</a>.</p>
<p><code>%d</code><br /> <p>%e<br />
<code>%/</code><br /> Evaluation depth of the current sourced file, shell function, or eval.
Current working directory. If an integer follows the <code>%</code>, it This is incremented or decremented every time the value of %N is set or
specifies a number of trailing components of the current working reverted to a previous value, respectively. This is most useful for
directory to show; zero means the whole path. A negative integer debugging as part of $PS4.</p>
specifies leading components, i.e. <code>%-1d</code> specifies the first <p>%h<br />
component.</p> %!<br />
</li>
<li>
<p><code>%~</code><br />
As <code>%d</code> and <code>%/</code>, but if the current working directory starts with
<code>$HOME</code>, that part is replaced by a <code>~</code>. Furthermore, if it has a
named directory as its prefix, that part is replaced by a <code>~</code>
followed by the name of the directory, but only if the result is
shorter than the full path; <a href="Expansion.html#Filename-Expansion">Filename
Expansion</a>.</p>
</li>
<li>
<p><code>%e</code><br />
Evaluation depth of the current sourced file, shell function, or
<code>eval</code>. This is incremented or decremented every time the value of
<code>%N</code> is set or reverted to a previous value, respectively. This is
most useful for debugging as part of <code>$PS4</code>.</p>
</li>
<li>
<p><code>%h</code><br />
<code>%!</code><br />
Current history event number.</p> Current history event number.</p>
</li> <p>%i<br />
<li> The line number currently being executed in the script, sourced file, or
<p><code>%i</code><br /> shell function given by %N. This is most useful for debugging as part of
The line number currently being executed in the script, sourced $PS4.</p>
file, or shell function given by <code>%N</code>. This is most useful for <p>%I<br />
debugging as part of <code>$PS4</code>.</p> The line number currently being executed in the file %x. This is similar
</li> to %i, but the line number is always a line number in the file where the
<li> code was defined, even if the code is a shell function.</p>
<p><code>%I</code><br /> <p>%j<br />
The line number currently being executed in the file <code>%x</code>. This is
similar to <code>%i</code>, but the line number is always a line number in the
file where the code was defined, even if the code is a shell
function.</p>
</li>
<li>
<p><code>%j</code><br />
The number of jobs.</p> The number of jobs.</p>
</li> <p>%L<br />
<li> The current value of $SHLVL.</p>
<p><code>%L</code><br /> <p>%N<br />
The current value of <code>$SHLVL</code>.</p>
</li>
<li>
<p><code>%N</code><br />
The name of the script, sourced file, or shell function that zsh is The name of the script, sourced file, or shell function that zsh is
currently executing, whichever was started most recently. If there currently executing, whichever was started most recently. If there is
is none, this is equivalent to the parameter <code>$0</code>. An integer may none, this is equivalent to the parameter $0. An integer may follow the
follow the <code>%</code> to specify a number of trailing path components to % to specify a number of trailing path components to show; zero means
show; zero means the full path. A negative integer specifies leading the full path. A negative integer specifies leading components.</p>
components.</p> <p>%x<br />
</li>
<li>
<p><code>%x</code><br />
The name of the file containing the source code currently being The name of the file containing the source code currently being
executed. This behaves as <code>%N</code> except that function and eval command executed. This behaves as %N except that function and eval command names
names are not shown, instead the file where they were defined.</p> are not shown, instead the file where they were defined.</p>
</li> <p>%c<br />
<li> %.<br />
<p><code>%c</code><br /> %C<br />
<code>%.</code><br />
<code>%C</code><br />
Trailing component of the current working directory. An integer may Trailing component of the current working directory. An integer may
follow the <code>%</code> to get more than one component. Unless <code>%C</code> is follow the % to get more than one component. Unless %C is used,
used, tilde contraction is performed first. These are deprecated as tilde contraction is performed first. These are deprecated as %c and %C
<code>%c</code> and <code>%C</code> are equivalent to <code>%1~</code> and <code>%1/</code>, respectively, while are equivalent to %1~ and %1/, respectively, while explicit positive
explicit positive integers have the same effect as for the latter integers have the same effect as for the latter two sequences.</p>
two sequences.</p>
</li>
</ul>
<hr /> <hr />
<p><span id="Date-and-time"></span></p> <p><span id="Date-and-time"></span></p>
<h3 id="1324-date-and-time"><a class="header" href="#1324-date-and-time">13.2.4 Date and time</a></h3> <h3 id="1324-date-and-time"><a class="header" href="#1324-date-and-time">13.2.4 Date and time</a></h3>
<ul> <p>%D<br />
<li> The date in <code>yy</code>-<code>mm</code>-<code>dd</code> format.</p>
<p><code>%D</code><br /> <p>%T<br />
The date in <code>yy``-``mm``-``dd</code> format.</p>
</li>
<li>
<p><code>%T</code><br />
Current time of day, in 24-hour format.</p> Current time of day, in 24-hour format.</p>
</li> <p>%t<br />
<li> %@<br />
<p><code>%t</code><br />
<code>%@</code><br />
Current time of day, in 12-hour, am/pm format.</p> Current time of day, in 12-hour, am/pm format.</p>
</li> <p>%*<br />
<li>
<p><code>%*</code><br />
Current time of day in 24-hour format, with seconds.</p> Current time of day in 24-hour format, with seconds.</p>
</li> <p>%w<br />
<li> The date in <code>day</code>-<code>dd</code> format.</p>
<p><code>%w</code><br /> <p>%W<br />
The date in <code>day``-``dd</code> format.</p> The date in <code>mm</code>/<code>dd</code>/<code>yy</code> format.</p>
</li> <p>%D{<code>string</code>}<br />
<li> <code>string</code> is formatted using the strftime function. See strftime(3) for
<p><code>%W</code><br /> more details. Various zsh extensions provide numbers with no leading
The date in <code>mm``/``dd``/``yy</code> format.</p> zero or space if the number is a single digit:</p>
</li> <p>%f<br />
<li>
<p><code>%D{``string``}</code><br />
<code>string</code> is formatted using the <code>strftime</code> function. See man page
strftime(3) for more details. Various zsh extensions provide numbers
with no leading zero or space if the number is a single digit:</p>
<ul>
<li>
<p><code>%f</code><br />
a day of the month</p> a day of the month</p>
</li> <p>%K<br />
<li>
<p><code>%K</code><br />
the hour of the day on the 24-hour clock</p> the hour of the day on the 24-hour clock</p>
</li> <p>%L<br />
<li>
<p><code>%L</code><br />
the hour of the day on the 12-hour clock</p> the hour of the day on the 12-hour clock</p>
</li> <p>In addition, if the system supports the POSIX gettimeofday system call,
</ul> %. provides decimal fractions of a second since the epoch with leading
<p>In addition, if the system supports the POSIX <code>gettimeofday</code> system zeroes. By default three decimal places are provided, but a number of
call, <code>%.</code> provides decimal fractions of a second since the epoch digits up to 9 may be given following the %; hence %6. outputs
with leading zeroes. By default three decimal places are provided, microseconds, and %9. outputs nanoseconds. (The latter requires a
but a number of digits up to 9 may be given following the <code>%</code>; hence nanosecond-precision clock_gettime; systems lacking this will return a
<code>%6.</code> outputs microseconds, and <code>%9.</code> outputs nanoseconds. (The value multiplied by the appropriate power of 10.) A typical example of
latter requires a nanosecond-precision <code>clock_gettime</code>; systems this is the format %D{%H:%M:%S.%.}.</p>
lacking this will return a value multiplied by the appropriate power <p>The GNU extension %N is handled as a synonym for %9..</p>
of 10.) A typical example of this is the format <code>%D{%H:%M:%S.%.}</code>.</p> <p>Additionally, the GNU extension that a - between the % and the format
<p>The GNU extension <code>%N</code> is handled as a synonym for <code>%9.</code>.</p> character causes a leading zero or space to be stripped is handled
<p>Additionally, the GNU extension that a <code>-</code> between the <code>%</code> and the directly by the shell for the format characters d, f, H, k, l, m, M, S
format character causes a leading zero or space to be stripped is and y; any other format characters are provided to the systems
handled directly by the shell for the format characters <code>d</code>, <code>f</code>, strftime(3) with any leading - present, so the handling is system
<code>H</code>, <code>k</code>, <code>l</code>, <code>m</code>, <code>M</code>, <code>S</code> and <code>y</code>; any other format characters dependent. Further GNU (or other) extensions are also passed to
are provided to the systems strftime(3) with any leading <code>-</code> strftime(3) and may work if the system supports them.</p>
present, so the handling is system dependent. Further GNU (or other)
extensions are also passed to strftime(3) and may work if the system
supports them.</p>
</li>
</ul>
<hr /> <hr />
<p><span id="Visual-effects"></span></p> <p><span id="Visual-effects"></span></p>
<h3 id="1325-visual-effects"><a class="header" href="#1325-visual-effects">13.2.5 Visual effects</a></h3> <h3 id="1325-visual-effects"><a class="header" href="#1325-visual-effects">13.2.5 Visual effects</a></h3>
<ul> <p>%B (%b)<br />
<li>
<p><code>%B</code> (<code>%b</code>)<br />
Start (stop) boldface mode.</p> Start (stop) boldface mode.</p>
</li> <p>%E<br />
<li>
<p><code>%E</code><br />
Clear to end of line.</p> Clear to end of line.</p>
</li> <p>%U (%u)<br />
<li>
<p><code>%U</code> (<code>%u</code>)<br />
Start (stop) underline mode.</p> Start (stop) underline mode.</p>
</li> <p>%S (%s)<br />
<li>
<p><code>%S</code> (<code>%s</code>)<br />
Start (stop) standout mode.</p> Start (stop) standout mode.</p>
</li> <p>%F (%f)<br />
<li> Start (stop) using a different foreground colour, if supported by the
<p><code>%F</code> (<code>%f</code>)<br /> terminal. The colour may be specified two ways: either as a numeric
Start (stop) using a different foreground colour, if supported by argument, as normal, or by a sequence in braces following the %F, for
the terminal. The colour may be specified two ways: either as a example %F{red}. In the latter case the values allowed are as described
numeric argument, as normal, or by a sequence in braces following for the fg zle_highlight attribute; <a href="Zsh-Line-Editor.html#Character-Highlighting">Character
the <code>%F</code>, for example <code>%F{red}</code>. In the latter case the values Highlighting</a>. This means
allowed are as described for the <code>fg</code> <code>zle_highlight</code> attribute; that numeric colours are allowed in the second format also.</p>
<a href="Zsh-Line-Editor.html#Character-Highlighting">Character <p>%K (%k)<br />
Highlighting</a>. This
means that numeric colours are allowed in the second format also.</p>
</li>
<li>
<p><code>%K</code> (<code>%k</code>)<br />
Start (stop) using a different bacKground colour. The syntax is Start (stop) using a different bacKground colour. The syntax is
identical to that for <code>%F</code> and <code>%f</code>.</p> identical to that for %F and %f.</p>
</li> <p>%{...%}<br />
<li>
<p><code>%{</code>...<code>%}</code><br />
Include a string as a literal escape sequence. The string within the Include a string as a literal escape sequence. The string within the
braces should not change the cursor position. Brace pairs can nest.</p> braces should not change the cursor position. Brace pairs can nest.</p>
<p>A positive numeric argument between the <code>%</code> and the <code>{</code> is treated <p>A positive numeric argument between the % and the { is treated as
as described for <code>%G</code> below.</p> described for %G below.</p>
</li> <p>%G<br />
<li> Within a %{...%} sequence, include a glitch: that is, assume that a
<p><code>%G</code><br /> single character width will be output. This is useful when outputting
Within a <code>%{</code>...<code>%}</code> sequence, include a glitch: that is, assume characters that otherwise cannot be correctly handled by the shell, such
that a single character width will be output. This is useful when as the alternate character set on some terminals. The characters in
outputting characters that otherwise cannot be correctly handled by question can be included within a %{...%} sequence together with the
the shell, such as the alternate character set on some terminals. appropriate number of %G sequences to indicate the correct width. An
The characters in question can be included within a <code>%{</code>...<code>%}</code> integer between the % and G indicates a character width other than
sequence together with the appropriate number of <code>%G</code> sequences to one. Hence %{<code>seq</code>%2G%} outputs <code>seq</code> and assumes it takes up the width
indicate the correct width. An integer between the <code>%</code> and <code>G</code> of two standard characters.</p>
indicates a character width other than one. Hence <code>%{``seq``%2G%}</code> <p>Multiple uses of %G accumulate in the obvious fashion; the position of
outputs <code>seq</code> and assumes it takes up the width of two standard the %G is unimportant. Negative integers are not handled.</p>
characters.</p> <p>Note that when prompt truncation is in use it is advisable to divide up
<p>Multiple uses of <code>%G</code> accumulate in the obvious fashion; the output into single characters within each %{...%} group so that the
position of the <code>%G</code> is unimportant. Negative integers are not correct truncation point can be found.</p>
handled.</p>
<p>Note that when prompt truncation is in use it is advisable to divide
up output into single characters within each <code>%{</code>...<code>%}</code> group so
that the correct truncation point can be found.</p>
</li>
</ul>
<hr /> <hr />
<p><span id="Conditional-Substrings-in-Prompts"></span></p> <p><span id="Conditional-Substrings-in-Prompts"></span></p>
<h2 id="133-conditional-substrings-in-prompts"><a class="header" href="#133-conditional-substrings-in-prompts">13.3 Conditional Substrings in Prompts</a></h2> <h2 id="133-conditional-substrings-in-prompts"><a class="header" href="#133-conditional-substrings-in-prompts">13.3 Conditional Substrings in Prompts</a></h2>
<ul> <p>%v<br />
<li>
<p><code>%v</code><br />
<span id="index-psvar_002c-use-of"></span></p> <span id="index-psvar_002c-use-of"></span></p>
<p>The value of the first element of the <code>psvar</code> array parameter. <p>The value of the first element of the psvar array parameter. Following
Following the <code>%</code> with an integer gives that element of the array. the % with an integer gives that element of the array. Negative
Negative integers count from the end of the array.</p> integers count from the end of the array.</p>
</li> <p>%(<code>x</code>.<code>true-text</code>.<code>false-text</code>)<br />
<li>
<p><code>%(``x``.``true-text``.``false-text``)</code><br />
Specifies a ternary expression. The character following the <code>x</code> is Specifies a ternary expression. The character following the <code>x</code> is
arbitrary; the same character is used to separate the text for the arbitrary; the same character is used to separate the text for the
true result from that for the false result. This separator may true result from that for the false result. This separator may not
not appear in the <code>true-text</code>, except as part of a %-escape appear in the <code>true-text</code>, except as part of a %-escape sequence. A )
sequence. A <code>)</code> may appear in the <code>false-text</code> as <code>%)</code>. may appear in the <code>false-text</code> as %). <code>true-text</code> and <code>false-text</code> may
<code>true-text</code> and <code>false-text</code> may both contain arbitrarily-nested both contain arbitrarily-nested escape sequences, including further
escape sequences, including further ternary expressions.</p> ternary expressions.</p>
<p>The left parenthesis may be preceded or followed by a positive <p>The left parenthesis may be preceded or followed by a positive integer
integer <code>n</code>, which defaults to zero. A negative integer will be <code>n</code>, which defaults to zero. A negative integer will be multiplied by
multiplied by -1, except as noted below for <code>l</code>. The test -1, except as noted below for l. The test character <code>x</code> may be any of
character <code>x</code> may be any of the following:</p> the following:</p>
<ul> <p>!<br />
<li>
<p><code>!</code><br />
True if the shell is running with privileges.</p> True if the shell is running with privileges.</p>
</li> <h1 id=""><a class="header" href="#"></a></h1>
<li> <p>True if the effective uid of the current process is <code>n</code>.</p>
<p><code>#</code><br /> <p>?<br />
True if the effective uid of the current process is <code>n</code>.</p>
</li>
<li>
<p><code>?</code><br />
True if the exit status of the last command was <code>n</code>.</p> True if the exit status of the last command was <code>n</code>.</p>
</li> <p>_<br />
<li>
<p><code>_</code><br />
True if at least <code>n</code> shell constructs were started.</p> True if at least <code>n</code> shell constructs were started.</p>
</li> <p>C<br />
<li> /<br />
<p><code>C</code><br /> True if the current absolute path has at least <code>n</code> elements relative to
<code>/</code><br /> the root directory, hence / is counted as 0 elements.</p>
True if the current absolute path has at least <code>n</code> elements <p>c<br />
relative to the root directory, hence <code>/</code> is counted as 0 .<br />
~<br />
True if the current path, with prefix replacement, has at least <code>n</code>
elements relative to the root directory, hence / is counted as 0
elements.</p> elements.</p>
</li> <p>D<br />
<li>
<p><code>c</code><br />
<code>.</code><br />
<code>~</code><br />
True if the current path, with prefix replacement, has at least
<code>n</code> elements relative to the root directory, hence <code>/</code> is
counted as 0 elements.</p>
</li>
<li>
<p><code>D</code><br />
True if the month is equal to <code>n</code> (January = 0).</p> True if the month is equal to <code>n</code> (January = 0).</p>
</li> <p>d<br />
<li>
<p><code>d</code><br />
True if the day of the month is equal to <code>n</code>.</p> True if the day of the month is equal to <code>n</code>.</p>
</li> <p>e<br />
<li>
<p><code>e</code><br />
True if the evaluation depth is at least <code>n</code>.</p> True if the evaluation depth is at least <code>n</code>.</p>
</li> <p>g<br />
<li>
<p><code>g</code><br />
True if the effective gid of the current process is <code>n</code>.</p> True if the effective gid of the current process is <code>n</code>.</p>
</li> <p>j<br />
<li>
<p><code>j</code><br />
True if the number of jobs is at least <code>n</code>.</p> True if the number of jobs is at least <code>n</code>.</p>
</li> <p>L<br />
<li> True if the SHLVL parameter is at least <code>n</code>.</p>
<p><code>L</code><br /> <p>l<br />
True if the <code>SHLVL</code> parameter is at least <code>n</code>.</p> True if at least <code>n</code> characters have already been printed on the current
</li> line. When <code>n</code> is negative, true if at least abs(<code>n</code>) characters remain
<li> before the opposite margin (thus the left margin for RPROMPT).</p>
<p><code>l</code><br /> <p>S<br />
True if at least <code>n</code> characters have already been printed on the True if the SECONDS parameter is at least <code>n</code>.</p>
current line. When <code>n</code> is negative, true if at least <p>T<br />
<code>abs``(``n``)</code> characters remain before the opposite margin
(thus the left margin for <code>RPROMPT</code>).</p>
</li>
<li>
<p><code>S</code><br />
True if the <code>SECONDS</code> parameter is at least <code>n</code>.</p>
</li>
<li>
<p><code>T</code><br />
True if the time in hours is equal to <code>n</code>.</p> True if the time in hours is equal to <code>n</code>.</p>
</li> <p>t<br />
<li>
<p><code>t</code><br />
True if the time in minutes is equal to <code>n</code>.</p> True if the time in minutes is equal to <code>n</code>.</p>
</li> <p>v<br />
<li> True if the array psvar has at least <code>n</code> elements.</p>
<p><code>v</code><br /> <p>V<br />
True if the array <code>psvar</code> has at least <code>n</code> elements.</p> True if element <code>n</code> of the array psvar is set and non-empty.</p>
</li> <p>w<br />
<li>
<p><code>V</code><br />
True if element <code>n</code> of the array <code>psvar</code> is set and non-empty.</p>
</li>
<li>
<p><code>w</code><br />
True if the day of the week is equal to <code>n</code> (Sunday = 0).</p> True if the day of the week is equal to <code>n</code> (Sunday = 0).</p>
</li> <p>%&lt;<code>string</code>&lt;<br />
</ul> %&gt;<code>string</code>&gt;<br />
</li> %[<code>xstring</code>]<br />
<li> Specifies truncation behaviour for the remainder of the prompt string.
<p><code>%&lt;``string``&lt;</code><br /> The third, deprecated, form is equivalent to %<code>xstringx</code>, i.e. <code>x</code> may
<code>%&gt;``string``&gt;</code><br /> be &lt; or &gt;. The <code>string</code> will be displayed in place of the truncated
<code>%[``xstring``]</code><br /> portion of any string; note this does not undergo prompt expansion.</p>
Specifies truncation behaviour for the remainder of the prompt
string. The third, deprecated, form is equivalent to
<code>%``xstringx</code>, i.e. <code>x</code> may be <code>&lt;</code> or <code>&gt;</code>. The <code>string</code>
will be displayed in place of the truncated portion of any string;
note this does not undergo prompt expansion.</p>
<p>The numeric argument, which in the third form may appear immediately <p>The numeric argument, which in the third form may appear immediately
after the <code>[</code>, specifies the maximum permitted length of the after the [, specifies the maximum permitted length of the various
various strings that can be displayed in the prompt. In the first strings that can be displayed in the prompt. In the first two forms,
two forms, this numeric argument may be negative, in which case the this numeric argument may be negative, in which case the truncation
truncation length is determined by subtracting the absolute value of length is determined by subtracting the absolute value of the numeric
the numeric argument from the number of character positions argument from the number of character positions remaining on the current
remaining on the current prompt line. If this results in a zero or prompt line. If this results in a zero or negative length, a length of 1
negative length, a length of 1 is used. In other words, a negative is used. In other words, a negative argument arranges that after
argument arranges that after truncation at least <code>n</code> characters truncation at least <code>n</code> characters remain before the right margin (left
remain before the right margin (left margin for <code>RPROMPT</code>).</p> margin for RPROMPT).</p>
<p>The forms with <code>&lt;</code> truncate at the left of the string, and the <p>The forms with &lt; truncate at the left of the string, and the forms
forms with <code>&gt;</code> truncate at the right of the string. For example, with &gt; truncate at the right of the string. For example, if the
if the current directory is <code>/home/pike</code>, the prompt <code>%8&lt;..&lt;%/</code> current directory is /home/pike, the prompt %8&lt;..&lt;%/ will expand
will expand to <code>..e/pike</code>. In this string, the terminating to ..e/pike. In this string, the terminating character (&lt;, &gt; or
character (<code>&lt;</code>, <code>&gt;</code> or <code>]</code>), or in fact any character, may be ]), or in fact any character, may be quoted by a preceding \; note
quoted by a preceding <code>\</code>; note when using <code>print -P</code>, however, when using print -P, however, that this must be doubled as the string is
that this must be doubled as the string is also subject to standard also subject to standard print processing, in addition to any
<code>print</code> processing, in addition to any backslashes removed by a backslashes removed by a double quoted string: the worst case is
double quoted string: the worst case is therefore <code>print -P &quot;%&lt;\\&lt;&lt;...&quot;</code>.</p> therefore print -P &quot;%&lt;\\\\&lt;&lt;...&quot;.</p>
<p>If the <code>string</code> is longer than the specified truncation length, it <p>If the <code>string</code> is longer than the specified truncation length, it will
will appear in full, completely replacing the truncated string.</p> appear in full, completely replacing the truncated string.</p>
<p>The part of the prompt string to be truncated runs to the end of the <p>The part of the prompt string to be truncated runs to the end of the
string, or to the end of the next enclosing group of the <code>%(</code> string, or to the end of the next enclosing group of the %( construct,
construct, or to the next truncation encountered at the same or to the next truncation encountered at the same grouping level (i.e.
grouping level (i.e. truncations inside a <code>%(</code> are separate), truncations inside a %( are separate), which ever comes first. In
which ever comes first. In particular, a truncation with argument particular, a truncation with argument zero (e.g., %&lt;&lt;) marks the
zero (e.g., <code>%&lt;&lt;</code>) marks the end of the range of the string to be end of the range of the string to be truncated while turning off
truncated while turning off truncation from there on. For example, truncation from there on. For example, the prompt %10&lt;...&lt;%~%&lt;&lt;%#
the prompt <code>%10&lt;...&lt;%~%&lt;&lt;%# </code> will print a truncated will print a truncated representation of the current directory,
representation of the current directory, followed by a <code>%</code> or followed by a % or #, followed by a space. Without the %&lt;&lt;,
<code>#</code>, followed by a space. Without the <code>%&lt;&lt;</code>, those two those two characters would be included in the string to be truncated.
characters would be included in the string to be truncated. Note Note that %-0&lt;&lt; is not equivalent to %&lt;&lt; but specifies that the
that <code>%-0&lt;&lt;</code> is not equivalent to <code>%&lt;&lt;</code> but specifies that the
prompt is truncated at the right margin.</p> prompt is truncated at the right margin.</p>
<p>Truncation applies only within each individual line of the prompt, <p>Truncation applies only within each individual line of the prompt, as
as delimited by embedded newlines (if any). If the total length of delimited by embedded newlines (if any). If the total length of any line
any line of the prompt after truncation is greater than the terminal of the prompt after truncation is greater than the terminal width, or if
width, or if the part to be truncated contains embedded newlines, the part to be truncated contains embedded newlines, truncation behavior
truncation behavior is undefined and may change in a future version is undefined and may change in a future version of the shell. Use
of the shell. Use <code>%-``n``(l.``true-text``.``false-text``)</code> to %-<code>n</code>(l.<code>true-text</code>.<code>false-text</code>) to remove parts of the prompt when
remove parts of the prompt when the available space is less than the available space is less than <code>n</code>.</p>
<code>n</code>.</p>
</li>
</ul>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Conditional-Expressions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Conditional-Expressions.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Expansion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Expansion.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -690,64 +507,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Conditional-Expressions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Conditional-Expressions.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Expansion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Expansion.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Redirection - Zsh Manual</title> <title>Redirection - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html" class="active"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html" class="active"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -180,11 +157,11 @@
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="Redirection"></span> <span id="Redirection-1"></span></p> <p><span id="Redirection"></span> <span id="Redirection-1"></span></p>
<h1 id="7-redirection"><a class="header" href="#7-redirection">7 Redirection</a></h1> <h1 id="7-redirection"><a class="header" href="#7-redirection">7 Redirection</a></h1>
<p><span id="index-redirection"></span> <p><span id="index-redirection"></span> <span
<span id="index-file-descriptors"></span> id="index-file-descriptors"></span> <span
<span id="index-descriptors_002c-file"></span></p> id="index-descriptors_002c-file"></span></p>
<p>If a command is followed by <code>&amp;</code> and job control is not active, then the <p>If a command is followed by &amp; and job control is not active, then the
default standard input for the command is the empty file <code>/dev/null</code>. default standard input for the command is the empty file /dev/null.
Otherwise, the environment for the execution of a command contains the Otherwise, the environment for the execution of a command contains the
file descriptors of the invoking shell as modified by input/output file descriptors of the invoking shell as modified by input/output
specifications.</p> specifications.</p>
@ -193,128 +170,86 @@ follow a complex command. Expansion occurs before <code>word</code> or <code>dig
used except as noted below. If the result of substitution on <code>word</code> used except as noted below. If the result of substitution on <code>word</code>
produces more than one filename, redirection occurs for each separate produces more than one filename, redirection occurs for each separate
filename in turn.</p> filename in turn.</p>
<ul> <p>&lt; <code>word</code><br />
<li> Open file <code>word</code> for reading as standard input. It is an error to open a
<p><code>&lt;</code> <code>word</code><br /> file in this fashion if it does not exist.</p>
Open file <code>word</code> for reading as standard input. It is an error to <p>&lt;&gt; <code>word</code><br />
open a file in this fashion if it does not exist.</p> Open file <code>word</code> for reading and writing as standard input. If the file
</li> does not exist then it is created.</p>
<li> <p>&gt; <code>word</code><br />
<p><code>&lt;&gt;</code> <code>word</code><br /> Open file <code>word</code> for writing as standard output. If the file does not
Open file <code>word</code> for reading and writing as standard input. If the exist then it is created. If the file exists, and the CLOBBER option is
file does not exist then it is created.</p> unset, this causes an error; otherwise, it is truncated to zero length.</p>
</li> <p>&gt;| <code>word</code><br />
<li> &gt;! <code>word</code><br />
<p><code>&gt;</code> <code>word</code><br /> Same as &gt;, except that the file is truncated to zero length if it
Open file <code>word</code> for writing as standard output. If the file does exists, regardless of CLOBBER.</p>
not exist then it is created. If the file exists, and the <code>CLOBBER</code> <p>&gt;&gt; <code>word</code><br />
option is unset, this causes an error; otherwise, it is truncated to Open file <code>word</code> for writing in append mode as standard output. If the
zero length.</p> file does not exist, and the CLOBBER and APPEND_CREATE options are both
</li> unset, this causes an error; otherwise, the file is created.</p>
<li> <p>&gt;&gt;| <code>word</code><br />
<p><code>&gt;|</code> <code>word</code><br /> &gt;&gt;! <code>word</code><br />
<code>&gt;!</code> <code>word</code><br /> Same as &gt;&gt;, except that the file is created if it does not exist,
Same as <code>&gt;</code>, except that the file is truncated to zero length if it regardless of CLOBBER and APPEND_CREATE.</p>
exists, regardless of <code>CLOBBER</code>.</p> <p>&lt;&lt;[-] <code>word</code><br />
</li> The shell input is read up to a line that is the same as <code>word</code>, or to
<li> an end-of-file. No parameter expansion, command substitution or filename
<p><code>&gt;&gt;</code> <code>word</code><br /> generation is performed on <code>word</code>. The resulting document, called a
Open file <code>word</code> for writing in append mode as standard output. If <em>here-document</em>, becomes the standard input.</p>
the file does not exist, and the <code>CLOBBER</code> and <code>APPEND_CREATE</code> <p>If any character of <code>word</code> is quoted with single or double quotes or a
options are both unset, this causes an error; otherwise, the file is \, no interpretation is placed upon the characters of the document.
created.</p> Otherwise, parameter and command substitution occurs, \ followed by a
</li> newline is removed, and \ must be used to quote the characters \,
<li> $, and the first character of <code>word</code>.</p>
<p><code>&gt;&gt;|</code> <code>word</code><br /> <p>Note that <code>word</code> itself does not undergo shell expansion. Backquotes in
<code>&gt;&gt;!</code> <code>word</code><br /> <code>word</code> do not have their usual effect; instead they behave similarly to
Same as <code>&gt;&gt;</code>, except that the file is created if it does not exist, double quotes, except that the backquotes themselves are passed through
regardless of <code>CLOBBER</code> and <code>APPEND_CREATE</code>.</p> unchanged. (This information is given for completeness and it is not
</li> recommended that backquotes be used.) Quotes in the form $<code>...</code> have
<li> their standard effect of expanding backslashed references to special
<p><code>&lt;&lt;</code>[<code>-</code>] <code>word</code><br /> characters.</p>
The shell input is read up to a line that is the same as <code>word</code>, or <p>If &lt;&lt;- is used, then all leading tabs are stripped from <code>word</code> and
to an end-of-file. No parameter expansion, command substitution or
filename generation is performed on <code>word</code>. The resulting document,
called a <em>here-document</em>, becomes the standard input.</p>
<p>If any character of <code>word</code> is quoted with single or double quotes or
a <code>\</code>, no interpretation is placed upon the characters of the
document. Otherwise, parameter and command substitution occurs,
<code>\</code> followed by a newline is removed, and <code>\</code> must be used
to quote the characters <code>\</code>, <code>$</code>, <code></code> and the first character
of <code>word</code>.</p>
<p>Note that <code>word</code> itself does not undergo shell expansion. Backquotes
in <code>word</code> do not have their usual effect; instead they behave
similarly to double quotes, except that the backquotes themselves
are passed through unchanged. (This information is given for
completeness and it is not recommended that backquotes be used.)
Quotes in the form <code>$``...``</code> have their standard effect of
expanding backslashed references to special characters.</p>
<p>If <code>&lt;&lt;-</code> is used, then all leading tabs are stripped from <code>word</code> and
from the document.</p> from the document.</p>
</li> <p>&lt;&lt;&lt; <code>word</code><br />
<li> Perform shell expansion on <code>word</code> and pass the result to standard input.
<p><code>&lt;&lt;&lt;</code> <code>word</code><br /> This is known as a <em>here-string</em>. Compare the use of <code>word</code> in
Perform shell expansion on <code>word</code> and pass the result to standard here-documents above, where <code>word</code> does not undergo shell expansion. The
input. This is known as a <em>here-string</em>. Compare the use of <code>word</code> result will have a trailing newline after it.</p>
in here-documents above, where <code>word</code> does not undergo shell <p>&lt;&amp; <code>number</code><br />
expansion.</p> &gt;&amp; <code>number</code><br />
</li> The standard input/output is duplicated from file descriptor <code>number</code>
<li> (see dup2(2)).</p>
<p><code>&lt;&amp;</code> <code>number</code><br /> <p>&lt;&amp; -<br />
<code>&gt;&amp;</code> <code>number</code><br /> &gt;&amp; -<br />
The standard input/output is duplicated from file descriptor
<code>number</code> (see man page dup2(2)).</p>
</li>
<li>
<p><code>&lt;&amp; -</code><br />
<code>&gt;&amp; -</code><br />
Close the standard input/output.</p> Close the standard input/output.</p>
</li> <p>&lt;&amp; p<br />
<li> &gt;&amp; p<br />
<p><code>&lt;&amp; p</code><br />
<code>&gt;&amp; p</code><br />
The input/output from/to the coprocess is moved to the standard The input/output from/to the coprocess is moved to the standard
input/output.</p> input/output.</p>
</li> <p>&gt;&amp; <code>word</code><br />
<li> &amp;&gt; <code>word</code><br />
<p><code>&gt;&amp;</code> <code>word</code><br /> (Except where &gt;&amp; <code>word</code> matches one of the above syntaxes; &amp;&gt; can
<code>&amp;&gt;</code> <code>word</code><br /> always be used to avoid this ambiguity.) Redirects both standard output
(Except where <code>&gt;&amp;</code> <code>word</code> matches one of the above syntaxes; and standard error (file descriptor 2) in the manner of &gt; <code>word</code>. Note
<code>&amp;&gt;</code> can always be used to avoid this ambiguity.) Redirects that this does <em>not</em> have the same effect as &gt; <code>word</code> 2&gt;&amp;1 in the
both standard output and standard error (file descriptor 2) in the presence of multios (see the section below).</p>
manner of <code>&gt;</code> <code>word</code>. Note that this does <em>not</em> have the same <p>&gt;&amp;| <code>word</code><br />
effect as <code>&gt;</code> <code>word</code> <code>2&gt;&amp;1</code> in the presence of multios (see the &gt;&amp;! <code>word</code><br />
section below).</p> &amp;&gt;| <code>word</code><br />
</li> &amp;&gt;! <code>word</code><br />
<li> Redirects both standard output and standard error (file descriptor 2) in
<p><code>&gt;&amp;|</code> <code>word</code><br /> the manner of &gt;| <code>word</code>.</p>
<code>&gt;&amp;!</code> <code>word</code><br /> <p>&gt;&gt;&amp; <code>word</code><br />
<code>&amp;&gt;|</code> <code>word</code><br /> &amp;&gt;&gt; <code>word</code><br />
<code>&amp;&gt;!</code> <code>word</code><br /> Redirects both standard output and standard error (file descriptor 2) in
Redirects both standard output and standard error (file descriptor</p> the manner of &gt;&gt; <code>word</code>.</p>
<ol start="2"> <p>&gt;&gt;&amp;| <code>word</code><br />
<li>in the manner of <code>&gt;|</code> <code>word</code>.</li> &gt;&gt;&amp;! <code>word</code><br />
</ol> &amp;&gt;&gt;| <code>word</code><br />
</li> &amp;&gt;&gt;! <code>word</code><br />
<li> Redirects both standard output and standard error (file descriptor 2) in
<p><code>&gt;&gt;&amp;</code> <code>word</code><br /> the manner of &gt;&gt;| <code>word</code>.</p>
<code>&amp;&gt;&gt;</code> <code>word</code><br />
Redirects both standard output and standard error (file descriptor</p>
<ol start="2">
<li>in the manner of <code>&gt;&gt;</code> <code>word</code>.</li>
</ol>
</li>
<li>
<p><code>&gt;&gt;&amp;|</code> <code>word</code><br />
<code>&gt;&gt;&amp;!</code> <code>word</code><br />
<code>&amp;&gt;&gt;|</code> <code>word</code><br />
<code>&amp;&gt;&gt;!</code> <code>word</code><br />
Redirects both standard output and standard error (file descriptor</p>
<ol start="2">
<li>in the manner of <code>&gt;&gt;|</code> <code>word</code>.</li>
</ol>
</li>
</ul>
<p>If one of the above is preceded by a digit, then the file descriptor <p>If one of the above is preceded by a digit, then the file descriptor
referred to is that specified by the digit instead of the default 0 or</p> referred to is that specified by the digit instead of the default 0 or</p>
<ol> <ol>
@ -323,7 +258,7 @@ shell evaluates each redirection in terms of the (<em>file descriptor</em>,
<em>file</em>) association at the time of evaluation. For example:</li> <em>file</em>) association at the time of evaluation. For example:</li>
</ol> </ol>
<blockquote> <blockquote>
<p>... <code>1&gt;``fname</code> <code>2&gt;&amp;1</code></p> <p>... 1&gt;<code>fname</code> 2&gt;&amp;1</p>
</blockquote> </blockquote>
<p>first associates file descriptor 1 with file <code>fname</code>. It then associates <p>first associates file descriptor 1 with file <code>fname</code>. It then associates
file descriptor 2 with the file associated with file descriptor 1 (that file descriptor 2 with the file associated with file descriptor 1 (that
@ -331,227 +266,216 @@ is, <code>fname</code>). If the order of redirections were reversed, file
descriptor 2 would be associated with the terminal (assuming file descriptor 2 would be associated with the terminal (assuming file
descriptor 1 had been) and then file descriptor 1 would be associated descriptor 1 had been) and then file descriptor 1 would be associated
with file <code>fname</code>.</p> with file <code>fname</code>.</p>
<p>The <code>|&amp;</code> command separator described in <a href="Shell-Grammar.html#Simple-Commands-_0026-Pipelines">Simple Commands &amp; <p>The |&amp; command separator described in <a href="Shell-Grammar.html#Simple-Commands-_0026-Pipelines">Simple Commands &amp;
Pipelines</a> is a Pipelines</a> is a
shorthand for <code>2&gt;&amp;1 |</code>.</p> shorthand for 2&gt;&amp;1 |.</p>
<p>The various forms of process substitution, <code>&lt;(``list``)</code>, and <p>The various forms of process substitution, &lt;(<code>list</code>), and =(<code>list</code>)
<code>=(``list``)</code> for input and <code>&gt;(``list``)</code> for output, are often for input and &gt;(<code>list</code>) for output, are often used together with
used together with redirection. For example, if <code>word</code> in an output redirection. For example, if <code>word</code> in an output redirection is of the
redirection is of the form <code>&gt;(``list``)</code> then the output is piped to form &gt;(<code>list</code>) then the output is piped to the command represented by
the command represented by <code>list</code>. See <a href="Expansion.html#Process-Substitution">Process <code>list</code>. See <a href="Expansion.html#Process-Substitution">Process Substitution</a>.</p>
Substitution</a>.</p>
<hr /> <hr />
<p><span id="Opening-file-descriptors-using-parameters"></span></p> <p><span id="Opening-file-descriptors-using-parameters"></span></p>
<h2 id="71-opening-file-descriptors-using-parameters"><a class="header" href="#71-opening-file-descriptors-using-parameters">7.1 Opening file descriptors using parameters</a></h2> <h2 id="71-opening-file-descriptors-using-parameters"><a class="header" href="#71-opening-file-descriptors-using-parameters">7.1 Opening file descriptors using parameters</a></h2>
<p><span id="index-file-descriptors_002c-use-with-parameters"></span> <p><span id="index-file-descriptors_002c-use-with-parameters"></span> <span
<span id="index-parameters_002c-for-using-file-descriptors"></span></p> id="index-parameters_002c-for-using-file-descriptors"></span></p>
<p>When the shell is parsing arguments to a command, and the shell option <p>When the shell is parsing arguments to a command, and the shell option
<code>IGNORE_BRACES</code> is not set, a different form of redirection is allowed: IGNORE_BRACES is not set, a different form of redirection is allowed:
instead of a digit before the operator there is a valid shell identifier instead of a digit before the operator there is a valid shell identifier
enclosed in braces. The shell will open a new file descriptor that is enclosed in braces. The shell will open a new file descriptor that is
guaranteed to be at least 10 and set the parameter named by the guaranteed to be at least 10 and set the parameter named by the
identifier to the file descriptor opened. No whitespace is allowed identifier to the file descriptor opened. No whitespace is allowed
between the closing brace and the redirection character. For example:</p> between the closing brace and the redirection character. For example:</p>
<blockquote> <blockquote>
<p>... <code>{myfd}&gt;&amp;1</code></p> <p>... {myfd}&gt;&amp;1</p>
</blockquote> </blockquote>
<p>This opens a new file descriptor that is a duplicate of file descriptor <p>This opens a new file descriptor that is a duplicate of file descriptor
1 and sets the parameter <code>myfd</code> to the number of the file descriptor, 1 and sets the parameter myfd to the number of the file descriptor,
which will be at least 10. The new file descriptor can be written to which will be at least 10. The new file descriptor can be written to
using the syntax <code>&gt;&amp;$myfd</code>. The file descriptor remains open in using the syntax &gt;&amp;$myfd. The file descriptor remains open in subshells</p>
subshells</p> <p>The syntax {<code>varid</code>}&gt;&amp;-, for example {myfd}&gt;&amp;-, may be used to close a
<p>The syntax <code>{``varid``}&gt;&amp;-</code>, for example <code>{myfd}&gt;&amp;-</code>, may be used to file descriptor opened in this fashion. Note that the parameter given by
close a file descriptor opened in this fashion. Note that the parameter <code>varid</code> must previously be set to a file descriptor in this case.</p>
given by <code>varid</code> must previously be set to a file descriptor in this
case.</p>
<p>It is an error to open or close a file descriptor in this fashion when <p>It is an error to open or close a file descriptor in this fashion when
the parameter is readonly. However, it is not an error to read or write the parameter is readonly. However, it is not an error to read or write
a file descriptor using <code>&lt;&amp;$``param</code> or <code>&gt;&amp;$``param</code> if <code>param</code> is a file descriptor using &lt;&amp;$<code>param</code> or &gt;&amp;$<code>param</code> if <code>param</code> is
readonly.</p> readonly.</p>
<p>If the option <code>CLOBBER</code> is unset, it is an error to open a file <p>If the option CLOBBER is unset, it is an error to open a file descriptor
descriptor using a parameter that is already set to an open file using a parameter that is already set to an open file descriptor
descriptor previously allocated by this mechanism. Unsetting the previously allocated by this mechanism. Unsetting the parameter before
parameter before using it for allocating a file descriptor avoids the using it for allocating a file descriptor avoids the error.</p>
error.</p>
<p>Note that this mechanism merely allocates or closes a file descriptor; <p>Note that this mechanism merely allocates or closes a file descriptor;
it does not perform any redirections from or to it. It is usually it does not perform any redirections from or to it. It is usually
convenient to allocate a file descriptor prior to use as an argument to convenient to allocate a file descriptor prior to use as an argument to
<code>exec</code>. The syntax does not in any case work when used around complex exec. The syntax does not in any case work when used around complex
commands such as parenthesised subshells or loops, where the opening commands such as parenthesised subshells or loops, where the opening
brace is interpreted as part of a command list to be executed in the brace is interpreted as part of a command list to be executed in the
current shell.</p> current shell.</p>
<p>The following shows a typical sequence of allocation, use, and closing <p>The following shows a typical sequence of allocation, use, and closing
of a file descriptor:</p> of a file descriptor:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">integer myfd <pre><code class="language-zsh">integer myfd
exec {myfd}&gt;~/logs/mylogfile.txt exec {myfd}&gt;~/logs/mylogfile.txt
print This is a log message. &gt;&amp;$myfd print This is a log message. &gt;&amp;$myfd
exec {myfd}&gt;&amp;- exec {myfd}&gt;&amp;-
</code></pre> </code></pre>
</div> </div>
<p>Note that the expansion of the variable in the expression <code>&gt;&amp;$myfd</code> <p>Note that the expansion of the variable in the expression &gt;&amp;$myfd
occurs at the point the redirection is opened. This is after the occurs at the point the redirection is opened. This is after the
expansion of command arguments and after any redirections to the left on expansion of command arguments and after any redirections to the left on
the command line have been processed.</p> the command line have been processed.</p>
<hr /> <hr />
<p><span id="Multios"></span></p> <p><span id="Multios"></span></p>
<h2 id="72-multios"><a class="header" href="#72-multios">7.2 Multios</a></h2> <h2 id="72-multios"><a class="header" href="#72-multios">7.2 Multios</a></h2>
<p><span id="index-multios"></span> <p><span id="index-multios"></span> <span
<span id="index-MULTIOS_002c-use-of"></span></p> id="index-MULTIOS_002c-use-of"></span></p>
<p>If the user tries to open a file descriptor for writing more than once, <p>If the user tries to open a file descriptor for writing more than once,
the shell opens the file descriptor as a pipe to a process that copies the shell opens the file descriptor as a pipe to a process that copies
its input to all the specified outputs, similar to tee, provided the its input to all the specified outputs, similar to tee, provided the
<code>MULTIOS</code> option is set, as it is by default. Thus:</p> MULTIOS option is set, as it is by default. Thus:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">date &gt;foo &gt;bar <pre><code class="language-zsh">date &gt;foo &gt;bar
</code></pre> </code></pre>
</div> </div>
<p>writes the date to two files, named <code>foo</code> and <code>bar</code>. Note that a <p>writes the date to two files, named foo and bar. Note that a pipe is
pipe is an implicit redirection; thus</p> an implicit redirection; thus</p>
<div class="example"> <div class="example">
<pre><code class="language-example">date &gt;foo | cat <pre><code class="language-zsh">date &gt;foo | cat
</code></pre> </code></pre>
</div> </div>
<p>writes the date to the file <code>foo</code>, and also pipes it to cat.</p> <p>writes the date to the file foo, and also pipes it to cat.</p>
<p>Note that the shell opens all the files to be used in the multio process <p>Note that the shell opens all the files to be used in the multio process
immediately, not at the point they are about to be written.</p> immediately, not at the point they are about to be written.</p>
<p>Note also that redirections are always expanded in order. This happens <p>Note also that redirections are always expanded in order. This happens
regardless of the setting of the <code>MULTIOS</code> option, but with the option regardless of the setting of the MULTIOS option, but with the option in
in effect there are additional consequences. For example, the meaning of effect there are additional consequences. For example, the meaning of
the expression <code>&gt;&amp;1</code> will change after a previous redirection:</p> the expression &gt;&amp;1 will change after a previous redirection:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">date &gt;&amp;1 &gt;output <pre><code class="language-zsh">date &gt;&amp;1 &gt;output
</code></pre> </code></pre>
</div> </div>
<p>In the case above, the <code>&gt;&amp;1</code> refers to the standard output at the start <p>In the case above, the &gt;&amp;1 refers to the standard output at the start
of the line; the result is similar to the <code>tee</code> command. However, of the line; the result is similar to the tee command. However,
consider:</p> consider:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">date &gt;output &gt;&amp;1 <pre><code class="language-zsh">date &gt;output &gt;&amp;1
</code></pre> </code></pre>
</div> </div>
<p>As redirections are evaluated in order, when the <code>&gt;&amp;1</code> is encountered <p>As redirections are evaluated in order, when the &gt;&amp;1 is encountered the
the standard output is set to the file <code>output</code> and another copy of the standard output is set to the file output and another copy of the output
output is therefore sent to that file. This is unlikely to be what is is therefore sent to that file. This is unlikely to be what is intended.</p>
intended.</p> <p>If the MULTIOS option is set, the word after a redirection operator is
<p>If the <code>MULTIOS</code> option is set, the word after a redirection operator is
also subjected to filename generation (globbing). Thus</p> also subjected to filename generation (globbing). Thus</p>
<div class="example"> <div class="example">
<pre><code class="language-example">: &gt; * <pre><code class="language-zsh">: &gt; *
</code></pre> </code></pre>
</div> </div>
<p>will truncate all files in the current directory, assuming theres at <p>will truncate all files in the current directory, assuming theres at
least one. (Without the <code>MULTIOS</code> option, it would create an empty file least one. (Without the MULTIOS option, it would create an empty file
called <code>*</code>.) Similarly, you can do</p> called *.) Similarly, you can do</p>
<div class="example"> <div class="example">
<pre><code class="language-example">echo exit 0 &gt;&gt; *.sh <pre><code class="language-zsh">echo exit 0 &gt;&gt; *.sh
</code></pre> </code></pre>
</div> </div>
<p>If the user tries to open a file descriptor for reading more than once, <p>If the user tries to open a file descriptor for reading more than once,
the shell opens the file descriptor as a pipe to a process that copies the shell opens the file descriptor as a pipe to a process that copies
all the specified inputs to its output in the order specified, provided all the specified inputs to its output in the order specified, provided
the <code>MULTIOS</code> option is set. It should be noted that each file is opened the MULTIOS option is set. It should be noted that each file is opened
immediately, not at the point where it is about to be read: this immediately, not at the point where it is about to be read: this
behaviour differs from <code>cat</code>, so if strictly standard behaviour is behaviour differs from cat, so if strictly standard behaviour is needed,
needed, <code>cat</code> should be used instead.</p> cat should be used instead.</p>
<p>Thus</p> <p>Thus</p>
<div class="example"> <div class="example">
<pre><code class="language-example">sort &lt;foo &lt;fubar <pre><code class="language-zsh">sort &lt;foo &lt;fubar
</code></pre> </code></pre>
</div> </div>
<p>or even</p> <p>or even</p>
<div class="example"> <div class="example">
<pre><code class="language-example">sort &lt;f{oo,ubar} <pre><code class="language-zsh">sort &lt;f{oo,ubar}
</code></pre> </code></pre>
</div> </div>
<p>is equivalent to <code>cat foo fubar | sort</code>.</p> <p>is equivalent to cat foo fubar | sort.</p>
<p>Expansion of the redirection argument occurs at the point the <p>Expansion of the redirection argument occurs at the point the
redirection is opened, at the point described above for the expansion of redirection is opened, at the point described above for the expansion of
the variable in <code>&gt;&amp;$myfd</code>.</p> the variable in &gt;&amp;$myfd.</p>
<p>Note that a pipe is an implicit redirection; thus</p> <p>Note that a pipe is an implicit redirection; thus</p>
<div class="example"> <div class="example">
<pre><code class="language-example">cat bar | sort &lt;foo <pre><code class="language-zsh">cat bar | sort &lt;foo
</code></pre> </code></pre>
</div> </div>
<p>is equivalent to <code>cat bar foo | sort</code> (note the order of the inputs).</p> <p>is equivalent to cat bar foo | sort (note the order of the inputs).</p>
<p>If the <code>MULTIOS</code> option is <em>un</em>set, each redirection replaces the <p>If the MULTIOS option is <em>un</em>set, each redirection replaces the previous
previous redirection for that file descriptor. However, all files redirection for that file descriptor. However, all files redirected to
redirected to are actually opened, so</p> are actually opened, so</p>
<div class="example"> <div class="example">
<pre><code class="language-example">echo Hello &gt; bar &gt; baz <pre><code class="language-zsh">echo Hello &gt; bar &gt; baz
</code></pre> </code></pre>
</div> </div>
<p>when <code>MULTIOS</code> is unset will truncate <code>bar</code>, and write <code>Hello</code> into <p>when MULTIOS is unset will truncate bar, and write Hello into baz.</p>
<code>baz</code>.</p>
<p>There is a problem when an output multio is attached to an external <p>There is a problem when an output multio is attached to an external
program. A simple example shows this:</p> program. A simple example shows this:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">cat file &gt;file1 &gt;file2 <pre><code class="language-zsh">cat file &gt;file1 &gt;file2
cat file1 file2 cat file1 file2
</code></pre> </code></pre>
</div> </div>
<p>Here, it is possible that the second <code>cat</code> will not display the full <p>Here, it is possible that the second cat will not display the full
contents of <code>file1</code> and <code>file2</code> (i.e. the original contents of <code>file</code> contents of file1 and file2 (i.e. the original contents of file repeated
repeated twice).</p> twice).</p>
<p>The reason for this is that the multios are spawned after the <code>cat</code> <p>The reason for this is that the multios are spawned after the cat
process is forked from the parent shell, so the parent shell does not process is forked from the parent shell, so the parent shell does not
wait for the multios to finish writing data. This means the command as wait for the multios to finish writing data. This means the command as
shown can exit before <code>file1</code> and <code>file2</code> are completely written. As a shown can exit before file1 and file2 are completely written. As a
workaround, it is possible to run the <code>cat</code> process as part of a job in workaround, it is possible to run the cat process as part of a job in
the current shell:</p> the current shell:</p>
<div class="example"> <div class="example">
<pre><code class="language-example">{ cat file } &gt;file &gt;file2 <pre><code class="language-zsh">{ cat file } &gt;file &gt;file2
</code></pre> </code></pre>
</div> </div>
<p>Here, the <code>{``...``}</code> job will pause to wait for both files to be <p>Here, the {<code>...</code>} job will pause to wait for both files to be written.</p>
written.</p>
<hr /> <hr />
<p><span id="Redirections-with-no-command"></span></p> <p><span id="Redirections-with-no-command"></span></p>
<h2 id="73-redirections-with-no-command"><a class="header" href="#73-redirections-with-no-command">7.3 Redirections with no command</a></h2> <h2 id="73-redirections-with-no-command"><a class="header" href="#73-redirections-with-no-command">7.3 Redirections with no command</a></h2>
<p>When a simple command consists of one or more redirection operators and <p>When a simple command consists of one or more redirection operators and
zero or more parameter assignments, but no command name, zsh can behave zero or more parameter assignments, but no command name, zsh can behave
in several ways.</p> in several ways.</p>
<p><span id="index-NULLCMD_002c-use-of"></span> <p><span id="index-NULLCMD_002c-use-of"></span> <span
<span id="index-CSH_005fNULLCMD_002c-use-of"></span></p> id="index-CSH_005fNULLCMD_002c-use-of"></span></p>
<p>If the parameter <code>NULLCMD</code> is not set or the option <code>CSH_NULLCMD</code> is <p>If the parameter NULLCMD is not set or the option CSH_NULLCMD is set, an
set, an error is caused. This is the csh behavior and <code>CSH_NULLCMD</code> is error is caused. This is the csh behavior and CSH_NULLCMD is set by
set by default when emulating csh.</p> default when emulating csh.</p>
<p><span id="index-SH_005fNULLCMD_002c-use-of"></span></p> <p><span id="index-SH_005fNULLCMD_002c-use-of"></span></p>
<p>If the option <code>SH_NULLCMD</code> is set, the builtin <code>:</code> is inserted as a <p>If the option SH_NULLCMD is set, the builtin : is inserted as a
command with the given redirections. This is the default when emulating command with the given redirections. This is the default when emulating
sh or ksh.</p> sh or ksh.</p>
<p><span id="index-READNULLCMD_002c-use-of"></span></p> <p><span id="index-READNULLCMD_002c-use-of"></span></p>
<p>Otherwise, if the parameter <code>NULLCMD</code> is set, its value will be used as <p>Otherwise, if the parameter NULLCMD is set, its value will be used as a
a command with the given redirections. If both <code>NULLCMD</code> and command with the given redirections. If both NULLCMD and READNULLCMD are
<code>READNULLCMD</code> are set, then the value of the latter will be used instead set, then the value of the latter will be used instead of that of the
of that of the former when the redirection is an input. The default for former when the redirection is an input. The default for NULLCMD is
<code>NULLCMD</code> is <code>cat</code> and for <code>READNULLCMD</code> is <code>more</code>. Thus</p> cat and for READNULLCMD is more. Thus</p>
<div class="example"> <div class="example">
<pre><code class="language-example">&lt; file <pre><code class="language-zsh">&lt; file
</code></pre> </code></pre>
</div> </div>
<p>shows the contents of <code>file</code> on standard output, with paging if that is <p>shows the contents of file on standard output, with paging if that is a
a terminal. <code>NULLCMD</code> and <code>READNULLCMD</code> may refer to shell functions.</p> terminal. NULLCMD and READNULLCMD may refer to shell functions.</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Shell-Grammar.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Shell-Grammar.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Command-Execution.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Command-Execution.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -559,64 +483,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Shell-Grammar.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Shell-Grammar.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Command-Execution.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Command-Execution.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Roadmap - Zsh Manual</title> <title>Roadmap - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html" class="active"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html" class="active"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -201,9 +178,10 @@ be created or edited to customize the shell. See
<a href="Files.html#Files">Files</a>.</p> <a href="Files.html#Files">Files</a>.</p>
<p>If no personal initialization files exist for the current user, a <p>If no personal initialization files exist for the current user, a
function is run to help you change some of the most common settings. It function is run to help you change some of the most common settings. It
wont appear if your administrator has disabled the <code>zsh/newuser</code> wont appear if your administrator has disabled the zsh/newuser module.
module. The function is designed to be self-explanatory. You can run it The function is designed to be self-explanatory. You can run it by hand
by hand with <code>autoload -Uz zsh-newuser-install; zsh-newuser-install -f</code>. See also <a href="User-Contributions.html#User-Configuration-Functions">User Configuration with autoload -Uz zsh-newuser-install; zsh-newuser-install -f. See
also <a href="User-Contributions.html#User-Configuration-Functions">User Configuration
Functions</a>.</p> Functions</a>.</p>
<hr /> <hr />
<p><span id="Interactive-Use"></span></p> <p><span id="Interactive-Use"></span></p>
@ -214,14 +192,14 @@ Editor</a>.</p>
<p>The first decision a user must make is whether to use the Emacs or Vi <p>The first decision a user must make is whether to use the Emacs or Vi
editing mode as the keys for editing are substantially different. Emacs editing mode as the keys for editing are substantially different. Emacs
editing mode is probably more natural for beginners and can be selected editing mode is probably more natural for beginners and can be selected
explicitly with the command <code>bindkey -e</code>.</p> explicitly with the command bindkey -e.</p>
<p>A history mechanism for retrieving previously typed lines (most simply <p>A history mechanism for retrieving previously typed lines (most simply
with the Up or Down arrow keys) is available; note that, unlike other with the Up or Down arrow keys) is available; note that, unlike other
shells, zsh will not save these lines when the shell exits unless you shells, zsh will not save these lines when the shell exits unless you
set appropriate variables, and the number of history lines retained by set appropriate variables, and the number of history lines retained by
default is quite small (30 lines). See the description of the shell default is quite small (30 lines). See the description of the shell
variables (referred to in the documentation as parameters) <code>HISTFILE</code>, variables (referred to in the documentation as parameters) HISTFILE,
<code>HISTSIZE</code> and <code>SAVEHIST</code> in <a href="Parameters.html#Parameters-Used-By-The-Shell">Parameters Used By The HISTSIZE and SAVEHIST in <a href="Parameters.html#Parameters-Used-By-The-Shell">Parameters Used By The
Shell</a>. Note that its Shell</a>. Note that its
currently only possible to read and write files saving history when the currently only possible to read and write files saving history when the
shell is interactive, i.e. it does not work from scripts.</p> shell is interactive, i.e. it does not work from scripts.</p>
@ -229,17 +207,16 @@ shell is interactive, i.e. it does not work from scripts.</p>
supported by the operating system). This is (mostly) handled supported by the operating system). This is (mostly) handled
transparently by the shell, but the degree of support in terminal transparently by the shell, but the degree of support in terminal
emulators is variable. There is some discussion of this in the shell emulators is variable. There is some discussion of this in the shell
FAQ, <code>http://www.zsh.org/FAQ/</code>. Note in particular that for combining FAQ, <a href="https://www.zsh.org/FAQ/">https://www.zsh.org/FAQ/</a>. Note in particular that for combining
characters to be handled the option <code>COMBINING_CHARS</code> needs to be set. characters to be handled the option COMBINING_CHARS needs to be set.
Because the shell is now more sensitive to the definition of the Because the shell is now more sensitive to the definition of the
character set, note that if you are upgrading from an older version of character set, note that if you are upgrading from an older version of
the shell you should ensure that the appropriate variable, either <code>LANG</code> the shell you should ensure that the appropriate variable, either LANG
(to affect all aspects of the shells operation) or <code>LC_CTYPE</code> (to (to affect all aspects of the shells operation) or LC_CTYPE (to affect
affect only the handling of character sets) is set to an appropriate only the handling of character sets) is set to an appropriate value.
value. This is true even if you are using a single-byte character set This is true even if you are using a single-byte character set including
including extensions of ASCII such as <code>ISO-8859-1</code> or <code>ISO-8859-15</code>. See extensions of ASCII such as ISO-8859-1 or ISO-8859-15. See the
the description of <code>LC_CTYPE</code> in description of LC_CTYPE in <a href="Parameters.html#Parameters">Parameters</a>.</p>
<a href="Parameters.html#Parameters">Parameters</a>.</p>
<hr /> <hr />
<p><span id="Completion-1"></span></p> <p><span id="Completion-1"></span></p>
<h3 id="321-completion"><a class="header" href="#321-completion">3.2.1 Completion</a></h3> <h3 id="321-completion"><a class="header" href="#321-completion">3.2.1 Completion</a></h3>
@ -247,13 +224,13 @@ the description of <code>LC_CTYPE</code> in
type only a part (usually the prefix) of a word and have the shell fill type only a part (usually the prefix) of a word and have the shell fill
in the rest. The completion system in zsh is programmable. For example, in the rest. The completion system in zsh is programmable. For example,
the shell can be set to complete email addresses in arguments to the the shell can be set to complete email addresses in arguments to the
mail command from your <code>~/.abook/addressbook</code>; usernames, hostnames, and mail command from your ~/.abook/addressbook; usernames, hostnames, and
even remote paths in arguments to scp, and so on. Anything that can be even remote paths in arguments to scp, and so on. Anything that can be
written in or glued together with zsh can be the source of what the line written in or glued together with zsh can be the source of what the line
editor offers as possible completions.</p> editor offers as possible completions.</p>
<p>Zsh has two completion systems, an old, so called <code>compctl</code> completion <p>Zsh has two completion systems, an old, so called compctl completion
(named after the builtin command that serves as its complete and only (named after the builtin command that serves as its complete and only
user interface), and a new one, referred to as <code>compsys</code>, organized as user interface), and a new one, referred to as compsys, organized as
library of builtin and user-defined functions. The two systems differ in library of builtin and user-defined functions. The two systems differ in
their interface for specifying the completion behavior. The new system their interface for specifying the completion behavior. The new system
is more customizable and is supplied with completions for many commonly is more customizable and is supplied with completions for many commonly
@ -267,34 +244,21 @@ System</a>.</p>
<p>Apart from completion, the line editor is highly extensible by means of <p>Apart from completion, the line editor is highly extensible by means of
shell functions. Some useful functions are provided with the shell; they shell functions. Some useful functions are provided with the shell; they
provide facilities such as:</p> provide facilities such as:</p>
<ul> <p>insert-composed-char<br />
<li>
<p><code>insert-composed-char</code><br />
composing characters not found on the keyboard</p> composing characters not found on the keyboard</p>
</li> <p>match-words-by-style<br />
<li>
<p><code>match-words-by-style</code><br />
configuring what the line editor considers a word when moving or configuring what the line editor considers a word when moving or
deleting by word</p> deleting by word</p>
</li> <p>history-beginning-search-backward-end, etc.<br />
<li>
<p><code>history-beginning-search-backward-end</code>, etc.<br />
alternative ways of searching the shell history</p> alternative ways of searching the shell history</p>
</li> <p>replace-string, replace-pattern<br />
<li> functions for replacing strings or patterns globally in the command line</p>
<p><code>replace-string</code>, <code>replace-pattern</code><br /> <p>edit-command-line<br />
functions for replacing strings or patterns globally in the command
line</p>
</li>
<li>
<p><code>edit-command-line</code><br />
edit the command line with an external editor.</p> edit the command line with an external editor.</p>
</li>
</ul>
<p>See <a href="User-Contributions.html#ZLE-Functions">ZLE Functions</a> for <p>See <a href="User-Contributions.html#ZLE-Functions">ZLE Functions</a> for
descriptions of these.</p> descriptions of these.</p>
<hr /> <hr />
<p><span id="Options-3"></span></p> <p><span id="Options-1"></span></p>
<h2 id="33-options"><a class="header" href="#33-options">3.3 Options</a></h2> <h2 id="33-options"><a class="header" href="#33-options">3.3 Options</a></h2>
<p>The shell has a large number of options for changing its behaviour. <p>The shell has a large number of options for changing its behaviour.
These cover all aspects of the shell; browsing the full documentation is These cover all aspects of the shell; browsing the full documentation is
@ -310,27 +274,17 @@ programming. These are described in <a href="Expansion.html#Filename-Generation"
Generation</a>.</p> Generation</a>.</p>
<p>Of particular interest are the following patterns that are not commonly <p>Of particular interest are the following patterns that are not commonly
supported by other systems of pattern matching:</p> supported by other systems of pattern matching:</p>
<ul> <p>**<br />
<li>
<p><code>**</code><br />
for matching over multiple directories</p> for matching over multiple directories</p>
</li> <p>|<br />
<li>
<p><code>|</code><br />
for matching either of two alternatives</p> for matching either of two alternatives</p>
</li> <p>~, ^<br />
<li> the ability to exclude patterns from matching when the EXTENDED_GLOB
<p><code>~</code>, <code>^</code><br /> option is set</p>
the ability to exclude patterns from matching when the <p>(<code>...</code>)<br />
<code>EXTENDED_GLOB</code> option is set</p>
</li>
<li>
<p><code>(``...``)</code><br />
glob qualifiers, included in parentheses at the end of the pattern, glob qualifiers, included in parentheses at the end of the pattern,
which select files by type (such as directories) or attribute (such which select files by type (such as directories) or attribute (such as
as size).</p> size).</p>
</li>
</ul>
<hr /> <hr />
<p><span id="General-Comments-on-Syntax"></span></p> <p><span id="General-Comments-on-Syntax"></span></p>
<h2 id="35-general-comments-on-syntax"><a class="header" href="#35-general-comments-on-syntax">3.5 General Comments on Syntax</a></h2> <h2 id="35-general-comments-on-syntax"><a class="header" href="#35-general-comments-on-syntax">3.5 General Comments on Syntax</a></h2>
@ -341,10 +295,10 @@ General shell syntax is introduced in <a href="Shell-Grammar.html#Shell-Grammar"
Grammar</a>.</p> Grammar</a>.</p>
<p>One commonly encountered difference is that variables substituted onto <p>One commonly encountered difference is that variables substituted onto
the command line are not split into words. See the description of the the command line are not split into words. See the description of the
shell option <code>SH_WORD_SPLIT</code> in <a href="Expansion.html#Parameter-Expansion">Parameter shell option SH_WORD_SPLIT in <a href="Expansion.html#Parameter-Expansion">Parameter
Expansion</a>. In zsh, you can either Expansion</a>. In zsh, you can either
explicitly request the splitting (e.g. <code>${=foo}</code>) or use an array when explicitly request the splitting (e.g. ${=foo}) or use an array when you
you want a variable to expand to more than one word. See <a href="Parameters.html#Array-Parameters">Array want a variable to expand to more than one word. See <a href="Parameters.html#Array-Parameters">Array
Parameters</a>.</p> Parameters</a>.</p>
<hr /> <hr />
<p><span id="Programming"></span></p> <p><span id="Programming"></span></p>
@ -359,50 +313,34 @@ simple text replacement.</p>
above, are provided with the shell and are described in <a href="User-Contributions.html#User-Contributions">User above, are provided with the shell and are described in <a href="User-Contributions.html#User-Contributions">User
Contributions</a>. Features Contributions</a>. Features
include:</p> include:</p>
<ul> <p>promptinit<br />
<li>
<p><code>promptinit</code><br />
a prompt theme system for changing prompts easily, see <a href="User-Contributions.html#Prompt-Themes">Prompt a prompt theme system for changing prompts easily, see <a href="User-Contributions.html#Prompt-Themes">Prompt
Themes</a></p> Themes</a></p>
</li> <p>zsh-mime-setup<br />
<li> a MIME-handling system which dispatches commands according to the suffix
<p><code>zsh-mime-setup</code><br /> of a file as done by graphical file managers</p>
a MIME-handling system which dispatches commands according to the <p>zcalc<br />
suffix of a file as done by graphical file managers</p>
</li>
<li>
<p><code>zcalc</code><br />
a calculator</p> a calculator</p>
</li> <p>zargs<br />
<li> a version of xargs that makes the find command redundant</p>
<p><code>zargs</code><br /> <p>zmv<br />
a version of <code>xargs</code> that makes the <code>find</code> command redundant</p>
</li>
<li>
<p><code>zmv</code><br />
a command for renaming files by means of shell patterns.</p> a command for renaming files by means of shell patterns.</p>
</li>
</ul>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="prev" href="Introduction.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Introduction.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Invocation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Invocation.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -410,64 +348,35 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="Introduction.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> <a rel="prev" href="Introduction.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i> <i class="fa fa-angle-left"></i>
</a> </a>
<a rel="next" href="Invocation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Invocation.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>The Z Shell Manual - Zsh Manual</title> <title>The Z Shell Manual - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html" class="active"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html" class="active"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -176,58 +153,48 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="The-Z-Shell-Manual"></span> <p><span id="The-Z-Shell-Manual"></span> <span
<span id="The-Z-Shell-Manual-1"></span></p> id="The-Z-Shell-Manual-1"></span></p>
<h1 id="1-the-z-shell-manual"><a class="header" href="#1-the-z-shell-manual">1 The Z Shell Manual</a></h1> <h1 id="1-the-z-shell-manual"><a class="header" href="#1-the-z-shell-manual">1 The Z Shell Manual</a></h1>
<p>This document has been produced from the texinfo file <code>zsh.texi</code>, <p>This document has been produced from the texinfo file zsh.texi, included
included in the <code>Doc</code> sub-directory of the Zsh distribution.</p> in the Doc sub-directory of the Zsh distribution.</p>
<hr /> <hr />
<p><span id="Producing-documentation-from-zsh_002etexi"></span></p> <p><span id="Producing-documentation-from-zsh_002etexi"></span></p>
<h2 id="11-producing-documentation-from-zshtexi"><a class="header" href="#11-producing-documentation-from-zshtexi">1.1 Producing documentation from zsh.texi</a></h2> <h2 id="11-producing-documentation-from-zshtexi"><a class="header" href="#11-producing-documentation-from-zshtexi">1.1 Producing documentation from zsh.texi</a></h2>
<p>The texinfo source may be converted into several formats:</p> <p>The texinfo source may be converted into several formats:</p>
<ul>
<li>
<p>The Info manual<br /> <p>The Info manual<br />
The Info format allows searching for topics, commands, functions, The Info format allows searching for topics, commands, functions, etc.
etc. from the many Indices. The command <code>makeinfo zsh.texi</code> is from the many Indices. The command makeinfo zsh.texi is used to
used to produce the Info documentation.</p> produce the Info documentation.</p>
</li>
<li>
<p>The printed manual<br /> <p>The printed manual<br />
The command <code>texi2dvi zsh.texi</code> will output <code>zsh.dvi</code> which can The command texi2dvi zsh.texi will output zsh.dvi which can then be
then be processed with dvips and optionally gs (Ghostscript) to processed with dvips and optionally gs (Ghostscript) to produce a nicely
produce a nicely formatted printed manual.</p> formatted printed manual.</p>
</li>
<li>
<p>The HTML manual<br /> <p>The HTML manual<br />
An HTML version of this manual is available at the Zsh web site via:</p> An HTML version of this manual is available at the Zsh web site via:</p>
<p><code>http://zsh.sourceforge.net/Doc/</code>.</p> <p><a href="https://zsh.sourceforge.io/Doc/">https://zsh.sourceforge.io/Doc/</a>.</p>
<p>(The HTML version is produced with texi2html, which may be obtained <p>(The HTML version is produced with texi2html, which may be obtained from
from <code>http://www.nongnu.org/texi2html/</code>. The command is <code>texi2html output . ifinfo split=chapter node-files zsh.texi</code>. If <a href="http://www.nongnu.org/texi2html/">http://www.nongnu.org/texi2html/</a>. The command is texi2html output .
necessary, upgrade to version 1.78 of texi2html.)</p> ifinfo split=chapter node-files zsh.texi. If necessary, upgrade to
</li> version 1.78 of texi2html.)</p>
</ul>
<p>For those who do not have the necessary tools to process texinfo, <p>For those who do not have the necessary tools to process texinfo,
precompiled documentation (PostScript, dvi, PDF, info and HTML formats) precompiled documentation (PostScript, dvi, PDF, info and HTML formats)
is available from the zsh archive site or its mirrors, in the file is available from the zsh archive site or its mirrors, in the file
<code>zsh-doc.tar.gz</code>. (See <a href="Introduction.html#Availability">Availability</a> zsh-doc.tar.gz. (See <a href="Introduction.html#Availability">Availability</a> for
for a list of sites.)</p> a list of sites.)</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="next" href="Introduction.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Introduction.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -235,60 +202,32 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="next" href="Introduction.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Introduction.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
overflow-x: auto; overflow-x: auto;
background: #191f26; background: #191f26;
color: #e6e1cf; color: #e6e1cf;
padding: 0.5em;
} }
.hljs-comment, .hljs-comment,

View File

@ -108,9 +108,12 @@ function playground_text(playground) {
let text = playground_text(code_block); let text = playground_text(code_block);
let classes = code_block.querySelector('code').classList; let classes = code_block.querySelector('code').classList;
let has_2018 = classes.contains("edition2018"); let edition = "2015";
let edition = has_2018 ? "2018" : "2015"; if(classes.contains("edition2018")) {
edition = "2018";
} else if(classes.contains("edition2021")) {
edition = "2021";
}
var params = { var params = {
version: "stable", version: "stable",
optimize: "0", optimize: "0",
@ -133,7 +136,15 @@ function playground_text(playground) {
body: JSON.stringify(params) body: JSON.stringify(params)
}) })
.then(response => response.json()) .then(response => response.json())
.then(response => result_block.innerText = response.result) .then(response => {
if (response.result.trim() === '') {
result_block.innerText = "No output";
result_block.classList.add("result-no-output");
} else {
result_block.innerText = response.result;
result_block.classList.remove("result-no-output");
}
})
.catch(error => result_block.innerText = "Playground Communication: " + error.message); .catch(error => result_block.innerText = "Playground Communication: " + error.message);
} }
@ -151,12 +162,13 @@ function playground_text(playground) {
if (window.ace) { if (window.ace) {
// language-rust class needs to be removed for editable // language-rust class needs to be removed for editable
// blocks or highlightjs will capture events // blocks or highlightjs will capture events
Array code_nodes
.from(document.querySelectorAll('code.editable')) .filter(function (node) {return node.classList.contains("editable"); })
.forEach(function (block) { block.classList.remove('language-rust'); }); .forEach(function (block) { block.classList.remove('language-rust'); });
Array Array
.from(document.querySelectorAll('code:not(.editable)')) code_nodes
.filter(function (node) {return !node.classList.contains("editable"); })
.forEach(function (block) { hljs.highlightBlock(block); }); .forEach(function (block) { hljs.highlightBlock(block); });
} else { } else {
code_nodes.forEach(function (block) { hljs.highlightBlock(block); }); code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
@ -359,7 +371,14 @@ function playground_text(playground) {
}); });
themePopup.addEventListener('click', function (e) { themePopup.addEventListener('click', function (e) {
var theme = e.target.id || e.target.parentElement.id; var theme;
if (e.target.className === "theme") {
theme = e.target.id;
} else if (e.target.parentElement.className === "theme") {
theme = e.target.parentElement.id;
} else {
return;
}
set_theme(theme); set_theme(theme);
}); });

View File

@ -208,24 +208,63 @@ pre {
pre > .buttons { pre > .buttons {
position: absolute; position: absolute;
z-index: 100; z-index: 100;
right: 5px; right: 0px;
top: 5px; top: 2px;
margin: 0px;
padding: 2px 0px;
color: var(--sidebar-fg); color: var(--sidebar-fg);
cursor: pointer; cursor: pointer;
visibility: hidden;
opacity: 0;
transition: visibility 0.1s linear, opacity 0.1s linear;
}
pre:hover > .buttons {
visibility: visible;
opacity: 1
} }
pre > .buttons :hover { pre > .buttons :hover {
color: var(--sidebar-active); color: var(--sidebar-active);
border-color: var(--icons-hover);
background-color: var(--theme-hover);
} }
pre > .buttons i { pre > .buttons i {
margin-left: 8px; margin-left: 8px;
} }
pre > .buttons button { pre > .buttons button {
color: inherit;
background: transparent;
border: none;
cursor: inherit; cursor: inherit;
margin: 0px 5px;
padding: 3px 5px;
font-size: 14px;
border-style: solid;
border-width: 1px;
border-radius: 4px;
border-color: var(--icons);
background-color: var(--theme-popup-bg);
transition: 100ms;
transition-property: color,border-color,background-color;
color: var(--icons);
} }
@media (pointer: coarse) {
pre > .buttons button {
/* On mobile, make it easier to tap buttons. */
padding: 0.3rem 1rem;
}
}
pre > code {
padding: 1rem;
}
/* FIXME: ACE editors overlap their buttons because ACE does absolute
positioning within the code block which breaks padding. The only solution I
can think of is to move the padding to the outer pre tag (or insert a div
wrapper), but that would require fixing a whole bunch of CSS rules.
*/
.hljs.ace_editor {
padding: 0rem 0rem;
}
pre > .result { pre > .result {
margin-top: 10px; margin-top: 10px;
} }

View File

@ -12,6 +12,7 @@ html {
color: var(--fg); color: var(--fg);
background-color: var(--bg); background-color: var(--bg);
text-size-adjust: none; text-size-adjust: none;
-webkit-text-size-adjust: none;
} }
body { body {
@ -25,6 +26,16 @@ code {
font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */ font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
} }
/* make long words/inline code not x overflow */
main {
overflow-wrap: break-word;
}
/* make wide tables scroll if they overflow */
.table-wrapper {
overflow-x: auto;
}
/* Don't change font size in headers. */ /* Don't change font size in headers. */
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
font-size: unset; font-size: unset;
@ -79,8 +90,7 @@ h6:target::before {
.content { .content {
overflow-y: auto; overflow-y: auto;
padding: 0 15px; padding: 0 5px 50px 5px;
padding-bottom: 50px;
} }
.content main { .content main {
margin-left: auto; margin-left: auto;
@ -92,7 +102,7 @@ h6:target::before {
.content ul { line-height: 1.45em; } .content ul { line-height: 1.45em; }
.content a { text-decoration: none; } .content a { text-decoration: none; }
.content a:hover { text-decoration: underline; } .content a:hover { text-decoration: underline; }
.content img { max-width: 100%; } .content img, .content video { max-width: 100%; }
.content .header:link, .content .header:link,
.content .header:visited { .content .header:visited {
color: var(--fg); color: var(--fg);
@ -175,3 +185,7 @@ blockquote {
margin: 5px 0px; margin: 5px 0px;
font-weight: bold; font-weight: bold;
} }
.result-no-output {
font-style: italic;
}

View File

@ -67,7 +67,7 @@
--links: #2b79a2; --links: #2b79a2;
--inline-code-color: #c5c8c6;; --inline-code-color: #c5c8c6;
--theme-popup-bg: #141617; --theme-popup-bg: #141617;
--theme-popup-border: #43484d; --theme-popup-border: #43484d;
@ -147,7 +147,7 @@
--links: #2b79a2; --links: #2b79a2;
--inline-code-color: #c5c8c6;; --inline-code-color: #c5c8c6;
--theme-popup-bg: #161923; --theme-popup-bg: #161923;
--theme-popup-border: #737480; --theme-popup-border: #737480;
@ -228,7 +228,7 @@
--links: #2b79a2; --links: #2b79a2;
--inline-code-color: #c5c8c6;; --inline-code-color: #c5c8c6;
--theme-popup-bg: #141617; --theme-popup-bg: #141617;
--theme-popup-border: #43484d; --theme-popup-border: #43484d;

View File

@ -61,7 +61,6 @@
overflow-x: auto; overflow-x: auto;
background: #f6f7f6; background: #f6f7f6;
color: #000; color: #000;
padding: 0.5em;
} }
.hljs-emphasis { .hljs-emphasis {

View File

@ -4,37 +4,25 @@
<!-- Book generated using mdBook --> <!-- Book generated using mdBook -->
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>The Z Shell Manual - Zsh Manual</title> <title>The Z Shell Manual - Zsh Manual</title>
<!-- Custom HTML head --> <!-- Custom HTML head -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content=""> <meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<link rel="icon" href="favicon.svg"> <link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png"> <link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css"> <link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css"> <link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css"> <link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print"> <link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts --> <!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css"> <link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css"> <link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets --> <!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css"> <link rel="stylesheet" href="highlight.css">
@ -42,9 +30,7 @@
<link rel="stylesheet" href="ayu-highlight.css"> <link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets --> <!-- Custom theme stylesheets -->
</head> </head>
<body> <body>
<!-- Provide site root to javascript --> <!-- Provide site root to javascript -->
@ -95,7 +81,7 @@
<nav id="sidebar" class="sidebar" aria-label="Table of contents"> <nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox"> <div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-_0026-Signals.html"><strong aria-hidden="true">10.</strong> Jobs &amp; Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol> <ol class="chapter"><li class="chapter-item expanded "><a href="The-Z-Shell-Manual.html" class="active"><strong aria-hidden="true">1.</strong> The Z Shell Manual</a></li><li class="chapter-item expanded "><a href="Introduction.html"><strong aria-hidden="true">2.</strong> Introduction</a></li><li class="chapter-item expanded "><a href="Roadmap.html"><strong aria-hidden="true">3.</strong> Roadmap</a></li><li class="chapter-item expanded "><a href="Invocation.html"><strong aria-hidden="true">4.</strong> Invocation</a></li><li class="chapter-item expanded "><a href="Files.html"><strong aria-hidden="true">5.</strong> Files</a></li><li class="chapter-item expanded "><a href="Shell-Grammar.html"><strong aria-hidden="true">6.</strong> Shell Grammar</a></li><li class="chapter-item expanded "><a href="Redirection.html"><strong aria-hidden="true">7.</strong> Redirection</a></li><li class="chapter-item expanded "><a href="Command-Execution.html"><strong aria-hidden="true">8.</strong> Command Execution</a></li><li class="chapter-item expanded "><a href="Functions.html"><strong aria-hidden="true">9.</strong> Functions</a></li><li class="chapter-item expanded "><a href="Jobs-&-Signals.html"><strong aria-hidden="true">10.</strong> Jobs & Signals</a></li><li class="chapter-item expanded "><a href="Arithmetic-Evaluation.html"><strong aria-hidden="true">11.</strong> Arithmetic Evaluation</a></li><li class="chapter-item expanded "><a href="Conditional-Expressions.html"><strong aria-hidden="true">12.</strong> Conditional Expressions</a></li><li class="chapter-item expanded "><a href="Prompt-Expansion.html"><strong aria-hidden="true">13.</strong> Prompt Expansion</a></li><li class="chapter-item expanded "><a href="Expansion.html"><strong aria-hidden="true">14.</strong> Expansion</a></li><li class="chapter-item expanded "><a href="Parameters.html"><strong aria-hidden="true">15.</strong> Parameters</a></li><li class="chapter-item expanded "><a href="Options.html"><strong aria-hidden="true">16.</strong> Options</a></li><li class="chapter-item expanded "><a href="Shell-Builtin-Commands.html"><strong aria-hidden="true">17.</strong> Shell Builtin Commands</a></li><li class="chapter-item expanded "><a href="Zsh-Line-Editor.html"><strong aria-hidden="true">18.</strong> Zsh Line Editor</a></li><li class="chapter-item expanded "><a href="Completion-Widgets.html"><strong aria-hidden="true">19.</strong> Completion Widgets</a></li><li class="chapter-item expanded "><a href="Completion-System.html"><strong aria-hidden="true">20.</strong> Completion System</a></li><li class="chapter-item expanded "><a href="Completion-Using-compctl.html"><strong aria-hidden="true">21.</strong> Completion Using compctl</a></li><li class="chapter-item expanded "><a href="Zsh-Modules.html"><strong aria-hidden="true">22.</strong> Zsh Modules</a></li><li class="chapter-item expanded "><a href="Calendar-Function-System.html"><strong aria-hidden="true">23.</strong> Calendar Function System</a></li><li class="chapter-item expanded "><a href="TCP-Function-System.html"><strong aria-hidden="true">24.</strong> TCP Function System</a></li><li class="chapter-item expanded "><a href="Zftp-Function-System.html"><strong aria-hidden="true">25.</strong> Zftp Function System</a></li><li class="chapter-item expanded "><a href="User-Contributions.html"><strong aria-hidden="true">26.</strong> User Contributions</a></li></ol>
</div> </div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
</nav> </nav>
@ -103,8 +89,7 @@
<div id="page-wrapper" class="page-wrapper"> <div id="page-wrapper" class="page-wrapper">
<div class="page"> <div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky bordered"> <div id="menu-bar" class="menu-bar sticky bordered">
<div class="left-buttons"> <div class="left-buttons">
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
@ -120,28 +105,21 @@
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul> </ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
</div> </div>
<h1 class="menu-title">Zsh Manual</h1> <h1 class="menu-title">Zsh Manual</h1>
<div class="right-buttons"> <div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book"> <a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i> <i id="print-button" class="fa fa-print"></i>
</a> </a>
</div> </div>
</div> </div>
<div id="search-wrapper" class="hidden"> <div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer"> <form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
@ -152,7 +130,6 @@
</ul> </ul>
</div> </div>
</div> </div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript"> <script type="text/javascript">
@ -176,58 +153,48 @@
</li> </li>
</ul> </ul>
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
<p><span id="The-Z-Shell-Manual"></span> <p><span id="The-Z-Shell-Manual"></span> <span
<span id="The-Z-Shell-Manual-1"></span></p> id="The-Z-Shell-Manual-1"></span></p>
<h1 id="1-the-z-shell-manual"><a class="header" href="#1-the-z-shell-manual">1 The Z Shell Manual</a></h1> <h1 id="1-the-z-shell-manual"><a class="header" href="#1-the-z-shell-manual">1 The Z Shell Manual</a></h1>
<p>This document has been produced from the texinfo file <code>zsh.texi</code>, <p>This document has been produced from the texinfo file zsh.texi, included
included in the <code>Doc</code> sub-directory of the Zsh distribution.</p> in the Doc sub-directory of the Zsh distribution.</p>
<hr /> <hr />
<p><span id="Producing-documentation-from-zsh_002etexi"></span></p> <p><span id="Producing-documentation-from-zsh_002etexi"></span></p>
<h2 id="11-producing-documentation-from-zshtexi"><a class="header" href="#11-producing-documentation-from-zshtexi">1.1 Producing documentation from zsh.texi</a></h2> <h2 id="11-producing-documentation-from-zshtexi"><a class="header" href="#11-producing-documentation-from-zshtexi">1.1 Producing documentation from zsh.texi</a></h2>
<p>The texinfo source may be converted into several formats:</p> <p>The texinfo source may be converted into several formats:</p>
<ul>
<li>
<p>The Info manual<br /> <p>The Info manual<br />
The Info format allows searching for topics, commands, functions, The Info format allows searching for topics, commands, functions, etc.
etc. from the many Indices. The command <code>makeinfo zsh.texi</code> is from the many Indices. The command makeinfo zsh.texi is used to
used to produce the Info documentation.</p> produce the Info documentation.</p>
</li>
<li>
<p>The printed manual<br /> <p>The printed manual<br />
The command <code>texi2dvi zsh.texi</code> will output <code>zsh.dvi</code> which can The command texi2dvi zsh.texi will output zsh.dvi which can then be
then be processed with dvips and optionally gs (Ghostscript) to processed with dvips and optionally gs (Ghostscript) to produce a nicely
produce a nicely formatted printed manual.</p> formatted printed manual.</p>
</li>
<li>
<p>The HTML manual<br /> <p>The HTML manual<br />
An HTML version of this manual is available at the Zsh web site via:</p> An HTML version of this manual is available at the Zsh web site via:</p>
<p><code>http://zsh.sourceforge.net/Doc/</code>.</p> <p><a href="https://zsh.sourceforge.io/Doc/">https://zsh.sourceforge.io/Doc/</a>.</p>
<p>(The HTML version is produced with texi2html, which may be obtained <p>(The HTML version is produced with texi2html, which may be obtained from
from <code>http://www.nongnu.org/texi2html/</code>. The command is <code>texi2html output . ifinfo split=chapter node-files zsh.texi</code>. If <a href="http://www.nongnu.org/texi2html/">http://www.nongnu.org/texi2html/</a>. The command is texi2html output .
necessary, upgrade to version 1.78 of texi2html.)</p> ifinfo split=chapter node-files zsh.texi. If necessary, upgrade to
</li> version 1.78 of texi2html.)</p>
</ul>
<p>For those who do not have the necessary tools to process texinfo, <p>For those who do not have the necessary tools to process texinfo,
precompiled documentation (PostScript, dvi, PDF, info and HTML formats) precompiled documentation (PostScript, dvi, PDF, info and HTML formats)
is available from the zsh archive site or its mirrors, in the file is available from the zsh archive site or its mirrors, in the file
<code>zsh-doc.tar.gz</code>. (See <a href="Introduction.html#Availability">Availability</a> zsh-doc.tar.gz. (See <a href="Introduction.html#Availability">Availability</a> for
for a list of sites.)</p> a list of sites.)</p>
<hr /> <hr />
<p>This document was generated on <em>February 15, 2020</em> using <p>This document was generated on <em>May 14, 2022</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html
<a href="http://www.nongnu.org/texi2html/"><em>texi2html 5.0</em></a>.<br /> 5.0</em></a>.<br />
Zsh version 5.8, released on February 14, 2020.</p> Zsh version 5.9, released on May 14, 2022.</p>
</main> </main>
<nav class="nav-wrapper" aria-label="Page navigation"> <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons --> <!-- Mobile navigation buttons -->
<a rel="next" href="Introduction.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Introduction.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
<div style="clear: both"></div> <div style="clear: both"></div>
</nav> </nav>
@ -235,60 +202,32 @@ Zsh version 5.8, released on February 14, 2020.</p>
</div> </div>
<nav class="nav-wide-wrapper" aria-label="Page navigation"> <nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="next" href="Introduction.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> <a rel="next" href="Introduction.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i> <i class="fa fa-angle-right"></i>
</a> </a>
</nav> </nav>
</div> </div>
<!-- Livereload script (if served using the cli tool) -->
<script type="text/javascript">
var socket = new WebSocket("ws://localhost:3000/__livereload");
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function() {
socket.close();
}
</script>
<script type="text/javascript"> <script type="text/javascript">
window.playground_copyable = true; window.playground_copyable = true;
</script> </script>
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script> <script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
<script src="searcher.js" type="text/javascript" charset="utf-8"></script> <script src="searcher.js" type="text/javascript" charset="utf-8"></script>
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
<script src="highlight.js" type="text/javascript" charset="utf-8"></script> <script src="highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book.js" type="text/javascript" charset="utf-8"></script> <script src="book.js" type="text/javascript" charset="utf-8"></script>
<!-- Custom JS scripts --> <!-- Custom JS scripts -->
</body> </body>
</html> </html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -81,8 +81,6 @@
overflow-x: auto; overflow-x: auto;
background: #1d1f21; background: #1d1f21;
color: #c5c8c6; color: #c5c8c6;
padding: 0.5em;
-webkit-text-size-adjust: none;
} }
.coffeescript .javascript, .coffeescript .javascript,