diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-04-11 12:44:42 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-04-11 12:44:42 -0700 |
commit | c9ac37893fd55b1b079f0d70420ac30673ead775 (patch) | |
tree | 94f4e7d474b6b230be3bc65ec2b38b04f52dab72 | |
parent | 46d47dc916e81903b5edf5bd8a1c621677c35549 (diff) | |
download | gists-c9ac37893fd55b1b079f0d70420ac30673ead775.tar gists-c9ac37893fd55b1b079f0d70420ac30673ead775.tar.gz gists-c9ac37893fd55b1b079f0d70420ac30673ead775.tar.bz2 gists-c9ac37893fd55b1b079f0d70420ac30673ead775.zip |
Add CDScript
-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 |