Question: You are tasked with writing a script that will find all the C function given a directory. Your script will have to recursively look through
You are tasked with writing a script that will find all the C function given a directory. Your script will have to recursively look through the directory and find all .c files and output the functions contained within them.
Given the directory structure:
project/ bridge/ mysql_bridge.c postgres_bridge.c entity/ main.c db_adapter.c
Your code should retrieve all functions from: * mysql_bridge.c * postgres_bridge.c * main.c * db_adapter.c
Your script should output "Unable to find any functions" if no source files were encountered. Specifically, the only source files that should be search for are .c files (headers are ignored)
This will be an opportune time to utilise regular expressions in your script. Your task should execute within Ed's linux environment. If it fails to execute properly, you will receive no marks for this task.
Your script requires using taking a command line argument which should be the root of the project.
Example 1:
./findfn.sh project_1
project_1/ever/jump.c: void logical_jump(int loc) int ngoto() project_1/indent/handle.c: FILE* figure_out_this(char* name) void kill_all() project_1/mac.c: void some(void) int super_function(int xx, int ya) project_1/test.c: void this_function()
Example 2: Bad directory
./findfn.sh file
file is not a directory
Example 3: Unable to find functions
./findfn.sh project_2
Unable to find any functions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
