From eee75716f34767157c0c7597a78ca8fee6d7cd27 Mon Sep 17 00:00:00 2001 From: tg Date: Thu, 28 Jan 2010 15:33:11 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20document=20the=20pipeline=20thing?= =?UTF-8?q?=20better=20=E2=80=A2=20set=20-o=20{posix,sh}=20also=20turns=20?= =?UTF-8?q?off=20the=20other,=20like=20{emacs,gmacs,vi}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mksh.1 | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mksh.1 b/mksh.1 index dc0c678..c053fbe 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.213 2010/01/28 15:23:03 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.214 2010/01/28 15:33:11 tg Exp $ .\" $OpenBSD: ksh.1,v 1.129 2009/05/28 06:09:06 jmc Exp $ .\"- .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 @@ -3591,12 +3591,12 @@ for pristine I/O. The inner loop will be executed in a subshell and variable changes cannot be propagated if executed in a pipeline: .Bd -literal -offset indent -foo \*(Ba bar \*(Ba while read foo; do ...; done +bar \*(Ba baz \*(Ba while read foo; do ...; done .Ed .Pp Use co-processes instead: .Bd -literal -offset indent -foo \*(Ba bar \*(Ba& +bar \*(Ba baz \*(Ba& while read \-p foo; do ...; done exec 3\*(Gt&p; exec 3\*(Gt&\- .Ed @@ -3913,7 +3913,9 @@ Enable a somewhat more ish mode. As a side effect, setting this flag turns off .Ic braceexpand -mode, which can be turned back on manually. +mode, which can be turned back on manually, and +.Ic sh +mode. .It Ic sh Enable .Pa /bin/sh @@ -3921,11 +3923,13 @@ Enable mode. Automatically enabled if the basename of the shell invocation begins with .Dq sh -and this autodetection feature was requested at compilation time +and this autodetection feature is compiled in .Pq not in MirBSD . As a side effect, setting this flag turns off .Ic braceexpand -mode, which can be turned back on manually. +mode, which can be turned back on manually, and +.Ic posix +mode. .It Ic vi Enable .Xr vi 1 Ns -like @@ -5980,6 +5984,13 @@ x=$(case $foo in bar) echo $bar ;; *) echo $baz ;; esac) .Pp Patches welcome. .Pp +The parts of a pipeline, like below, are executed in subshells. +Thus, variable assignments inside them fail. +This is actually a feature; use co-processes instead. +.Bd -literal -offset indent +foo \*(Ba bar \*(Ba read baz # will not change $baz +.Ed +.Pp This document attempts to describe .Nm mksh\ R39+devel and up,