From c9ac37893fd55b1b079f0d70420ac30673ead775 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Mon, 11 Apr 2022 12:44:42 -0700 Subject: Add CDScript --- CDScript/README.md | 11 +++++++++++ CDScript/cd | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 CDScript/README.md create mode 100755 CDScript/cd diff --git a/CDScript/README.md b/CDScript/README.md new file mode 100644 index 0000000..2c0fe83 --- /dev/null +++ b/CDScript/README.md @@ -0,0 +1,11 @@ +# cd(1) + +`cd` may not be a shell built-in. + +Usage: `/path/to/cd /path/` + +Requires root. Not working on fish. + +## Under the hood + +I just ptrace to attach to the shell and call the `chdir()` syscall. diff --git a/CDScript/cd b/CDScript/cd new file mode 100755 index 0000000..463fe8e --- /dev/null +++ b/CDScript/cd @@ -0,0 +1,7 @@ +#!/bin/sh +set -e +DIR=$1 +if test -z "$DIR"; then + DIR=$HOME +fi +exec sudo gdb -ex 'set confirm off' -ex "call (int) chdir(\"$DIR\")" -ex quit -p $PPID -- cgit v1.2.3