bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug-report/request: allow "set +n" to re-enable commands.


From: Richard Neill
Subject: bug-report/request: allow "set +n" to re-enable commands.
Date: Fri, 22 Mar 2013 10:57:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]