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

Re: PATCH: failed autoload

Bart Schaefer wrote:
> Suppose you're calling the failing function in a loop.  Now you'll get
> the error repeatedly, as often as the loop manages to keep running,
> rather than only once.
> schaefer<509> repeat 7 breakthis
> breakthis:3: parse error near `\n'
> breakthis:3: parse error near `\n'

But surely that's correct?  If the function gets redefined to a no-op it
silently succeeds, which could in principle cause untold mayhem.

% cat ~/fns/copy_file_to_backup
# deliberate typo
if [[ -f $1 ]]: then
  cp $1 ~/backup_files
% autoload copy_file_to_backup
% for f in *; do copy_file_to_backup $1 && rm -f $1; done

(I haven't dared tried this but I think you get the picture even if the
example's a bit awry.)

I've noticed the old behaviour with trepidation before, but never done
anything about it; I don't remember there being any discussion about
making it a deliberate feature.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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