Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: skip command from debug trap
- X-seq: zsh-workers 25420
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: PATCH: skip command from debug trap
- Date: Thu, 07 Aug 2008 07:52:51 -0700
- In-reply-to: <20080807111122.3325ada0@news01>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <27237.1217946438@xxxxxxx> <6cd6de210808051647k17f14902nce840ca3edd6ddb@xxxxxxxxxxxxxx> <20080806104716.44647a75@news01> <080806072236.ZM14655@xxxxxxxxxxxxxxxxxxxxxx> <6cd6de210808060730q3ebdc5cdt71b381f861ff0fa1@xxxxxxxxxxxxxx> <20080806145917.GE5197@xxxxxxxxxxxxxxx> <20080806163410.0ce3cacd@news01> <6cd6de210808061000l5c6e0a8fheb06db75560a1598@xxxxxxxxxxxxxx> <200808061754.m76HsOQv002657@xxxxxxxxxxxxxx> <6cd6de210808061209g30b82612r148e576dbe1941bd@xxxxxxxxxxxxxx> <200808061949.m76Jn10k020995@xxxxxxxxxxxxxxxxxxx> <080806180010.ZM15414@xxxxxxxxxxxxxxxxxxxxxx> <20080807111122.3325ada0@news01>
On Aug 7, 11:11am, Peter Stephenson wrote:
} Subject: Re: PATCH: skip command from debug trap
}
} On Wed, 06 Aug 2008 18:00:10 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} >
} > TRAPDEBUG() { return 1 }
} > setopt DEBUG_BEFORE_CMD IGNORE_EOF
} >
} > You've just rendered your shell useless. You can't even exit from it
} > (except by way of the ten-EOFs failsafe we put in some while ago).
}
} I suppose that's power vs. responsibility.
One point: This becomes even easier to screw up if DEBUG_BEFORE_CMD is
the default behavior, and would be mystifying to a typical user.
} > I propose that ERR_EXIT be unset on entry to TRAPDEBUG, always. Then at
} > return from the function, if ERR_EXIT has become set, treat that as an
} > indication to skip the command (and restore ERR_EXIT to whatever its
} > pre-function state was).
After sending this I thought "hmm, I could just as easily have suggested
a new option." I guess it's a good thing I didn't.
} > If you setopt ERR_EXIT and return non-zero
} > you still get what you always would (anyway, if you really wanted the
} > shell to exit, you can just call "exit" from the trap).
}
} This seems quite neat, it even gets round the nastiness of working out
} which level of the function call stack your at to fiddle with the return
} value. It seems perfectly reasonable to make non-use of ERR_EXIT within
} DEBUG traps a documented feature: we already do this during initialisation
} scripts and can invoke the same mechanism trivially here. That's not quite
} what you said---you said let it behave as normal but with the additional
} feature, but given we have the other mechanism to suppress its use, it
} seems neater to apply that here when hijacking the option, right?
Yes; in fact when I first wrote it down I suggested exactly that, but
then noticed that it wasn't necessary to disable it entirely and backed
out that part. If it's actually *easier* this way, the "you can just
call 'exit'" still applies.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author