| 1 | ## oils_failures_allowed: 1
 | 
| 2 | 
 | 
| 3 | #### shopt supports long flags
 | 
| 4 | shopt -p nullglob
 | 
| 5 | 
 | 
| 6 | shopt --set nullglob
 | 
| 7 | shopt -p nullglob
 | 
| 8 | 
 | 
| 9 | shopt --unset nullglob
 | 
| 10 | shopt -p nullglob
 | 
| 11 | ## STDOUT:
 | 
| 12 | shopt -u nullglob
 | 
| 13 | shopt -s nullglob
 | 
| 14 | shopt -u nullglob
 | 
| 15 | ## END
 | 
| 16 | 
 | 
| 17 | #### shopt supports 'set' options
 | 
| 18 | shopt -p errexit
 | 
| 19 | 
 | 
| 20 | shopt --set errexit
 | 
| 21 | false
 | 
| 22 | 
 | 
| 23 | echo should not get here
 | 
| 24 | ## status: 1
 | 
| 25 | ## STDOUT:
 | 
| 26 | shopt -u errexit
 | 
| 27 | ## END
 | 
| 28 | 
 | 
| 29 | 
 | 
| 30 | #### shopt --unset errexit { }
 | 
| 31 | shopt --set oil:all
 | 
| 32 | 
 | 
| 33 | echo one
 | 
| 34 | 
 | 
| 35 | shopt --unset errexit {
 | 
| 36 |   echo two
 | 
| 37 |   false
 | 
| 38 |   echo three
 | 
| 39 | }
 | 
| 40 | 
 | 
| 41 | false
 | 
| 42 | echo 'should not get here'
 | 
| 43 | 
 | 
| 44 | ## status: 1
 | 
| 45 | ## STDOUT:
 | 
| 46 | one
 | 
| 47 | two
 | 
| 48 | three
 | 
| 49 | ## END
 | 
| 50 | 
 | 
| 51 | #### shopt -p works correctly inside block
 | 
| 52 | shopt --set parse_brace
 | 
| 53 | 
 | 
| 54 | shopt -p | grep inherit_errexit
 | 
| 55 | shopt --set inherit_errexit {
 | 
| 56 |   shopt -p | grep inherit_errexit
 | 
| 57 | }
 | 
| 58 | 
 | 
| 59 | ## STDOUT:
 | 
| 60 | shopt -u inherit_errexit
 | 
| 61 | shopt -s inherit_errexit
 | 
| 62 | ## END
 | 
| 63 | 
 | 
| 64 | 
 | 
| 65 | #### shopt --set GROUP { }
 | 
| 66 | shopt --set parse_brace
 | 
| 67 | 
 | 
| 68 | shopt -p | grep errexit
 | 
| 69 | echo ---
 | 
| 70 | 
 | 
| 71 | shopt --set oil:all {
 | 
| 72 |   #false
 | 
| 73 |   #echo status=$?
 | 
| 74 |   shopt -p | grep errexit
 | 
| 75 | }
 | 
| 76 | echo ---
 | 
| 77 | 
 | 
| 78 | shopt --set oil:upgrade {
 | 
| 79 |   shopt -p | grep errexit
 | 
| 80 | }
 | 
| 81 | echo ---
 | 
| 82 | 
 | 
| 83 | shopt --set strict:all {
 | 
| 84 |   shopt -p | grep errexit
 | 
| 85 | }
 | 
| 86 | 
 | 
| 87 | # TODO: shopt --table should show the error value
 | 
| 88 | 
 | 
| 89 | ## STDOUT:
 | 
| 90 | shopt -u command_sub_errexit
 | 
| 91 | shopt -u inherit_errexit
 | 
| 92 | shopt -u strict_errexit
 | 
| 93 | shopt -u verbose_errexit
 | 
| 94 | ---
 | 
| 95 | shopt -s command_sub_errexit
 | 
| 96 | shopt -s inherit_errexit
 | 
| 97 | shopt -s strict_errexit
 | 
| 98 | shopt -s verbose_errexit
 | 
| 99 | ---
 | 
| 100 | shopt -s command_sub_errexit
 | 
| 101 | shopt -s inherit_errexit
 | 
| 102 | shopt -u strict_errexit
 | 
| 103 | shopt -s verbose_errexit
 | 
| 104 | ---
 | 
| 105 | shopt -u command_sub_errexit
 | 
| 106 | shopt -u inherit_errexit
 | 
| 107 | shopt -s strict_errexit
 | 
| 108 | shopt -u verbose_errexit
 | 
| 109 | ## END
 | 
| 110 | 
 | 
| 111 | #### shopt and block status
 | 
| 112 | shopt --set oil:all
 | 
| 113 | 
 | 
| 114 | shopt --unset errexit {
 | 
| 115 |   false
 | 
| 116 | }
 | 
| 117 | # this is still 0, even though last command was 1
 | 
| 118 | echo status=$?
 | 
| 119 | 
 | 
| 120 | ## STDOUT:
 | 
| 121 | status=0
 | 
| 122 | ## END
 | 
| 123 | 
 | 
| 124 | #### shopt usage error
 | 
| 125 | shopt --set oil:all
 | 
| 126 | 
 | 
| 127 | echo one
 | 
| 128 | shopt --set a {
 | 
| 129 |   echo two
 | 
| 130 | }
 | 
| 131 | echo status=$?
 | 
| 132 | ## status: 2
 | 
| 133 | ## STDOUT:
 | 
| 134 | one
 | 
| 135 | ## END
 | 
| 136 | 
 | 
| 137 | #### shopt -p
 | 
| 138 | 
 | 
| 139 | shopt -p errexit
 | 
| 140 | shopt -p nullglob
 | 
| 141 | 
 | 
| 142 | echo --
 | 
| 143 | shopt -p strict:all | head -n 3
 | 
| 144 | 
 | 
| 145 | echo --
 | 
| 146 | shopt --set strict:all
 | 
| 147 | shopt -p strict:all | head -n 3
 | 
| 148 | 
 | 
| 149 | ## STDOUT:
 | 
| 150 | shopt -u errexit
 | 
| 151 | shopt -u nullglob
 | 
| 152 | --
 | 
| 153 | shopt -u strict_argv
 | 
| 154 | shopt -u strict_arith
 | 
| 155 | shopt -u strict_array
 | 
| 156 | --
 | 
| 157 | shopt -s strict_argv
 | 
| 158 | shopt -s strict_arith
 | 
| 159 | shopt -s strict_array
 | 
| 160 | ## END
 | 
| 161 | 
 | 
| 162 | #### TODO: all options as a table
 | 
| 163 | 
 | 
| 164 | shopt --table
 | 
| 165 | 
 | 
| 166 | # This is unlike shopt -p because
 | 
| 167 | 
 | 
| 168 | # 1) It shows ALL options, not just 'shopt' options
 | 
| 169 | # 2) It shows it in QTT format?
 | 
| 170 | 
 | 
| 171 | # opt_name Str   value Bool
 | 
| 172 | # errexit        true
 | 
| 173 | # nounset        false
 | 
| 174 | #
 | 
| 175 | # Could also be T and F?  JSON is more obvious
 | 
| 176 | 
 | 
| 177 | 
 | 
| 178 | ## STDOUT:
 | 
| 179 | ## END
 | 
| 180 | 
 |