run-gcc is a versatile Bash script designed to simplify the process of compiling and running C and C++ programs. It provides features such as input/output handling, output comparison, and error reporting, making it a convenient tool for developers and testers.
- Automatically detects the file type (
.cor.cpp) and uses the appropriate compiler (gccorg++). - Supports input redirection from a file.
- Compares program output with an expected output file and displays differences.
- Provides detailed error messages for unsupported file types, missing files, and compilation errors.
- Includes options for displaying help and version information.
For detailed instructions on installing, updating, and uninstalling run-gcc, please refer to the Installation Guide.
To install run-gcc using the provided Makefile, run:
make installThis will install the script to /usr/bin and the manual page to /usr/share/man/man1.
To uninstall, run:
make uninstallrun-gcc <source_file> [OPTIONS]
run-gcc --new <filename> [--template <name>]
run-gcc --list-templates <extension>-
-h, --help
Show the help message and exit. -
-v, --version
Show the script version and exit. -
-i, --input <file>
Specify an input file to provide input to the program. -
-e, --expected <file>
Specify an expected output file for comparison. -
-d, --diff
Show the difference between the program output and the expected output.
-
--new <filename>
Create a new source file from a template. -
--template <name>
Specify which template to use when creating a new file (default:default). -
--list-templates <extension>
List available templates for a specific file extension (c,cpp).
# Create a new C file with the default template
run-gcc --new hello.c
# Create a new C++ file with a specific template
run-gcc --new solution.cpp --template competitive
# List available templates for C files
run-gcc --list-templates crun-gcc hello.crun-gcc hello.cpprun-gcc hello_with_input.c -i input.txtrun-gcc hello_with_input.c -i input.txt -e expected_output.txtrun-gcc hello_with_input.c -i input.txt -e wrong_output.txt -dTemplates are stored in ~/.run-gcc/templates/ directory and organized by language:
~/.run-gcc/templates/c/- C templates~/.run-gcc/templates/cpp/- C++ templates
You can customize existing templates or add new ones by creating files in these directories. Template files must match the extension of the language they're for (e.g., .c for C templates, .cpp for C++ templates).
The following templates are included by default:
C Templates:
default- Basic C program structurecompetitive- Competitive programming template with common includes
C++ Templates:
default- Basic C++ program structurecompetitive- Competitive programming template with fast I/O and common includes
To add your own template:
- Create a new file in the appropriate language directory (e.g.,
~/.run-gcc/templates/c/mytemplate.c) - Add your template code to the file
- Use it with
run-gcc --new myfile.c --template mytemplate
The project includes automated tests written in Bats. To run the tests, execute:
make testContributions are welcome! If you'd like to contribute to run-gcc, please follow the guidelines outlined in the Contributing Guide.
- Fork the repository and clone it locally.
- Create a new branch for your feature or bug fix.
- Make your changes, ensuring they follow the project's coding conventions.
- Test your changes thoroughly.
- Submit a pull request with a detailed description of your changes.
For more details, refer to the Contributing Guide.
This project is licensed under the MIT License. See the LICENSE file for details.