aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-14 00:40:53 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-14 00:40:53 +1200
commit90676f972029029b42b7927b28ef7b08825881bf (patch)
tree4411bd18334f0d82160b7521c459b1cb86101744
parentMerge branch 'master' into freebsd (diff)
parentMerge branch 'openbsd' (diff)
downloaddotfiles-90676f972029029b42b7927b28ef7b08825881bf.tar.gz
dotfiles-90676f972029029b42b7927b28ef7b08825881bf.zip
Merge branch 'master' into freebsd
-rw-r--r--Makefile8
-rw-r--r--README.markdown6
-rw-r--r--X/xbindkeysrc7
-rw-r--r--X/xinitrc4
-rw-r--r--bash/bashrc.d/bc.bash3
-rw-r--r--bash/bashrc.d/ed.bash2
-rw-r--r--bash/bashrc.d/hgrep.bash2
-rw-r--r--bash/bashrc.d/prompt.bash36
-rwxr-xr-xbin/br3
-rw-r--r--bin/brxs3
-rwxr-xr-xbin/td2
-rw-r--r--git/gitconfig.m43
-rw-r--r--man/man1/br.121
-rw-r--r--man/man1/brxs.117
-rw-r--r--man/man1/rnda.11
-rw-r--r--man/man1/rnds.14
-rw-r--r--pdksh/kshrc14
-rw-r--r--pdksh/pdkshrc14
-rw-r--r--pdksh/pdkshrc.d/diff.pdksh4
-rw-r--r--pdksh/pdkshrc.d/ed.pdksh26
-rw-r--r--pdksh/pdkshrc.d/gdb.pdksh4
-rw-r--r--pdksh/pdkshrc.d/gpg.pdksh10
-rw-r--r--pdksh/pdkshrc.d/keychain.pdksh4
-rw-r--r--pdksh/pdkshrc.d/mkcd.pdksh4
-rw-r--r--pdksh/pdkshrc.d/prompt.pdksh (renamed from pdksh/kshrc.d/prompt.ksh)49
-rw-r--r--pdksh/pdkshrc.d/pwgen.pdksh8
-rw-r--r--pdksh/pdkshrc.d/rcsdiff.pdksh4
-rw-r--r--pdksh/pdkshrc.d/scp.pdksh9
-rw-r--r--pdksh/pdkshrc.d/scr.pdksh11
-rw-r--r--pdksh/pdkshrc.d/sudo.pdksh7
-rw-r--r--pdksh/pdkshrc.d/tmux.pdksh19
-rw-r--r--pdksh/pdkshrc.d/vim.pdksh15
-rw-r--r--sh/profile.d/env.sh14
-rwxr-xr-xtest/pdksh8
34 files changed, 280 insertions, 66 deletions
diff --git a/Makefile b/Makefile
index ce19001f..937e9528 100644
--- a/Makefile
+++ b/Makefile
@@ -209,11 +209,11 @@ install-i3 : install-x
install -m 0755 -d -- "$(HOME)"/.i3
install -pm 0644 -- i3/* "$(HOME)"/.i3
-install-pdksh : test-pdksh
+install-pdksh : test-pdksh install-sh
install -m 0755 -d -- \
- "$(HOME)"/.kshrc.d
- install -pm 0644 -- pdksh/kshrc "$(HOME)"/.kshrc
- install -pm 0644 -- pdksh/kshrc.d/* "$(HOME)"/.kshrc.d
+ "$(HOME)"/.pdkshrc.d
+ install -pm 0644 -- pdksh/pdkshrc "$(HOME)"/.pdkshrc
+ install -pm 0644 -- pdksh/pdkshrc.d/* "$(HOME)"/.pdkshrc.d
install-maildir :
install -m 0755 -d -- \
diff --git a/README.markdown b/README.markdown
index dc97891d..4d3bf251 100644
--- a/README.markdown
+++ b/README.markdown
@@ -207,8 +207,9 @@ things like give default arguments to `pwgen(1)`.
#### pdksh
The pdksh configuration files and functions are not nearly as featureful as the
-Bash ones. At the time of writing, these have only been tested on OpenBSD's
-pdksh fork, since that's the only reason I use it.
+Bash ones. They're tested on OpenBSD and FreeBSD pdksh implementations, but the
+former is the primary system for which I'm maintaining them, and there are some
+feature differences.
### GnuPG
@@ -325,6 +326,7 @@ Installed by the `install-bin` target:
* `ax(1)` evaluates an awk expression given on the command line; this is
intended as a quick way to test how Awk would interpret a given expression.
* `bel(1)` prints a terminal bell character.
+* `br(1)` launches $BROWSER.
* `ca(1)` prints a count of its given arguments.
* `cf(1)` prints a count of entries in a given directory.
* `clrd(1)` sets up a per-line file read, clearing the screen first.
diff --git a/X/xbindkeysrc b/X/xbindkeysrc
index 1e13cd62..a329fe7c 100644
--- a/X/xbindkeysrc
+++ b/X/xbindkeysrc
@@ -1,15 +1,18 @@
"exec urxvtcd"
Mod4 + Return
-"exec palemoon"
+"exec br"
Mod4 + b
"exec dmenu_run -fn 'terminus-iso8860-1-12' -nb '#111111' -nf '#eeeeee' -sb '#285577' -sf '#ffffff'"
Mod4 + d
-"exec gimp"
+"exec brxs"
Mod4 + g
+"exec gimp"
+ Mod4 + i
+
"exec i3lock --color=#000000 --image ~/.i3/lock.png --nofork"
Mod4 + slash
diff --git a/X/xinitrc b/X/xinitrc
index 643d2d4a..5e3af7e1 100644
--- a/X/xinitrc
+++ b/X/xinitrc
@@ -1,5 +1,5 @@
-# Browser within X is Pale Moon
-BROWSER=palemoon
+# Browser within X is Firefox
+BROWSER=firefox
export BROWSER
# Read X resources
diff --git a/bash/bashrc.d/bc.bash b/bash/bashrc.d/bc.bash
index 1a963708..643678ac 100644
--- a/bash/bashrc.d/bc.bash
+++ b/bash/bashrc.d/bc.bash
@@ -1,3 +1,6 @@
+# This function is only applicable if bc(1) has the non-POSIX -q option
+command bc -q </dev/null >&0 2>&0 || return
+
# Don't print the bc(1) welcome message
bc() {
command bc -q "$@"
diff --git a/bash/bashrc.d/ed.bash b/bash/bashrc.d/ed.bash
index 4653743b..b87894df 100644
--- a/bash/bashrc.d/ed.bash
+++ b/bash/bashrc.d/ed.bash
@@ -10,7 +10,7 @@ ed() {
# Colon prompt (POSIX)
set -- -p : "$@"
- # Verbose if availble (not POSIX)
+ # Verbose if available (not POSIX)
if ed -sv - </dev/null >&0 2>&0 ; then
set -- -v "$@"
fi
diff --git a/bash/bashrc.d/hgrep.bash b/bash/bashrc.d/hgrep.bash
index e5a5d4c9..2f7f8d54 100644
--- a/bash/bashrc.d/hgrep.bash
+++ b/bash/bashrc.d/hgrep.bash
@@ -8,7 +8,7 @@ hgrep() {
printf >&2 '%s: Need a pattern\n' "$FUNCNAME"
exit 2
fi
- if ! [[ $HISTFILE ]] ; then
+ if ! [[ -n $HISTFILE ]] ; then
printf >&2 '%s: No HISTFILE\n' "$FUNCNAME"
exit 2
fi
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index ba678909..feae7833 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -112,40 +112,22 @@ prompt() {
fi
branch=${branch##*/}
- # Safely read status with -z --porcelain
- local line
- local -i ready modified untracked
- while IFS= read -rd '' line ; do
- if [[ $line == [MADRCT]* ]] ; then
- ready=1
- fi
- if [[ $line == ?[MADRCT]* ]] ; then
- modified=1
- fi
- if [[ $line == '??'* ]] ; then
- untracked=1
- fi
- done < <(git status -z --porcelain 2>/dev/null)
-
- # Build state array from status output flags
- local -a state
- if ((ready)) ; then
- state[${#state[@]}]='+'
+ local state
+ if ! git diff-files --quiet ; then
+ state=${state}!
fi
- if ((modified)) ; then
- state[${#state[@]}]='!'
+ if ! git diff-index --cached --quiet HEAD ; then
+ state=${state}+
fi
- if ((untracked)) ; then
- state[${#state[@]}]='?'
+ if [[ -n $(git ls-files --others --exclude-standard) ]] ; then
+ state=${state}?
fi
-
- # Add another indicator if we have stashed changes
if git rev-parse --verify refs/stash >/dev/null 2>&1 ; then
- state[${#state[@]}]='^'
+ state=${state}^
fi
# Print the status in brackets with a git: prefix
- (IFS= ; printf '(git:%s%s)' "${branch:-unknown}" "${state[*]}")
+ printf '(git:%s%s)' "${branch:-unknown}" "$state"
;;
# Subversion prompt function
diff --git a/bin/br b/bin/br
new file mode 100755
index 00000000..1d982c04
--- /dev/null
+++ b/bin/br
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Launch $BROWSER
+exec "$BROWSER" "$@"
diff --git a/bin/brxs b/bin/brxs
new file mode 100644
index 00000000..5324885d
--- /dev/null
+++ b/bin/brxs
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Run $BROWSER with an URL retrieved from X's PRIMARY select
+exec br "$(xsel)"
diff --git a/bin/td b/bin/td
index 6d9aa064..e6cbfd93 100755
--- a/bin/td
+++ b/bin/td
@@ -12,7 +12,7 @@ file=${1:-"${TODO_NAME:-todo}"}
cd -- "$dir" || exit
# If the current directory isn't a Git repository, try to create one
-if ! command isgr >/dev/null ; then
+if ! command -v isgr >/dev/null ; then
printf >&2 'isgr: command not found\n'
exit 1
fi
diff --git a/git/gitconfig.m4 b/git/gitconfig.m4
index ea6b1220..060740a2 100644
--- a/git/gitconfig.m4
+++ b/git/gitconfig.m4
@@ -21,6 +21,9 @@
date = local
decorate = short
+[merge]
+ ff = false
+
[push]
default = matching
diff --git a/man/man1/br.1 b/man/man1/br.1
new file mode 100644
index 00000000..5d4d928b
--- /dev/null
+++ b/man/man1/br.1
@@ -0,0 +1,21 @@
+.TH BR 1 "August 2016" "Manual page for br"
+.SH NAME
+.B br
+\- launch "$BROWSER"
+.SH SYNOPSIS
+.B br
+.br
+.B br
+http://www.example.com/
+.br
+BROWSER=firefox
+.B br
+.SH DESCRIPTION
+.B br
+execs the program in the $BROWSER environment variable. That's it. It was
+written so the browser could safely be launched from xbindkeys(1) and similar
+programs.
+.SH SEE ALSO
+brxs(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/brxs.1 b/man/man1/brxs.1
new file mode 100644
index 00000000..fe6adb95
--- /dev/null
+++ b/man/man1/brxs.1
@@ -0,0 +1,17 @@
+.TH BRXS 1 "August 2016" "Manual page for brxs"
+.SH NAME
+.B brxs
+\- launch "$BROWSER" with the contents of the X clipboard as the sole argument
+.SH SYNOPSIS
+.B brxs
+BROWSER=firefox
+.B brxs
+.SH DESCRIPTION
+.B brxs
+runs br(1) with the contents of the X selection buffer as retrieved by xsel(1)
+as its sole argument. The intent is to have a quick way to fire up the browser
+to look at an URL you have in your clipboard.
+.SH SEE ALSO
+br(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/rnda.1 b/man/man1/rnda.1
index 3c573662..4cfd7cbd 100644
--- a/man/man1/rnda.1
+++ b/man/man1/rnda.1
@@ -4,7 +4,6 @@
\- return a low-quality random choice from the given arguments
.SH SYNOPSIS
.B rnda
-.br
arg1 arg2 arg3
.SH DESCRIPTION
.B rnda
diff --git a/man/man1/rnds.1 b/man/man1/rnds.1
index 67a3f9a7..f259bd84 100644
--- a/man/man1/rnds.1
+++ b/man/man1/rnds.1
@@ -15,7 +15,9 @@ read, defaulting to 32. This is intended as a low-quality seed for rndi(1).
.P
/dev/urandom is tried first, then /dev/arandom, then /dev/random, before the
script gives up and emits nothing.
+.P
+If you have OpenSSL, you will almost certainly prefer rand(1ssl).
.SH SEE ALSO
-rndi(1), rnda(1), rndf(1), rndl(1), rndn(6)
+rndi(1), rnda(1), rndf(1), rndl(1), rand(1ssl), rndn(6)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/pdksh/kshrc b/pdksh/kshrc
deleted file mode 100644
index c0697774..00000000
--- a/pdksh/kshrc
+++ /dev/null
@@ -1,14 +0,0 @@
-# Emacs-style key bindings
-set -o braceexpand
-set -o emacs
-
-# Save history
-HISTFILE=$HOME/.sh_history
-HISTSIZE=$((1 << 12))
-
-# Load any supplementary scripts
-for kshrc in "$HOME"/.kshrc.d/*.ksh ; do
- [[ -e $kshrc ]] || continue
- . "$kshrc"
-done
-unset -v kshrc
diff --git a/pdksh/pdkshrc b/pdksh/pdkshrc
new file mode 100644
index 00000000..46dbba2c
--- /dev/null
+++ b/pdksh/pdkshrc
@@ -0,0 +1,14 @@
+# Emacs-style key bindings
+set -o braceexpand
+set -o emacs
+
+# Save history
+HISTFILE=$HOME/.pdksh_history
+HISTSIZE=$((1 << 12))
+
+# Load any supplementary scripts
+for pdkshrc in "$HOME"/.pdkshrc.d/*.pdksh ; do
+ [[ -e $pdkshrc ]] || continue
+ . "$pdkshrc"
+done
+unset -v pdkshrc
diff --git a/pdksh/pdkshrc.d/diff.pdksh b/pdksh/pdkshrc.d/diff.pdksh
new file mode 100644
index 00000000..2c752c8d
--- /dev/null
+++ b/pdksh/pdkshrc.d/diff.pdksh
@@ -0,0 +1,4 @@
+# Use a unified format for diff(1) by default
+diff() {
+ command diff -u "$@"
+}
diff --git a/pdksh/pdkshrc.d/ed.pdksh b/pdksh/pdkshrc.d/ed.pdksh
new file mode 100644
index 00000000..f64f6dc6
--- /dev/null
+++ b/pdksh/pdkshrc.d/ed.pdksh
@@ -0,0 +1,26 @@
+# Add a colon prompt to ed when a command is expected rather than text; makes
+# it feel a lot more like using ex. Only do this when stdin is a terminal,
+# however. Also try and use -v for more verbose error output, and rlwrap(1) if
+# it's available.
+ed() {
+
+ # We're only adding options if input is from a terminal
+ if [[ -t 0 ]] ; then
+
+ # Colon prompt (POSIX)
+ set -- -p : "$@"
+
+ # Verbose if availble (not POSIX)
+ if ed -sv - </dev/null >&0 2>&0 ; then
+ set -- -v "$@"
+ fi
+ fi
+
+ # Execute the ed(1) call, in a wrapper if appropriate and with the
+ # concluded options
+ if [[ -t 0 ]] && command -v rlwrap >/dev/null ; then
+ command rlwrap ed "$@"
+ else
+ command ed "$@"
+ fi
+}
diff --git a/pdksh/pdkshrc.d/gdb.pdksh b/pdksh/pdkshrc.d/gdb.pdksh
new file mode 100644
index 00000000..ec9d4137
--- /dev/null
+++ b/pdksh/pdkshrc.d/gdb.pdksh
@@ -0,0 +1,4 @@
+# Don't print the GDB copyright message on every invocation
+gdb() {
+ command gdb -q "$@"
+}
diff --git a/pdksh/pdkshrc.d/gpg.pdksh b/pdksh/pdkshrc.d/gpg.pdksh
new file mode 100644
index 00000000..62d123ea
--- /dev/null
+++ b/pdksh/pdkshrc.d/gpg.pdksh
@@ -0,0 +1,10 @@
+# Wrapper around gpg(1) to stop ``--batch'' breaking things
+gpg() {
+ # shellcheck disable=SC2048
+ case $* in
+ *--ed*|*--gen-k*|*--sign-k*)
+ set -- --no-batch "$@"
+ ;;
+ esac
+ command gpg "$@"
+}
diff --git a/pdksh/pdkshrc.d/keychain.pdksh b/pdksh/pdkshrc.d/keychain.pdksh
new file mode 100644
index 00000000..40fe5d71
--- /dev/null
+++ b/pdksh/pdkshrc.d/keychain.pdksh
@@ -0,0 +1,4 @@
+# If GPG_TTY is set, update it
+if [[ -n $GPG_TTY ]] ; then
+ GPG_TTY=$(tty)
+fi
diff --git a/pdksh/pdkshrc.d/mkcd.pdksh b/pdksh/pdkshrc.d/mkcd.pdksh
new file mode 100644
index 00000000..6342d4a6
--- /dev/null
+++ b/pdksh/pdkshrc.d/mkcd.pdksh
@@ -0,0 +1,4 @@
+# Create a directory and change into it
+mkcd() {
+ mkdir -p -- "$1" && builtin cd -- "$1"
+}
diff --git a/pdksh/kshrc.d/prompt.ksh b/pdksh/pdkshrc.d/prompt.pdksh
index d261b90d..c3db782b 100644
--- a/pdksh/kshrc.d/prompt.ksh
+++ b/pdksh/pdkshrc.d/prompt.pdksh
@@ -18,6 +18,7 @@ prompt() {
# Set up prompt, including optional PROMPT_PREFIX and PROMPT_SUFFIX
# variables
PS1='[\u@\h:\w]'
+ PS1=$PS1'$(prompt vcs)'
PS1=$PS1'$(prompt job)'
PS1='${PROMPT_PREFIX}'$PS1
PS1=$PS1'${PROMPT_SUFFIX}'
@@ -76,6 +77,44 @@ prompt() {
PS4='+<$?> $LINENO:'
;;
+ # Git prompt function
+ git)
+ # Bail if we have no git(1)
+ if ! hash git 2>/dev/null ; then
+ return 1
+ fi
+
+ # Attempt to determine git branch, bail if we can't
+ typeset branch
+ branch=$( {
+ git symbolic-ref --quiet HEAD ||
+ git rev-parse --short HEAD
+ } 2>/dev/null )
+ if [[ ! -n $branch ]] ; then
+ return 1
+ fi
+ branch=${branch##*/}
+
+ typeset state
+ if ! git diff-files --quiet ; then
+ # Two exclamation marks, as that's how you get a literal "!" in
+ # a pdksh PS1
+ state=${state}!!
+ fi
+ if ! git diff-index --cached --quiet HEAD ; then
+ state=${state}+
+ fi
+ if [[ -n $(git ls-files --others --exclude-standard) ]] ; then
+ state=${state}?
+ fi
+ if git rev-parse --verify refs/stash >/dev/null 2>&1 ; then
+ state=${state}^
+ fi
+
+ # Print the status in brackets with a git: prefix
+ printf '(git:%s%s)' "${branch:-unknown}" "$state"
+ ;;
+
# Revert to simple inexpensive prompts
off)
PS1='\$ '
@@ -84,6 +123,16 @@ prompt() {
PS4='+ '
;;
+ # VCS wrapper prompt function; print the first relevant prompt, if any
+ vcs)
+ typeset vcs
+ for vcs in "${PROMPT_VCS[@]:-git}" ; do
+ if prompt "$vcs" ; then
+ return
+ fi
+ done
+ ;;
+
# Show the count of background jobs in curly brackets, if not zero
job)
typeset -i jobc
diff --git a/pdksh/pdkshrc.d/pwgen.pdksh b/pdksh/pdkshrc.d/pwgen.pdksh
new file mode 100644
index 00000000..7ba056e5
--- /dev/null
+++ b/pdksh/pdkshrc.d/pwgen.pdksh
@@ -0,0 +1,8 @@
+# Set some defaults for pwgen(1), because its defaults are to give me a long
+# list of relatively short passwords, when I generally want only one good one
+pwgen() {
+ if ! (($#)) ; then
+ set -- --secure -- "${PWGEN_LENGTH:-15}" "${PWGEN_COUNT:-1}"
+ fi
+ command pwgen "$@"
+}
diff --git a/pdksh/pdkshrc.d/rcsdiff.pdksh b/pdksh/pdkshrc.d/rcsdiff.pdksh
new file mode 100644
index 00000000..18b1d324
--- /dev/null
+++ b/pdksh/pdkshrc.d/rcsdiff.pdksh
@@ -0,0 +1,4 @@
+# Use a unified format for rcsdiff(1) by default
+rcsdiff() {
+ command rcsdiff -u "$@"
+}
diff --git a/pdksh/pdkshrc.d/scp.pdksh b/pdksh/pdkshrc.d/scp.pdksh
new file mode 100644
index 00000000..c3565f21
--- /dev/null
+++ b/pdksh/pdkshrc.d/scp.pdksh
@@ -0,0 +1,9 @@
+# Wrap scp(1) to check for missing colons
+scp() {
+ # shellcheck disable=SC2048
+ if (($# >= 2)) && [[ $* != *:* ]] ; then
+ printf 'ksh: scp: Missing colon, probably an error\n' >&2
+ return 2
+ fi
+ command scp "$@"
+}
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
+}
diff --git a/pdksh/pdkshrc.d/sudo.pdksh b/pdksh/pdkshrc.d/sudo.pdksh
new file mode 100644
index 00000000..d6d91d12
--- /dev/null
+++ b/pdksh/pdkshrc.d/sudo.pdksh
@@ -0,0 +1,7 @@
+# Add the -H parameter to sudo(8) calls, always use the target user's $HOME
+sudo() {
+ if [[ $1 != -v ]] ; then
+ set -- -H "$@"
+ fi
+ command sudo "$@"
+}
diff --git a/pdksh/pdkshrc.d/tmux.pdksh b/pdksh/pdkshrc.d/tmux.pdksh
new file mode 100644
index 00000000..f0d0e36a
--- /dev/null
+++ b/pdksh/pdkshrc.d/tmux.pdksh
@@ -0,0 +1,19 @@
+# Attach to existing tmux session rather than create a new one if possible
+tmux() {
+
+ # If given any arguments, just use them as they are
+ if (($#)) ; then
+ :
+
+ # If a session exists, just attach to it
+ elif command tmux has-session 2>/dev/null ; then
+ set -- attach-session -d
+
+ # Create a new session with an appropriate name
+ else
+ set -- new-session -s "${TMUX_SESSION:-default}"
+ fi
+
+ # Execute with concluded arguments
+ command tmux "$@"
+}
diff --git a/pdksh/pdkshrc.d/vim.pdksh b/pdksh/pdkshrc.d/vim.pdksh
new file mode 100644
index 00000000..37fc1871
--- /dev/null
+++ b/pdksh/pdkshrc.d/vim.pdksh
@@ -0,0 +1,15 @@
+# If Vim exists on the system, use it instead of ex, vi, and view
+if ! hash vim 2>/dev/null ; then
+ return
+fi
+
+# Define functions proper
+ex() {
+ vim -e "$@"
+}
+vi() {
+ vim "$@"
+}
+view() {
+ vim -R "$@"
+}
diff --git a/sh/profile.d/env.sh b/sh/profile.d/env.sh
index ba8e7f49..f1b83919 100644
--- a/sh/profile.d/env.sh
+++ b/sh/profile.d/env.sh
@@ -1,8 +1,10 @@
-# If we're running some kind of ksh, export ENV to find ~/.kshrc. Bash differs
-# considerably from this behaviour; it uses ENV as its startup file when it's
-# invoked as sh(1), and uses .bashrc or --rcfile as its interactive startup
-# file, so it doesn't need to be specified here.
-if [ -n "$KSH_VERSION" ] ; then
- ENV=$HOME/.kshrc
+# If we're running some kind of ksh, export ENV to find a suitable startup
+# file. Bash differs considerably from this behaviour; it uses ENV as its
+# startup file when it's invoked as sh(1), and uses .bashrc or --rcfile as its
+# interactive startup file, so it doesn't need to be specified here.
+case $KSH_VERSION in
+ *'PD KSH '*) ENV=$HOME/.pdkshrc ;;
+esac
+if [ -n "$ENV" ] ; then
export ENV
fi
diff --git a/test/pdksh b/test/pdksh
index 5ebd556a..fd1d55b7 100755
--- a/test/pdksh
+++ b/test/pdksh
@@ -1,6 +1,6 @@
#!/bin/sh
-for ksh in ksh/* ; do
- [ -f "$ksh" ] || continue
- ksh -n "$ksh" || exit
+for pdksh in pdksh/* pdksh/pdkshrc.d/* ; do
+ [ -f "$pdksh" ] || continue
+ ksh -n "$pdksh" || exit
done
-printf 'All ksh(1) scripts parsed successfully.\n'
+printf 'All pdksh scripts parsed successfully.\n'