Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: functions with redirections



(Sorry for the extensive context for short responses.)

On Oct 2,  9:35am, Peter Stephenson wrote:
}
} On Wed, 01 Oct 2014 21:07:41 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > On Oct 1,  8:17pm, Peter Stephenson wrote:
} > }
} > } On Mon, 29 Sep 2014 14:37:35 -0700
} > } Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > } > 
} > } > foo () { { echo foo } >&3 }
} > 
} > } +function is executed.  Any variables in the redirection are expanded
} > } +at the point the function is executed, but outside the function scope.
} 
} It doesn't make any obvious practical difference simply to expanding
} variables given that no variables appear in the function before the
} redirection is applied.

It makes a practical difference if $argv or its aliases are mentioned, or
for special parameters like funcstack and zsh_eval_context.


} > torch% cat /tmp/foo
} > foo() { echo foo } >&3
} > torch% zcompile -k /tmp/foo
} > torch% autoload foo
} > torch% FPATH=/tmp foo      
} > foo
} > 
} > Oops, the redirection didn't get applied.
} 
} Not sure how that could happen --- there must be some kludge to run the
} function the first time.  I guess this is specific to ksh style ---
} there may be something funny with the EF_RUN flag.

loadautofn() does a direct call to execode() in some cases but not in
others.  That or something like it is probably bypassing the redirect
handling.



Messages sorted by: Reverse Date, Date, Thread, Author