#!/usr/bin/perl # # Copyright © 2015-2025 by Vincent Slyngstad # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS LISTED ABOVE BE LIABLE # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the names of the authors above # shall not be used in advertising or otherwise to promote the sale, use # or other dealings in this Software without prior written authorization # from those authors. # The PDP-8 help file has the following format: # # &COMMAND NAME # &ADDITIONAL COMMAND NAMES(IF ANY) # TEXT OF HELP INFO # &NEXT COMMAND NAME # TEXT OF NEXT HELP INFO # ETC. $tools=`which $0`; $tools =~ s:[^/]*$::; # basename # # Attempt to find a help file in the working directory. # (Otherwise, use the one in 8tools.) $open = 0; for $i ("help.hl", "$tools/help.hl") { open(HELP, $i) || next; $open = 1; last; } die "No help file\n" unless $open; # # Inspect the argument. "*" and "help" list all the choices by searching for # lines beginning with "&". Other values look for the corresponding "&" line, # then dump text until a "\f" is found. $help = 0; push(@ARGV, 'ccl') unless @ARGV; $help = 1 if $ARGV[0] =~ /^help/i; $help = 1 if $ARGV[0] =~ /^[*]$/i; if ($help) { # # List all help topics while () { next unless s/^&//; next if /^\r*$/; print; } } else { $found = 0; while () { $found = 1 if /^[&]$ARGV[0]/i; last if $found; } die "No help for $ARGV[0]\n" unless $found; while () { s/^@//; next if /^[&]/; last if /^\f/; print; } }