Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
soc:2009:lynusvaz:notes:scripting_doc:features_added [2009/08/09 09:27] lynusvaz |
soc:2009:lynusvaz:notes:scripting_doc:features_added [2009/08/16 00:16] lynusvaz |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | The features mentioned here are NOT YET part of mainline gPXE, and are still under development. The modified code can be found in my git repository, in the [[http://git.etherboot.org/?p=people/lynusvaz/gpxe.git;a=shortlog;h=refs/heads/offset|offset]] branch. | + | =====Scripting Features===== |
+ | The features mentioned here are NOT YET part of mainline gPXE, and are still under development. The modified code can be found in my git repository, in the [[http://git.etherboot.org/?p=people/lynusvaz/gpxe.git;a=shortlog;h=refs/heads/expt|expt]] branch. | ||
- | Scripting features: | ||
- Identifiers | - Identifiers | ||
- Arithmetic evaluator | - Arithmetic evaluator | ||
Line 22: | Line 22: | ||
Arithmetic expressions can be evaluated by placing them within $(). | Arithmetic expressions can be evaluated by placing them within $(). | ||
The following operators are supported (in order of decreasing precedence): | The following operators are supported (in order of decreasing precedence): | ||
- | - !, ~ (logical NOT and bitwise negation) | + | - ''!, ~'' (logical NOT and bitwise negation) |
- | - *, /, % (multiplication, division, and modulo) | + | - ''*, /, %'' (multiplication, division, and modulo) |
- | - +, - (addition, subtraction) | + | - ''+, -'' (addition, subtraction) |
- | - <<, >> (left- and right-shift) | + | - ''<<, >>'' (left- and right-shift) |
- | - <, <=, >, >= (inequality) | + | - ''<, <=, >, >='' (inequality) |
- | - !=, == (equal, not equal) | + | - ''!=, =='' (equal, not equal) |
- | - & (bitwise AND) | + | - ''&'' (bitwise AND) |
- | - | (bitwise OR) | + | - ''|'' (bitwise OR) |
- | - ^ (bitwise EX-OR) | + | - ''^'' (bitwise EX-OR) |
- | - && (logical AND) | + | - ''&&'' (logical AND) |
- | - || (logical OR) | + | - ''||'' (logical OR) |
The == and != operators also act on strings. Identifiers are expanded by placing them within ${}. | The == and != operators also act on strings. Identifiers are expanded by placing them within ${}. | ||
E.g.: | E.g.: | ||
Line 69: | Line 69: | ||
Hello | Hello | ||
World | World | ||
+ | Hello World | ||
It's good to see you! | It's good to see you! | ||
Line 120: | Line 121: | ||
fi | fi | ||
- | 6. While and for loops have been added: | + | ====Loops==== |
+ | You can use while and for loops as: | ||
while <condition> | while <condition> | ||
do | do | ||
Line 150: | Line 152: | ||
done | done | ||
displays: | displays: | ||
- | 0 | + | i = 0 |
- | 1 | + | i = 1 |
- | 2 | + | i = 2 |
- | 3 | + | i = 3 |
- | 5 | + | i = 5 |
- | 18 | + | i = 18 |
+ | A break statement will exit a loop, and a continue statement will start the next iteration of the loop. | ||
+ | for i in 1 2 3 4 5 6 | ||
+ | do | ||
+ | if $(${i} == 3) | ||
+ | continue | ||
+ | fi | ||
+ | echo 'i =' ${i} | ||
+ | if $(${i} == 4) | ||
+ | break #This will exit the for loop, not just the if branch | ||
+ | fi | ||
+ | done | ||
+ | displays: | ||
+ | i = 1 | ||
+ | i = 2 | ||
+ | i = 4 | ||