[Abcde-users] [PATCH] Replace Sub-shell Parenthesis with Curly Braces and Indent

Roger rogerx.oss at gmail.com
Thu Mar 26 18:43:33 GMT 2015


> On Thu, Mar 26, 2015 at 10:48:19AM -0400, David Murphy wrote:
>   Date: Wed, 25 Mar 2015 11:03:34 -0400 From: rogerx.oss at gmail.com > 1)
>   Replaced the parenthesis within four piped script/code block sections and
>   > instead use curly braces or curly brackets. Hence, variables should now
>   be > preserved within and after the piped sections are called. (ie.
>   Sub-shells > variables are lost, as the shell called using parenthesis is
>   a separately > executed shell and might close an old bug here.) Have you
>   tested this?

As previously mentioned, yes.  And as previously mentioned, other users are 
going to need they're preferred method of extraction and preferred compression.  
So far, I think I've tested the defacto method and the method I always utilize.

>   The way I understood the stackexchange link you posted before
>   (http://unix.stackexchange.com/questions/127334/bash-subshell-creation-with-curly-braces),
>   piping multiple curly-brace blocks together will still cause subshells to
>   be spawned. I could definitely be misinterpreting that, though.

If I'm not mistaken; if your read the /usr/bin/abcde scripting, you'll notice 
there is (likely) only one set of braces within these three to four instances 
of curly brace blocks.  (Any other braces are likely variable enclosures, but I 
think the style of scripting used within abcde, avoids using curly braces even 
for encapsulating variables.)

As the description stands; one set of curly braces, a sub-shell is not created.  
Two or more curly braces, then a sub-shell is supposedly created.  I think the 
stackexchange.com posted info further describes the pipe as the main cause of 
the sub-shell creation.

So likely something to keep an eye on while further developing the pre/post 
custom user functions.

You might be getting confused, and thinking subsequent blocks causing 
sub-shells?  While we're talking embedded blocks here.

But with all that stated, nothing within the patch should change the behavior 
of abcde, except that variable definitions are now preserved and the patch 
inadvertently fixes an editor's syntax high lighting.  Indentional also seems 
to reflect the indenting style used within elsewhere of the script, and doesn't 
have an effect on performance.  If you've monitored these lists, Steve is also 
now trying to figure out where we're loosing variable definitions, and this is 
likely it.  (ie. Known bug.)

Personally, I'd rely more so on the following for reliable information, instead 
of focusing on stackexchange or other speculative resources:

{}  Block of code [curly brackets].                                                             
http://tldp.org/LDP/abs/html/special-chars.html#CODEBLOCKREF

I think I would always question stackexchange.com and similar information, 
before actually relying upon it.

Here's some hard copy resources for futher reference:

Newham, Cameron, and Bill Rosenblatt. Learning the Bash Shell. Beijing: 
O'Reilly, 2005; ISBN 0596009658. Page 176.  Section "Command blocks".

Another great book, but seems to dance around the loss of variable definitions 
when using blocks and sub-shells.  But well written and focues on writing 
easily readable scripts, while including focusing on ensuring the scripts use 
fewer resources.

Burtch, Ken O. Linux Shell Scripting with Bash. Indianapolis, IN: Sams Pub., 
2004; ISBN 0672326426.


-- 
Roger
http://rogerx.freeshell.org/



More information about the Abcde-users mailing list