aboutsummaryrefslogtreecommitdiff
path: root/pdksh/pdkshrc.d/scr.pdksh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-10 13:31:03 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-10 13:31:03 +1200
commit835a273f0a708b5ef8c59e299b034c78b045d936 (patch)
tree95ca4e81eeb9571a301fa91c5af07940710f6739 /pdksh/pdkshrc.d/scr.pdksh
parentMerge branch 'master' into openbsd (diff)
downloaddotfiles-835a273f0a708b5ef8c59e299b034c78b045d936.tar.gz
dotfiles-835a273f0a708b5ef8c59e299b034c78b045d936.zip
Port easy bashrc.d scripts to pdkshrc.d
Have left out anything that requires non-trivial fixes, mostly due to variable scope or missing features.
Diffstat (limited to 'pdksh/pdkshrc.d/scr.pdksh')
-rw-r--r--pdksh/pdkshrc.d/scr.pdksh11
1 files changed, 11 insertions, 0 deletions
diff --git a/pdksh/pdkshrc.d/scr.pdksh b/pdksh/pdkshrc.d/scr.pdksh
new file mode 100644
index 00000000..01bd20cb
--- /dev/null
+++ b/pdksh/pdkshrc.d/scr.pdksh
@@ -0,0 +1,11 @@
+# Create a temporary directory and change into it, to stop me putting stray
+# files into $HOME, and making the system do cleanup for me. Single optional
+# argument is the string to use for naming the directory; defaults to "scr".
+scr() {
+ if (($# <= 1)) ; then
+ cd -- "$(mktd "${1:-scr}")"
+ else
+ printf 'ksh: scr: too many arguments\n' >&2
+ return 2
+ fi
+}