commit 7a030a40413aa1f97e04844d0b281695b02580c5
Author: codecrafters-bot <[email protected]>
Date: Mon, 30 Dec 2024 17:23:48 +0000
init [skip ci]
Diffstat:
7 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/.codecrafters/compile.sh b/.codecrafters/compile.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# This script is used to compile your program on CodeCrafters
+#
+# This runs before .codecrafters/run.sh
+#
+# Learn more: https://codecrafters.io/program-interface
+
+# Exit early if any commands fail
+set -e
+
+gcc app/*.c -o /tmp/shell-target
diff --git a/.codecrafters/run.sh b/.codecrafters/run.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# This script is used to run your program on CodeCrafters
+#
+# This runs after .codecrafters/compile.sh
+#
+# Learn more: https://codecrafters.io/program-interface
+
+# Exit early if any commands fail
+set -e
+
+exec /tmp/shell-target "$@"
diff --git a/.gitattributes b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/README.md b/README.md
@@ -0,0 +1,34 @@
+[](https://app.codecrafters.io/users/codecrafters-bot?r=2qF)
+
+This is a starting point for C solutions to the
+["Build Your Own Shell" Challenge](https://app.codecrafters.io/courses/shell/overview).
+
+In this challenge, you'll build your own POSIX compliant shell that's capable of
+interpreting shell commands, running external programs and builtin commands like
+cd, pwd, echo and more. Along the way, you'll learn about shell command parsing,
+REPLs, builtin commands, and more.
+
+**Note**: If you're viewing this repo on GitHub, head over to
+[codecrafters.io](https://codecrafters.io) to try the challenge.
+
+# Passing the first stage
+
+The entry point for your `shell` implementation is in `app/main.c`. Study and
+uncomment the relevant code, and push your changes to pass the first stage:
+
+```sh
+git commit -am "pass 1st stage" # any msg
+git push origin master
+```
+
+Time to move on to the next stage!
+
+# Stage 2 & beyond
+
+Note: This section is for stages 2 and beyond.
+
+1. Ensure you have `c (9.2)` installed locally
+1. Run `./your_program.sh` to run your program, which is implemented in
+ `app/main.c`.
+1. Commit your changes and run `git push origin master` to submit your solution
+ to CodeCrafters. Test output will be streamed to your terminal.
diff --git a/app/main.c b/app/main.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main() {
+ // Flush after every printf
+ setbuf(stdout, NULL);
+
+ // Uncomment this block to pass the first stage
+ // printf("$ ");
+
+ // Wait for user input
+ char input[100];
+ fgets(input, 100, stdin);
+ return 0;
+}
diff --git a/codecrafters.yml b/codecrafters.yml
@@ -0,0 +1,11 @@
+# Set this to true if you want debug logs.
+#
+# These can be VERY verbose, so we suggest turning them off
+# unless you really need them.
+debug: false
+
+# Use this to change the C version used to run your code
+# on Codecrafters.
+#
+# Available versions: c-9.2
+language_pack: c-9.2
diff --git a/your_program.sh b/your_program.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Use this script to run your program LOCALLY.
+#
+# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
+#
+# Learn more: https://codecrafters.io/program-interface
+
+set -e # Exit early if any commands fail
+
+# Copied from .codecrafters/compile.sh
+#
+# - Edit this to change how your program compiles locally
+# - Edit .codecrafters/compile.sh to change how your program compiles remotely
+(
+ cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory
+ gcc app/*.c -o /tmp/shell-target
+)
+
+# Copied from .codecrafters/run.sh
+#
+# - Edit this to change how your program runs locally
+# - Edit .codecrafters/run.sh to change how your program runs remotely
+exec /tmp/shell-target "$@"