typo
[hband-tools.git] / mount / mount.bindfs
blob8106c2c39f4b349fc7ed5d2fd446b06dcf005637
1 #!/bin/bash
3 set -e
4 set -u
6 declare -a argv=()
7 declare -a bindfs_opts=($(bindfs --help | grep -Eio "[-]-[a-z0-9-]+"))
8 fuse_opts=
10 mntname=$1
11 shift
12 mntpoint=$1
13 shift
15 while [ $# -gt 0 ]
17 case "$1" in
18 -o)
19 shift
20 oldIFS=$IFS
21 IFS=,
22 for option in $1
24 is_bindfs_opt=0
25 for bindfs_opt in "${bindfs_opts[@]}"
27 option_key=${option%%=*}
28 if [ ".--$option_key" = ".$bindfs_opt" ]
29 then
30 if [ "$option_key" = mirror -o "$option_key" = mirror-only ]
31 then
32 option=${option//:/,}
34 argv+=("--$option")
35 is_bindfs_opt=1
36 break
38 done
39 if [ $is_bindfs_opt = 0 ]
40 then
41 fuse_opts=$fuse_opts${fuse_opts:+,}$option
43 done
44 IFS=$oldIFS
46 -n|-s)
47 true
50 echo "Unknown option: $1" >&2
51 exit 255
53 esac
54 shift
55 done
57 set +u
59 exec bindfs "${argv[@]}" ${fuse_opts:+-o "$fuse_opts"} "$mntname" "$mntpoint"