BASH

Bill Gradwohl bill at ycc.com
Sat Dec 4 17:28:35 UTC 2004


Sean wrote:

>:2,450s/^/#/
>
>And then afterward remove the comments with:
>
>:2,450s/^#//
>
>Not pretty, but maybe good for what you need?
>
>  
>
As you said - not pretty, but I'll keep it in my arsenal.
Thanks.

I guess this is where old DOS and the much hated "goto" offered 
something beneficial. Adding a label to a line of code and then issuing 
a goto to that label at the top of the script is better than the 
alternatives. The label can be left in the code as it does no harm and 
even acts as a bit of documentation. Removing or commenting the goto at 
the top is obvious. Therefore only a one line change can undo this.

Your commenting suggestion can be dangerous as you'd have to remember 
the range to undo it later. The if structure I've used is also inferior 
as it requires you to comment or get rid of both the "if" and the "fi" 
statements requiring 2 lines be changed.

I wish there were an alternative.

-- 
Bill Gradwohl
bill at ycc.com
http://www.ycc.com
spamSTOMPER Protected email




More information about the fedora-list mailing list