1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
;;; Gash -- Guile As SHell
;;; Copyright © 2016, 2017, 2018 R.E.W. van Beusekom <rutger.van.beusekom@gmail.com>
;;; Copyright © 2018, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Gash.
;;;
;;; Gash is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; Gash is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
* else-multiple
:script:
#+begin_src sh
if false; then
:
else
echo one
echo two
fi
#+end_src
* if-bracket-false
:script:
#+begin_src sh
if \[ 0 = 1 ]; then
exit 1
fi
exit 0
#+end_src
* if-bracket
:script:
#+begin_src sh
if \[ 1 = 1 ]; then
exit 0
fi
exit 1
#+end_src
* if-elif
:script:
#+begin_src sh
if false; then
exit 1
elif false; then
exit 2
else
exit 0
fi
exit 1
#+end_src
* if-else
:script:
#+begin_src sh
if false; then
exit 1
else
exit 0
fi
exit 1
#+end_src
* if-false
:script:
#+begin_src sh
if false; then
exit 1
fi
exit 0
#+end_src
* if-line
:script:
#+begin_src sh
if true; then echo yay; fi
#+end_src
* if-multiple
:script:
#+begin_src sh
if true; then
echo one
echo two
fi
#+end_src
:stdout:
#+begin_example
one
two
#+end_example
* if-redirect
:script:
#+begin_src sh
if $SHELL --version | grep foobar 2>/dev/null; then
exit 1
else
exit 0
fi
#+end_src
* if
:script:
#+begin_src sh
if true; then
exit 0
fi
exit 1
#+end_src
* if-test-false
:script:
#+begin_src sh
if test 0 = 1; then
exit 1
fi
exit 0
#+end_src
* if-test
:script:
#+begin_src sh
if test 1 = 1; then
exit 0
fi
exit 1
#+end_src
* if-word-variable
:script:
#+begin_src sh
if \[ x"$y" = x ]; then
exit 0
fi
exit 1
#+end_src
|