#!/usr/bin/env tsh : : tsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: ifzyon.tsh,v 1.1 2019/07/15 16:08:48 jneitzel Exp $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the Public Domain. " : : : " This tsh script (aka command file) illustrates shell voodoo! =^) " : : " Do `if -z string' & `if -n string', where string is specified " : " by $1. As noted by the usage messages below though, string is " : " in fact optional (for this script, but not for if(1)). NOTE: For " : " this script to be found & function correctly, 1) copy it to a " : " directory on your PATH, ensuring the copied script is executable " : " by your effective user/group id/name (see chown(8), chgrp(1), and " : " chmod(1) if needed), and invoke it as in the 1st usage message; 2) " : " or invoke it directly, as in the 2nd usage message (or similar). " : : " usage: ifzyon [string] " : " or: " : " usage: tsh [path/to/]ifzyon [string] " : : : " There is no need to check for correct usage. " : : >>$0'' <'' ; : >>$1'' <'' : " Make temporary directory, or fail with an error & non-zero status. " if ! { mkdir -m 0700 /tmp/ifzyon-$$ } if { exit } if A = B ( : ) >/tmp/ifzyon-$$/expr ( \ echo echo -n \''The specified string "'$1'" is '\' ; \ echo -n expr '"//'$1'" : '\''//.*'\'' - 2 | ' ; \ echo tr -d '\\n' ; \ echo echo '\ character\(s\) in length.' \ ) >>/tmp/ifzyon-$$/expr tsh /tmp/ifzyon-$$/expr ; echo ( : ) >/tmp/ifzyon-$$/run ( \ echo -n if -z ; \ echo -n \ \"$1\" ; \ echo \ echo '\ '-z: The length of '\"'$1'\"' is zero. \ ) >>/tmp/ifzyon-$$/run ( \ echo -n if -n ; \ echo -n \ \"$1\" ; \ echo \ echo '\ '-n: The length of '\"'$1'\"' is non-zero. \ ) >>/tmp/ifzyon-$$/run