1set -eu
2
3args=()
4declare -i path_args=0
5
6while (( $# )); do
7 if (( $# == 1 )); then
8 if (( path_args > 1)) || [[ "$1" = */ ]]; then
9 mkdir -p "$1"
10 else
11 mkdir -p "$(dirname "$1")"
12 fi
13 fi
14 case $1 in
15 -C) ;;
16 -o | -g) shift ;;
17 -m | -l)
18 # handle next arg so not counted as path arg
19 args+=("$1" "$2")
20 shift
21 ;;
22 -*) args+=("$1") ;;
23 *)
24 path_args+=1
25 args+=("$1")
26 ;;
27 esac
28 shift
29done