diff options
-rw-r--r-- | CDScript/README.md | 11 | ||||
-rwxr-xr-x | CDScript/cd | 7 |
2 files changed, 18 insertions, 0 deletions
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 |