| 1 | stdlib/
|
| 2 | =======
|
| 3 |
|
| 4 | Ideas for shell functions that could be in here:
|
| 5 |
|
| 6 | - Version comparison: https://github.com/oilshell/oil/issues/683
|
| 7 | - An automated way to download the latest version of Oil: https://github.com/oilshell/oil/issues/463
|
| 8 | - Maybe functions to lazily download documentation too?
|
| 9 | - `errexit` utilities: https://github.com/oilshell/oil/issues/474
|
| 10 |
|
| 11 | ## Notes on Contents
|
| 12 |
|
| 13 | This should be in doc/ref/chap-stdlib.md
|
| 14 |
|
| 15 | two.sh # The two functions I actually use
|
| 16 | byo-server-lib.sh # for using bash to test scripts
|
| 17 | # you need a client too
|
| 18 |
|
| 19 | YSH
|
| 20 |
|
| 21 | args.ysh
|
| 22 | testing.ysh # should these be assertions?
|
| 23 |
|
| 24 | stream.ysh
|
| 25 | table.ysh
|
| 26 |
|
| 27 | math.ysh # abs, max, min - TODO: sum
|
| 28 | list.ysh # any all sum
|
| 29 | funcs.ysh # identity - not that useful
|
| 30 |
|
| 31 | prelude.ysh # todo pass, hm
|
| 32 |
|
| 33 | ## What We Actually Use in Oils
|
| 34 |
|
| 35 | source stdlib/two.sh # I definitely use this
|
| 36 | source stdlib/bash-strict.sh # inherit_errexit
|
| 37 |
|
| 38 | source stdlib/taskfile.sh # questionable?
|
| 39 | # needs function docstring support
|
| 40 | # needs file docstring support
|
| 41 |
|
| 42 | source stdlib/byo-server-lib.sh # convert more of these
|
| 43 |
|
| 44 | ## Task Files Templates
|
| 45 |
|
| 46 | Problem: user scripts wouldn't run under bash:
|
| 47 |
|
| 48 | # Docstring
|
| 49 | source --builtin bash-strict.sh
|
| 50 | source --builtin two.sh
|
| 51 | source --builtin taskfile.sh
|
| 52 |
|
| 53 | foo() {
|
| 54 | echo todo
|
| 55 | }
|
| 56 |
|
| 57 | taskfile "$@"
|
| 58 |
|
| 59 | Test:
|
| 60 |
|
| 61 | # Docstring
|
| 62 | source --builtin bash-strict.sh
|
| 63 | source --builtin two.sh
|
| 64 | source --builtin byo-server-lib.sh
|
| 65 |
|
| 66 | source test/common.sh # assertions
|
| 67 |
|
| 68 | test-foo() {
|
| 69 | echo TODO
|
| 70 | }
|
| 71 |
|
| 72 | byo-maybe-main
|
| 73 |
|
| 74 | Command usage:
|
| 75 |
|
| 76 | byo test stdlib/TEST.sh
|
| 77 |
|
| 78 | I think that is reasonable.
|
| 79 |
|
| 80 | ## Polyfill ideas
|
| 81 |
|
| 82 | ### From Soil - Fix SSH and Bernstein chaining
|
| 83 |
|
| 84 | ssh $USER@$HOST "$(argv-to-str "$@")"
|
| 85 |
|
| 86 | which is simply:
|
| 87 |
|
| 88 | ssh $USER@$HOST "$(printf '%q ' "$@")"
|
| 89 |
|
| 90 | Though it would be more convenient as:
|
| 91 |
|
| 92 | quotefix ssh $USER@$HOST --- "$@"
|
| 93 |
|
| 94 | The --- means you are ending the normal args?
|
| 95 |
|
| 96 |
|
| 97 | Do we also need one for scp? On OS X it seems more weird.
|
| 98 |
|
| 99 | ### exit 255 for xargs?
|
| 100 |
|
| 101 | That's the special exit code to ABORT, hm.
|
| 102 |
|
| 103 | But I think 'each' will not do this? We should concentrate on that.
|
| 104 |
|
| 105 |
|
| 106 | ### strict mode
|
| 107 |
|
| 108 | Not sure it makes sense to source anything for this.
|
| 109 |
|
| 110 | shopt --set strict:all || true 2>&/dev/null
|