satyaortiz-gagne commited on
Commit
0267222
·
2 Parent(s): 240540b d87d4e6

Merge remote-tracking branch 'dataset_template/master' into HEAD

Browse files
.gitattributes CHANGED
@@ -1,3 +1,12 @@
1
 
2
  * annex.backend=MD5E
3
- **/.git* annex.largefiles=nothing
 
 
 
 
 
 
 
 
 
 
1
 
2
  * annex.backend=MD5E
3
+ **/.git* annex.largefiles=nothing
4
+
5
+ * annex.largefiles=(largerthan=1mb)
6
+ *.c annex.largefiles=nothing
7
+ *.cpp annex.largefiles=nothing
8
+ *.h annex.largefiles=nothing
9
+ *.py annex.largefiles=nothing
10
+ *.sh annex.largefiles=nothing
11
+
12
+ scripts/* annex.largefiles=nothing
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .nfs*
2
+ *.jugdata/
3
+ /.tmp/
4
+ /logs/
scripts/datalad.sh ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ source scripts/utils.sh echo -n
4
+
5
+ function activate_gitannex {
6
+ _conda_env=$(git config --file scripts/config/datalad_config --get datalad.conda.conda-env || echo -n)
7
+ if [[ ! -z "${_conda_env}" ]]
8
+ then
9
+ _modules=$(git config --file scripts/config/datalad_config --get datalad.conda.modules || echo -n)
10
+ if [[ -z "$(which conda)" ]] && [[ ! -z "${_modules}" ]]
11
+ then
12
+ module load ${_modules} 2>/dev/null
13
+ eval "$(conda shell.bash hook)"
14
+ fi
15
+ conda activate ${_conda_env} >/dev/null 2>&1 || eval "$(conda shell.bash hook)"
16
+ conda activate ${_conda_env}
17
+ exit_on_error_code "Failed to init git-annex conda env"
18
+ fi
19
+ }
20
+
21
+ function install_datalad {
22
+ init_venv --name venv --prefix .tmp/
23
+ exit_on_error_code "Failed to init venv"
24
+
25
+ datalad --version >/dev/null 2>&1 || python3 -m pip install -r scripts/requirements_datalad.txt
26
+ exit_on_error_code "Failed to install datalad requirements: pip install"
27
+ }
28
+
29
+ which git-annex || activate_gitannex
30
+ datalad --version >/dev/null 2>&1 || install_datalad
31
+ exit_on_error_code "Failed to install datalad requirements: pip install"
32
+
33
+ # Add bin to PATH
34
+ [[ -d "$(realpath bin/)" ]] && export PATH="${PATH}:$(realpath bin)"
35
+
36
+ datalad "$@"
scripts/get_utils.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ wget -O scripts/utils.sh https://raw.githubusercontent.com/satyaog/datasets_utils/095f79be167b721fbff34e45146dba519c44c305/utils.sh
scripts/jug_exec.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ from jug import is_jug_running
3
+
4
+ if is_jug_running():
5
+ from sys import argv
6
+ from jug.utils import jug_execute
7
+ jug_execute(argv[1:])
8
+ else:
9
+ from sys import argv
10
+ from jug.jug import main
11
+ try:
12
+ # Split and reorder jug's argv from script's argv
13
+ argv[:] = ["jug", "execute"] + argv[1:argv.index("--")] + \
14
+ [__file__] + argv[argv.index("--"):]
15
+ except ValueError:
16
+ argv[:] = ["jug", "execute", __file__] + argv[1:]
17
+ main(argv)
scripts/requirements_datalad.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ datalad[core]==0.11.8
2
+ datalad==0.11.8
scripts/stats.sh ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -o errexit -o pipefail -o noclobber
3
+
4
+ function acquire_lock {
5
+ if [ -e .tmp/lock_stats ]
6
+ then
7
+ [[ "$$" -eq "`cat .tmp/lock_stats`" ]] || return 1
8
+ else
9
+ mkdir -p .tmp/
10
+ echo -n "$$" > .tmp/lock_stats
11
+ chmod -wx .tmp/lock_stats
12
+ [[ "$$" -eq "`cat .tmp/lock_stats`" ]] || return 1
13
+ fi
14
+ }
15
+
16
+ function delete_lock {
17
+ rm -f .tmp/lock_stats
18
+ }
19
+
20
+ function if_empty {
21
+ if [[ -z "$1" ]]
22
+ then
23
+ echo -n "$2"
24
+ else
25
+ echo -n "$1"
26
+ fi
27
+ }
28
+
29
+ declare -a _dirs
30
+
31
+ _STDIN=0
32
+ while [[ $# -gt 0 ]]
33
+ do
34
+ _arg="$1"; shift
35
+ case "${_arg}" in
36
+ --stdin) _STDIN=1
37
+ echo "stdin = [${_STDIN}]"
38
+ ;;
39
+ --) break ;;
40
+ -h | --help)
41
+ >&2 echo "Options for $(basename "$0") are:"
42
+ >&2 echo "--stdin force read directories from stdin instead of script's arguments"
43
+ exit 1
44
+ ;;
45
+ *) _dirs+=("${_arg}") ;;
46
+ esac
47
+ done
48
+
49
+ acquire_lock || exit 1
50
+
51
+ trap delete_lock EXIT
52
+
53
+ if [[ ${#_dirs[@]} == 0 ]] || [[ ${_STDIN} == 1 ]]
54
+ then
55
+ readarray -t _dirs
56
+ fi
57
+
58
+ rm -f files_count.stats
59
+ rm -f disk_usage.stats
60
+ find "${_dirs[@]}" -type d | sort -u | while read d
61
+ do
62
+ fc=$(find "$d" -maxdepth 1 -type f | wc -l)
63
+ if [[ "$fc" -ne 0 ]]
64
+ then
65
+ printf "%d\t%s\n" "$fc" "$d" >>files_count.stats
66
+ fi
67
+
68
+ du=$(find "$d" -maxdepth 1 -type f | xargs -r du -c | tail -n1 | cut -f1)
69
+ if [[ ! -z "$du" ]]
70
+ then
71
+ printf "%d\t%s\n" "$du" "$d" >>disk_usage.stats
72
+ fi
73
+
74
+ for sd in "$d"/*
75
+ do
76
+ echo "$sd"
77
+ done | xargs chmod a-w
78
+ done
scripts/utils.sh ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ pushd `dirname "${BASH_SOURCE[0]}"` >/dev/null
4
+ _SCRIPT_DIR=`pwd -P`
5
+ popd >/dev/null
6
+
7
+ function exit_on_error_code {
8
+ local _ERR=$?
9
+ while [[ $# -gt 0 ]]
10
+ do
11
+ local _arg="$1"; shift
12
+ case "${_arg}" in
13
+ --err)
14
+ if [[ ${_ERR} -eq 0 ]]
15
+ then
16
+ _ERR=$1
17
+ fi
18
+ shift
19
+ ;;
20
+ -h | --help)
21
+ if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
22
+ then
23
+ >&2 echo "Unknown option [${_arg}]"
24
+ fi
25
+ >&2 echo "Options for ${FUNCNAME[0]} are:"
26
+ >&2 echo "[--err INT] use this exit code if '\$?' is 0 (optional)"
27
+ >&2 echo "ERROR_MESSAGE error message to print"
28
+ exit 1
29
+ ;;
30
+ *) set -- "${_arg}" "$@"; break ;;
31
+ esac
32
+ done
33
+
34
+ if [[ ${_ERR} -ne 0 ]]
35
+ then
36
+ >&2 echo "$(tput setaf 1)ERROR$(tput sgr0): $1: ${_ERR}"
37
+ exit ${_ERR}
38
+ fi
39
+ }
40
+
41
+ function test_enhanced_getopt {
42
+ ! getopt --test > /dev/null
43
+ if [[ ${PIPESTATUS[0]} -ne 4 ]]
44
+ then
45
+ >&2 echo "enhanced getopt is not available in this environment"
46
+ exit 1
47
+ fi
48
+ }
49
+
50
+ function enhanced_getopt {
51
+ local _NAME=$0
52
+ while [[ $# -gt 0 ]]
53
+ do
54
+ local _arg="$1"; shift
55
+ case "${_arg}" in
56
+ --options) local _OPTIONS="$1"; shift ;;
57
+ --longoptions) local _LONGOPTIONS="$1"; shift ;;
58
+ --name) local _NAME="$1"; shift ;;
59
+ --) break ;;
60
+ -h | --help | *)
61
+ if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
62
+ then
63
+ >&2 echo "Unknown option [${_arg}]"
64
+ fi
65
+ >&2 echo "Options for $(basename "$0") are:"
66
+ >&2 echo "--options OPTIONS The short (one-character) options to be recognized"
67
+ >&2 echo "--longoptions LONGOPTIONS The long (multi-character) options to be recognized"
68
+ >&2 echo "--name NAME name that will be used by the getopt routines when it reports errors"
69
+ exit 1
70
+ ;;
71
+ esac
72
+ done
73
+
74
+ local _PARSED=`getopt --options="${_OPTIONS}" --longoptions="${_LONGOPTIONS}" --name="${_NAME}" -- "$@"`
75
+ if [[ ${PIPESTATUS[0]} -ne 0 ]]
76
+ then
77
+ exit 2
78
+ fi
79
+
80
+ echo "${_PARSED}"
81
+ }
82
+
83
+ function init_conda_env {
84
+ while [[ $# -gt 0 ]]
85
+ do
86
+ local _arg="$1"; shift
87
+ case "${_arg}" in
88
+ --name) local _name="$1"; shift
89
+ echo "name = [${_name}]"
90
+ ;;
91
+ --prefix) local _prefixroot="$1"; shift
92
+ echo "prefix = [${_prefixroot}]"
93
+ ;;
94
+ --tmp) local _prefixroot="$1"; shift
95
+ >&2 echo "Deprecated --tmp option. Use --prefix instead."
96
+ echo "tmp = [${_prefixroot}]"
97
+ ;;
98
+ --) break ;;
99
+ -h | --help | *)
100
+ if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
101
+ then
102
+ >&2 echo "Unknown option [${_arg}]"
103
+ fi
104
+ >&2 echo "Options for ${FUNCNAME[0]} are:"
105
+ >&2 echo "--name STR conda env prefix name"
106
+ >&2 echo "--prefix DIR directory to hold the conda prefix"
107
+ exit 1
108
+ ;;
109
+ esac
110
+ done
111
+
112
+ local _CONDA_ENV=$CONDA_DEFAULT_ENV
113
+
114
+ # Configure conda for bash shell
115
+ eval "$(conda shell.bash hook)"
116
+ if [[ ! -z ${_CONDA_ENV} ]]
117
+ then
118
+ # Stack previous conda env which gets cleared after
119
+ # `eval "$(conda shell.bash hook)"`
120
+ conda activate ${_CONDA_ENV}
121
+ unset _CONDA_ENV
122
+ fi
123
+
124
+ if [[ ! -d "${_prefixroot}/env/${_name}/" ]]
125
+ then
126
+ conda create --prefix "${_prefixroot}/env/${_name}/" --yes --no-default-packages || \
127
+ exit_on_error_code "Failed to create ${_name} conda env"
128
+ fi
129
+
130
+ conda activate "${_prefixroot}/env/${_name}/" && \
131
+ exit_on_error_code "Failed to activate ${_name} conda env"
132
+
133
+ "$@"
134
+ }
135
+
136
+ function init_venv {
137
+ while [[ $# -gt 0 ]]
138
+ do
139
+ local _arg="$1"; shift
140
+ case "${_arg}" in
141
+ --name) local _name="$1"; shift
142
+ echo "name = [${_name}]"
143
+ ;;
144
+ --prefix) local _prefixroot="$1"; shift
145
+ echo "prefix = [${_prefixroot}]"
146
+ ;;
147
+ --tmp) local _prefixroot="$1"; shift
148
+ >&2 echo "Deprecated --tmp option. Use --prefix instead."
149
+ echo "tmp = [${_prefixroot}]"
150
+ ;;
151
+ --) break ;;
152
+ -h | --help | *)
153
+ if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
154
+ then
155
+ >&2 echo "Unknown option [${_arg}]"
156
+ fi
157
+ >&2 echo "Options for ${FUNCNAME[0]} are:"
158
+ >&2 echo "--name STR venv prefix name"
159
+ >&2 echo "--prefix DIR directory to hold the virtualenv prefix"
160
+ exit 1
161
+ ;;
162
+ esac
163
+ done
164
+
165
+ if [[ ! -d "${_prefixroot}/venv/${_name}/" ]]
166
+ then
167
+ mkdir -p "${_prefixroot}/venv/${_name}/" && \
168
+ python3 -m venv "${_prefixroot}/venv/${_name}/" || \
169
+ exit_on_error_code "Failed to create ${_name} venv"
170
+ fi
171
+
172
+ source "${_prefixroot}/venv/${_name}/bin/activate" || \
173
+ exit_on_error_code "Failed to activate ${_name} venv"
174
+ python3 -m pip install --upgrade pip
175
+
176
+ "$@"
177
+ }
178
+
179
+ function print_annex_checksum {
180
+ local _CHECKSUM=MD5
181
+ while [[ $# -gt 0 ]]
182
+ do
183
+ local _arg="$1"; shift
184
+ case "${_arg}" in
185
+ -c | --checksum) local _CHECKSUM="$1"; shift ;;
186
+ -h | --help)
187
+ >&2 echo "Options for $(basename "$0") are:"
188
+ >&2 echo "[-c | --checksum CHECKSUM] checksum to print (default: MD5)"
189
+ exit 1
190
+ ;;
191
+ --) break ;;
192
+ *) >&2 echo "Unknown option [${_arg}]"; exit 3 ;;
193
+ esac
194
+ done
195
+
196
+ for _file in "$@"
197
+ do
198
+ local _annex_file=`ls -l -- "${_file}" | grep -o ".git/annex/objects/.*/${_CHECKSUM}.*"`
199
+ if [[ ! -f "${_annex_file}" ]]
200
+ then
201
+ continue
202
+ fi
203
+ local _checksum=`echo "${_annex_file}" | xargs basename`
204
+ local _checksum=${_checksum##*--}
205
+ echo "${_checksum%%.*} ${_file}"
206
+ done
207
+ }
208
+
209
+ function list {
210
+ while [[ $# -gt 0 ]]
211
+ do
212
+ local _arg="$1"; shift
213
+ case "${_arg}" in
214
+ -d | --dataset) local _DATASET="$1"; shift ;;
215
+ -h | --help)
216
+ >&2 echo "Options for $(basename "$0") are:"
217
+ >&2 echo "[-d | --dataset PATH] dataset location"
218
+ git-annex list --help >&2
219
+ exit 1
220
+ ;;
221
+ --) break ;;
222
+ *) >&2 echo "Unknown option [${_arg}]"; exit 3 ;;
223
+ esac
224
+ done
225
+
226
+ if [[ ! -z "${_DATASET}" ]]
227
+ then
228
+ pushd "${_DATASET}" >/dev/null || exit 1
229
+ fi
230
+
231
+ git-annex list "$@" | { grep -o " .*" | grep -Eo "[^ ]+.*" || test $? = 1 ; }
232
+
233
+ if [[ ! -z "${_DATASET}" ]]
234
+ then
235
+ popd >/dev/null
236
+ fi
237
+ }
238
+
239
+ function subdatasets {
240
+ local _VAR=0
241
+ while [[ $# -gt 0 ]]
242
+ do
243
+ local _arg="$1"; shift
244
+ case "${_arg}" in
245
+ --var) local _VAR=1 ;;
246
+ -h | --help)
247
+ >&2 echo "Options for $(basename "$0") are:"
248
+ >&2 echo "--var also list datasets variants"
249
+ >&2 echo "then following --"
250
+ datalad subdatasets --help
251
+ exit 1
252
+ ;;
253
+ --) break ;;
254
+ *) >&2 echo "Unknown option [${_arg}]"; exit 3 ;;
255
+ esac
256
+ done
257
+
258
+ if [[ ${_VAR} != 0 ]]
259
+ then
260
+ datalad subdatasets $@ | grep -o ": .* (dataset)" | grep -o " .* " | grep -o "[^ ]*" | \
261
+ while read subds
262
+ do
263
+ echo ${subds}
264
+ for _d in "${subds}.var"/*
265
+ do
266
+ if [[ -d "$_d" ]]
267
+ then
268
+ echo $_d
269
+ fi
270
+ done
271
+ done
272
+ else
273
+ datalad subdatasets $@ | grep -o ": .* (dataset)" | grep -o " .* " | grep -o "[^ ]*"
274
+ fi
275
+ }
276
+
277
+ function unshare_mount {
278
+ if [[ ${EUID} -ne 0 ]]
279
+ then
280
+ unshare -rm ./"${BASH_SOURCE[0]}" unshare_mount "$@" <&0
281
+ exit $?
282
+ fi
283
+
284
+ if [[ -z ${_SRC} ]]
285
+ then
286
+ local _SRC=${PWD}
287
+ fi
288
+ while [[ $# -gt 0 ]]
289
+ do
290
+ local _arg="$1"; shift
291
+ case "${_arg}" in
292
+ --src) local _SRC="$1"; shift
293
+ echo "src = [${_SRC}]"
294
+ ;;
295
+ --dir) local _DIR="$1"; shift
296
+ echo "dir = [${_DIR}]"
297
+ ;;
298
+ --cd) local _CD=1
299
+ echo "cd = [${_CD}]"
300
+ ;;
301
+ --) break ;;
302
+ -h | --help | *)
303
+ if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
304
+ then
305
+ >&2 echo "Unknown option [${_arg}]"
306
+ fi
307
+ >&2 echo "Options for $(basename "$0") are:"
308
+ >&2 echo "[--dir DIR] mount location"
309
+ >&2 echo "[--src DIR] source dir (optional)"
310
+ exit 1
311
+ ;;
312
+ esac
313
+ done
314
+
315
+ mkdir -p ${_SRC}
316
+ mkdir -p ${_DIR}
317
+
318
+ local _SRC=$(cd "${_SRC}" && pwd -P)
319
+ local _DIR=$(cd "${_DIR}" && pwd -P)
320
+
321
+ mount -o bind ${_SRC} ${_DIR}
322
+ exit_on_error_code "Could not mount directory"
323
+
324
+ if [[ ! ${_CD} -eq 0 ]]
325
+ then
326
+ cd ${_DIR}
327
+ fi
328
+
329
+ unshare -U ${SHELL} -s "$@" <&0
330
+ }
331
+
332
+ function jug_exec {
333
+ if [[ -z ${_jug_exec} ]]
334
+ then
335
+ local _jug_exec=${_SCRIPT_DIR}/jug_exec.py
336
+ fi
337
+ local _jug_argv=()
338
+ while [[ $# -gt 0 ]]
339
+ do
340
+ local _arg="$1"; shift
341
+ case "${_arg}" in
342
+ --script | -s) local _jug_exec="$1"; shift ;;
343
+ -h | --help)
344
+ >&2 echo "Options for ${FUNCNAME[0]} are:"
345
+ >&2 echo "[--script | -s JUG_EXEC] path to the jug wrapper script (default: '${_jug_exec}')"
346
+ ${_jug_exec} --help
347
+ exit
348
+ ;;
349
+ --) break ;;
350
+ *) _jug_argv+=("${_arg}") ;;
351
+ esac
352
+ done
353
+ # Remove trailing '/' in argv before sending to jug
354
+ jug execute "${_jug_argv[@]%/}" ${_jug_exec} -- "${@%/}"
355
+ }
356
+
357
+ # function unshare_mount {
358
+ # if [[ ${EUID} -ne 0 ]]
359
+ # then
360
+ # unshare -rm ./"${BASH_SOURCE[0]}" unshare_mount "$@" <&0
361
+ # exit $?
362
+ # fi
363
+ #
364
+ # if [[ -z ${_SRC} ]]
365
+ # then
366
+ # local _SRC=${PWD}
367
+ # fi
368
+ # if [[ -z ${_DIR} ]]
369
+ # then
370
+ # local _DIR=${_PWD}
371
+ # fi
372
+ # while [[ $# -gt 0 ]]
373
+ # do
374
+ # local _arg="$1"; shift
375
+ # case "${_arg}" in
376
+ # --src) local _SRC="$1"; shift
377
+ # echo "src = [${_SRC}]"
378
+ # ;;
379
+ # --upper) local _UPPER="$1"; shift
380
+ # echo "upper = [${_UPPER}]"
381
+ # ;;
382
+ # --dir) local _DIR="$1"; shift
383
+ # echo "dir = [${_DIR}]"
384
+ # ;;
385
+ # --wd) local _WD="$1"; shift
386
+ # echo "wd = [${_WD}]"
387
+ # ;;
388
+ # --cd) local _CD=1
389
+ # echo "cd = [${_CD}]"
390
+ # ;;
391
+ # --) break ;;
392
+ # -h | --help | *)
393
+ # if [[ "${_arg}" != "-h" ]] && [[ "${_arg}" != "--help" ]]
394
+ # then
395
+ # >&2 echo "Unknown option [${_arg}]"
396
+ # fi
397
+ # >&2 echo "Options for $(basename "$0") are:"
398
+ # >&2 echo "[--upper DIR] upper mount overlay"
399
+ # >&2 echo "[--wd DIR] overlay working directory"
400
+ # >&2 echo "[--src DIR] lower mount overlay (optional)"
401
+ # >&2 echo "[--dir DIR] mount location (optional)"
402
+ # exit 1
403
+ # ;;
404
+ # esac
405
+ # done
406
+ #
407
+ # mkdir -p ${_SRC}
408
+ # mkdir -p ${_UPPER}
409
+ # mkdir -p ${_WD}
410
+ # mkdir -p ${_DIR}
411
+ #
412
+ # local _SRC=$(cd "${_SRC}" && pwd -P) || echo "${_SRC}"
413
+ # local _UPPER=$(cd "${_UPPER}" && pwd -P)
414
+ # local _WD=$(cd "${_WD}" && pwd -P)
415
+ # local _DIR=$(cd "${_DIR}" && pwd -P)
416
+ #
417
+ # mount -t overlay overlay -o lowerdir="${_SRC}",upperdir="${_UPPER}",workdir="${_WD}" "${_DIR}"
418
+ # exit_on_error_code "Could not mount overlay"
419
+ #
420
+ # if [[ ! ${_CD} -eq 0 ]]
421
+ # then
422
+ # cd ${_DIR}
423
+ # fi
424
+ #
425
+ # unshare -U ${SHELL} -s "$@" <&0
426
+ # }
427
+
428
+ if [[ ! -z "$@" ]]
429
+ then
430
+ "$@"
431
+ fi