#!/usr/bin/env etsh
:
: etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;;
:
: "  @(#)$Id: pev,v 1.4 2019/03/26 09:10:29 jneitzel Exp $  "
:
: "  The author of this file, J.A. Neitzel <jan (at) etsh (dot) nl>,  "
: "  hereby grants it to the public domain.                           "
:

:
: "  print etsh version (+ ls(1) & file(1) its components)                "
:
: "  As you may gather from the diagnostic on lines 35 - 41 below,        "
: "  your shell's PATH ($p) is important.  Fortunately, if you use etsh   "
: "  as your login shell and install it into / using the default PREFIX,  "
: "  you should be all set; the example rc files configure PREFIX ($X)    "
: "  and PATH ($p) for you.  Otherwise, you can adjust them below         "
: "  if needed.                                                           "
:
: "  usage: pev  "
:

set N pev
if $# -ne 0 if { exit } fd2 -e echo "usage: $N" ; if A == B
set X '/usr/local'
set Y 'etsh-5.4.0'
if $Y != $v if { exit } fd2 -e echo "$N: $Y != $v: error" ; if A == B
set Z '/usr/local/libexec/etsh-5.4.0/etsh'
if { which $Z/pev >/dev/null } goto path-ok-jump
:
: " Print a nicely formatted diagnostic, and exit with a non-zero status. "
:
fd2 -e head -7 ; if A == B ; exit
$Z/pev: not found

Add the value of $Z to your shell's PATH ($p), the beginning
is preferable if possible (but the end should work if not).
Otherwise, this script will not function correctly; the same
is true if etsh and tsh are not found in a directory on your
shell's PATH ($p).
: " diagnostic done "
: path-ok-jump

if -n "$d" -a -d "$d" goto jump
	set A ""
	goto jump1
: jump
	set A "$d"
	: fallthrough
: jump1

. SetV ; : " Notice that SetV uses ETSHDIR ($d). "

set B "$d"
set C ""
if "$B" == "$A" goto jump2
	set C 'cd ; rm -r "'"$B"'" ; cd -'
	: fallthrough
: jump2

:
: " Do the work now... "
:
echo This is $V!
which which etsh tsh ; echo $X/libexec/$v/tsh/[fgi]* | tr ' ' '\n'
( which which etsh tsh ; echo $X/libexec/$v/tsh/[fgi]* ) |\
	( tr '\n' ' ' ; echo ) |\
		sed 's/.*/ls -fl & ; file &/' | etsh
date '+%A, %Y-%m-%d, %T %Z'
$C
: zero status
