Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Attach
PointerAlignment: Right
SpaceAfterCStyleCast: true
SpaceBeforeParens: ControlStatements
20 changes: 20 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Checks: >
bugprone-*,
clang-analyzer-*,
performance-*,
portability-*,
readability-*,
-readability-identifier-length,
-readability-magic-numbers,
-readability-isolate-declaration,
-readability-function-cognitive-complexity,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-easily-swappable-parameters,
-bugprone-branch-clone,
-bugprone-implicit-widening-of-multiplication-result,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-security.ArrayBound,
-clang-analyzer-unix.StdCLibraryFunctions,
-clang-analyzer-core.NullDereference
WarningsAsErrors: ''
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
pull_request:
push:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cmake
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Build and test
run: ./run_tests.sh
Comment thread
Copilot marked this conversation as resolved.

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install lint tools
run: |
sudo apt-get update
sudo apt-get install -y clang-format clang-tidy
- name: clang-format (dry-run)
run: |
clang-format --dry-run --Werror $(find src include tests -name '*.c' -o -name '*.h')
- name: Configure for clang-tidy
run: cmake -B cmake-build-debug -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: clang-tidy
run: |
clang-tidy -p cmake-build-debug -warnings-as-errors=* $(find src include -name '*.c')
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
Comment thread
Copilot marked this conversation as resolved.
steps:
- uses: actions/checkout@v4
- name: Install cmake
run: |
sudo apt-get update
sudo apt-get install -y cmake
- name: Build (Release)
run: |
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: build/shell
generate_release_notes: true
114 changes: 58 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,58 @@
# Trigger

## Overview

This project aims to create a clean, efficient shell.

## Building

```bash
cmake -B cmake-build-debug -S .
cmake --build cmake-build-debug
```

## Running

```bash
./cmake-build-debug/shell
```

## Testing

The project includes comprehensive unit tests for all modules. To run the tests:

```bash
# Quick way
./run_tests.sh

# Or manually
cd cmake-build-debug
ctest --verbose
```

All tests use a custom lightweight testing framework that provides colored output and clear assertion messages.

## Goals

- Develop a functional, well‑structured shell.
- Ensure the shell is performant and easy to use.
- Continuously improve the project as I learn more.
- Maintain high code quality with unit tests.

## Inspiration

I’ll start by adapting the simple shell tutorial from Brennan Baker:

<https://brennan.io/2015/01/16/write-a-shell-in-c/>

This will serve as a solid foundation, which I'll later expand and customize. The resulting shell, named **Trigger**, will combine the tutorial's core ideas with additional features and optimizations.

## Development

Feature development is a collaboration between the project author and AI tooling: the
author reviews, directs, and integrates AI-generated contributions alongside
hand-written logic. All changes undergo code review before landing.

Feel free to explore the repository, submit issues, or contribute improvements.
# Trigger

