Thread (64 messages) flat view 64 messages, 5 authors, 2016-06-15

Re: [PATCHv2 1/8] test-lib: allow negation of prerequisites

From: Jeff King <hidden>
Date: 2016-06-15 22:55:18

On Wed, Nov 14, 2012 at 11:46:58PM -0800, Jonathan Nieder wrote:
quoted
+test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' '
I have a visceral nervousness when reading this code, from too much
unpleasant experience of bash's csh-style !history expansion.  Luckily
bash does not treat ! specially in the '-o sh' mode used by tests.
I can understand, having been bitten by it many times myself (not only
is it counter-intuitively expanded inside double quotes, and not only
does it not do what you wanted, but it does not insert the command into
the history, so you cannot even go back to fix it easily).
Does this feature work when running a test explicitly using
"bash <name of test>"?  That's something I do from time to time to
figure out whether a weird behavior is shell-specific.
Yes. You can test it yourself with "bash t0000-basic.sh". The reason is
that the "!" is part of history expansion, which is only enabled by
default for interactive shells.
If it works everywhere, this patch would help me conquer my fear of
exclamation points in git's tests, which would be a comfort to me and
a very good thing.
As far as I know, "!" should be safe in a non-interactive shell script.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help