You are not logged in.
Im working on a script that will do the stage 2 installation for me and its kind of a pain to have to run the whole script again just to see if something that I fixed at the very end was actually fixed. Is there a GOTO command or something like that that will let me skip certain chunks of the script? (ex. place GOTO line 128 at line 5 so I dont have to wait X amount of minutes for it to get there)
Offline
Make a function in your script tat you call when needed.
#function
showhiddenfiles() { ls -a }
#calling the function
showhiddenfiles
Offline
Yeah it appears Bash at least doesn't support any form of GOTO, either you can comment what you don't want to run, or you might be able to put the undesired code into a function and then just not call it, much like xd-0's response
Offline
You can put "labels" in comments and use sed to pass only the part of the script you want to be executed to bash. This won't work well if there are required functions defined above the starting line.
For example:
cookies.sh:
#!/bin/bash
echo cookies
echo ice cream
#tacos
echo tacos
In ~/.bashrc:
bgoto() {
sed -n "/^#$1\$/,\$ p" "$2" | bash
}
And finally run the script starting at #tacos with:
[foutrelis@foutboxd ~]$ bgoto tacos cookies.sh
tacos
It's not pretty, but it should do what you want.
Last edited by foutrelis (2009-08-09 11:46:06)
Offline
@foutrelis, that's a handy trick
Offline
You could run tail on the script and feed that to bash, if you knew how long it was going to be, that is.
Offline
Thanks for the responses but I found a way to block comment stuff using
:<<'END'
commented stuff here
END
Offline