cc: [email protected]
Subject: Re: [ast-users] capturing/transforming shell function output while  
maintaining side effects?
--------
> 
> given an existing shell function (which i'm not free to rewrite) which has 
> impor
> tant side effects (sets variables, etc.) in the shell and which also prints 
> on s
> tdout and/or stderr, how can i either capture the output(s) of the function 
> or p
> ass them to another program for further processing, while still preserving 
> any s
> ide effects? the obvious (command substitution, pipes) seems to run in 
> subshells
> , which means the side effects disappear.
> 
> (as a motivating example, imagine a particularly noisy function that, on 
> success
> , always prints a long message to stderr, and on failures, prints error 
> messages
>  to stderr. i would like to filter out the known success message, which can 
> be m
> atched with a regex, but continue to output anything else. (including stdout, 
> if
>  any.))
> -- 
> Aaron Davies
> [email protected]
> 

You can also run a subshell for which side effects do not disappear.

Instead of $(...), use ${ ...;}.  Note, that the space is required.
It will run the command substitution in the current shell so that side
effects will remain.

${ ...;} is documented in the man page.

David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to