-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug
More file actions
executable file
·51 lines (42 loc) · 911 Bytes
/
Copy pathdebug
File metadata and controls
executable file
·51 lines (42 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/bash
# Function to show usage
usage() {
echo "Usage: $0 [-a] source_file [program_arguments...]"
echo " -a: Compile with dependencies (*.c)"
exit 1
}
# Check if no arguments are provided
if [ $# -lt 1 ]; then
usage
fi
# Initialize variables
compile_with_dependencies=false
source_file=""
# Parse options
while getopts ":a" opt; do
case ${opt} in
a )
compile_with_dependencies=true
;;
\? )
usage
;;
esac
done
# Remove parsed options from positional parameters
shift $((OPTIND -1))
# Check if the source file is provided
if [ $# -lt 1 ]; then
usage
else
source_file=$1
shift
fi
# Compile the source file
if $compile_with_dependencies; then
cc -Wall -Werror -Wextra -o exec -g *.c
else
cc -Wall -Werror -Wextra -o exec -g "$source_file"
fi
# Exec with the args passed
lldb ./exec "$@"