[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug-report/request: allow "set +n" to re-enable commands.
From: |
Chris Down |
Subject: |
Re: bug-report/request: allow "set +n" to re-enable commands. |
Date: |
Sat, 23 Mar 2013 12:49:42 +0800 |
For 1, use a heredoc to a noop. Sorry for the terse reply, on my phone.
On 23 Mar 2013 05:07, "Richard Neill" <rn214@richardneill.org> wrote:
> Dear All,
>
> Might I suggest/request that "set +n" should undo the effect of
> "set -n" ?
>
> For example:
>
> #!/bin/bash
> echo one
> set -n
> echo two
> set +n
> echo three
>
> would print:
> one
> three
>
>
> Here's why I think it would be useful:
>
>
> 1. Bash doesn't have a block-comment mechanism, like /* ... */
> and this would provide one.
>
> 2. The documentation for "help set" says that flags can be undone with
> "+", thus the inverse of -n is +n.
> (though in contradiction , it also says that subsequent commands (which
> would include the "set" are ignored)
>
>
> 3. It would allow for a neat hack with polyglots. For example:
>
> #!/bin/bash -n
> <?php /*
> set +n
> echo "Hello, from Bash"
> exec /usr/bin/php -ddisplay_errors=E_ALL $0 $@
> */
> echo "Hello from PHP ".phpversion()."\n";
> //continue in PHP till the end of the file.
> ?>
>
>
> (there is actually a serious purpose to this, namely to create a php-cli
> script that shows all errors, despite the settings in the system-wide
> php-ini file)
>
> Example 3 works if you remove the "-n" and "set +n" parts, though it then
> emits an annoying complaint about "?php: No such file or directory"
>
>
> Thank you for your consideration,
>
> Best wishes,
>
> Richard
>
>