[![CI](https://github.com/melogtm/trigger/actions/workflows/ci.yml/badge.svg)](https://github.com/melogtm/trigger/actions/workflows/ci.yml)

## Overview

This project aims to create a clean, efficient shell.

## Building

```bash
cmake -B cmake-build-debug -S .
cmake --build cmake-build-debug
```

## Running

```bash
./cmake-build-debug/shell
```

## Testing

The project includes comprehensive unit tests for all modules. To run the tests:

```bash
# Quick way
./run_tests.sh

# Or manually
cd cmake-build-debug
ctest --verbose
```

All tests use a custom lightweight testing framework that provides colored output and clear assertion messages.

## Goals

- Develop a functional, well‑structured shell.
- Ensure the shell is performant and easy to use.
- Continuously improve the project as I learn more.
- Maintain high code quality with unit tests.

## Inspiration

I’ll start by adapting the simple shell tutorial from Brennan Baker:

<https://brennan.io/2015/01/16/write-a-shell-in-c/>

This will serve as a solid foundation, which I'll later expand and customize. The resulting shell, named **Trigger**, will combine the tutorial's core ideas with additional features and optimizations.

## Development

Feature development is a collaboration between the project author and AI tooling: the
author reviews, directs, and integrates AI-generated contributions alongside
hand-written logic. All changes undergo code review before landing.

Feel free to explore the repository, submit issues, or contribute improvements.
32 changes: 16 additions & 16 deletions include/builtins.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef BUILTINS_H
#define BUILTINS_H

int trigger_cd(char **args);
int trigger_help(char **args);
int trigger_exit(char **args);
int trigger_pwd(char **args);
int trigger_echo(char **args);
int trigger_export(char **args);
int trigger_unset(char **args);
int trigger_num_builtins(void);

extern char *builtin_str[];
extern int (*builtin_func[])(char **);

#endif
#ifndef BUILTINS_H
#define BUILTINS_H
int trigger_cd(char **args);
int trigger_help(char **args);
int trigger_exit(char **args);
int trigger_pwd(char **args);
int trigger_echo(char **args);
int trigger_export(char **args);
int trigger_unset(char **args);
int trigger_num_builtins(void);
extern char *builtin_str[];
extern int (*builtin_func[])(char **);
#endif
21 changes: 10 additions & 11 deletions include/execute.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#ifndef EXECUTE_H
#define EXECUTE_H

#define CHILD_PROCESS_EXITED 0
#define EXEC_RETURNED_FAILURE (-1)

int trigger_launch(char **args);
int trigger_execute(char ***args_ptr, int **glob_eligible_ptr);

#endif

#ifndef EXECUTE_H
#define EXECUTE_H

#define CHILD_PROCESS_EXITED 0
#define EXEC_RETURNED_FAILURE (-1)

int trigger_launch(char **args);
int trigger_execute(char ***args_ptr, int **glob_eligible_ptr);

#endif
12 changes: 6 additions & 6 deletions include/glob_expand.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef GLOB_EXPAND_H
#define GLOB_EXPAND_H

char **expand_globs(char **argv, int **glob_eligible_ptr);

#endif
#ifndef GLOB_EXPAND_H
#define GLOB_EXPAND_H
char **expand_globs(char **argv, int **glob_eligible_ptr);
#endif
25 changes: 12 additions & 13 deletions include/input.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#ifndef INPUT_H
#define INPUT_H

#define TRIGGER_AUTOMATIC_BUFFER_SIZE 0
#define GET_LINE_REACHED_END_OF_FILE_OR_ERROR (-1)
#define TRIGGER_TOK_DELIM " \t\r\n\a"

char *trigger_read_line(void);
char **trigger_split_line(const char *line);
char **trigger_split_line_ex(const char *line, int **out_glob_eligible);

#endif

#ifndef INPUT_H
#define INPUT_H

#define TRIGGER_AUTOMATIC_BUFFER_SIZE 0
#define GET_LINE_REACHED_END_OF_FILE_OR_ERROR (-1)
#define TRIGGER_TOK_DELIM " \t\r\n\a"

char *trigger_read_line(void);
char **trigger_split_line(const char *line);
char **trigger_split_line_ex(const char *line, int **out_glob_eligible);

#endif
28 changes: 14 additions & 14 deletions include/pipeline.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef PIPELINE_H
#define PIPELINE_H

typedef struct {
char **argv;
char *infile;
char *outfile;
int append;
} PipelineStage;

PipelineStage *trigger_parse_pipeline(char **tokens, int *num_stages);
int trigger_execute_pipeline(PipelineStage *stages, int num_stages);

#endif
#ifndef PIPELINE_H
#define PIPELINE_H
typedef struct {
char **argv;
char *infile;
char *outfile;
int append;
} PipelineStage;
PipelineStage *trigger_parse_pipeline(char **tokens, int *num_stages);
int trigger_execute_pipeline(PipelineStage *stages, int num_stages);
#endif
Loading
Loading