CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/gittools/path-nonlibraries.sh
Views: 1798
1
#!/usr/bin/env bash
2
3
usage() {
4
cat >&$1 <<EOF
5
Usage: $0 [OPTIONS]
6
7
Read a list of files relative to ardupilot's root directory and output the
8
non-libraries subsystems they belong to.
9
10
Options:
11
--show-paths, -p Print also file paths after the library name.
12
--help, -h Show this help message.
13
EOF
14
}
15
16
show_paths=false
17
18
while [[ -n $1 ]]; do
19
case "$1" in
20
--show-paths|-p)
21
show_paths=true
22
;;
23
--help|-h)
24
usage 1
25
exit 0
26
;;
27
*)
28
usage 2
29
exit 1
30
;;
31
esac
32
33
shift
34
done
35
36
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
37
ROOT=$(dirname $(git -C $SCRIPT_DIR rev-parse --git-dir))
38
39
if $show_paths; then
40
sedcmd="s,\([^/]\+\).*,\1\t\0,"
41
else
42
sedcmd="s,\([^/]\+\).*,\1,"
43
fi
44
45
grep -v "^libraries" | \
46
sed $sedcmd | \
47
sort | \
48
uniq | \
49
if $show_paths; then
50
while read d f; do
51
[[ -d "$ROOT/$d" ]] && printf "%s\t%s\n" "$d" "$f"
52
done
53
else
54
while read d; do
55
[[ -d "$ROOT/$d" ]] && echo "$d"
56
done
57
fi
58
59