1 #+Title: a collection of examples for ob-shell tests
4 * Sample data structures
10 #+NAME: sample_mapping_table
15 #+NAME: sample_big_table
17 | spaghetti | 20 | cm |
22 :ID: 0ba56632-8dc1-405c-a083-c204bae477cf
24 ** Generic shell: no arrays
25 #+begin_src sh :exports results :var array=sample_array
32 ** Bash shell: support for arrays
33 Bash will see a simple indexed array. In this test, we check that the
34 returned value is indeed only the first item of the array, as opposed to
35 the generic serialiation that will return all elements of the array as
37 #+begin_src bash :exports results :var array=sample_array
44 * Associative array tests (simple map)
46 :ID: bec1a5b0-4619-4450-a8c0-2a746b44bf8d
48 ** Generic shell: no special handing
49 The shell will see all values as a single string.
50 #+begin_src sh :exports results :var table=sample_mapping_table
55 : first one second two third three
57 ** Bash shell: support for associative arrays
58 Bash will see a table that contains the first column as the 'index'
59 of the associative array, and the second column as the value.
60 #+begin_src bash :exports results :var table=sample_mapping_table
67 * Associative array tests (more than 2 columns)
69 :ID: 82320a48-3409-49d7-85c9-5de1c6d3ff87
71 ** Generic shell: no special handing
72 #+begin_src sh :exports results :var table=sample_big_table
77 : bread 2 kg spaghetti 20 cm milk 50 dl
79 ** Bash shell: support for associative arrays with lists
80 Bash will see an associative array that contains each row as a single
81 string. Bash cannot handle lists in associative arrays.
82 #+begin_src bash :exports results :var table=sample_big_table
83 echo ${table[spaghetti]}