| 1 | proc shvar (...args;;; block) { |
| 2 | var vars = {} |
| 3 | if (len(args) === 0) { |
| 4 | error ('Expected name=value', code=3) |
| 5 | } |
| 6 | |
| 7 | for i, arg in (args) { |
| 8 | var name, s = arg.split("=", count=1) |
| 9 | if (not s) { |
| 10 | error ('Expected name=value', code=3) |
| 11 | } |
| 12 | |
| 13 | setvar vars[name] = s |
| 14 | } |
| 15 | |
| 16 | eval (block, vars=vars) |
| 17 | } |
| 18 | |
| 19 | # vim: sw=2 |