FMTTEST(1)
π FMTTEST(1) β or, the General Commands Manual page where you test your nmh mh-format(5) language programs β¨
okay bestie, welcome to fmttest, straight out of the nmh universe π
πΈ NAME πΈ
fmttest β test programs in nmh's mh-format(5) language π§
like, that's it, that's the whole job description. it tests programs. in nmh's mh-format(5) language. no cap.
β¨ SYNOPSIS β¨
fmttest [-help] [-version] [-form formatfile] [-format formatstring]
[-address | -raw | -date | -message] [-file | -nofile] [--component
component-text] [-dupaddrs | -nodupaddrs] [-ccme | -noccme]
[-outsize size-in-characters] [-width column-width] [-msgnum
number] [-msgcur flag] [-msgsize size] [-unseen flag] [-dump |
-nodump] [-trace | -notrace] [+folder] [msgs | strings]
look at her. so many flags. so much range. she's giving main character energy fr fr π
like, the way that there are choices in there (all those | pipes) means you pick one side of each pair, not both β the vibes are mutually exclusive and the manpage knows it π
and at the very end? you either hand her a +folder and some msgs, or you hand her strings β and honestly both are valid π
okay so that's the whole intro, the details are still loading, and we are SO not done yet β more coming right up, don't you dare close the terminal π
πΈ DESCRIPTION πΈ
okay bestie, fmttest is literally the tool you use to test programs written for the nmh format language, exactly as specified by mh-format(5). It's also intended to replace the ap, dp, and fmtdump programs. π
β¨ Format Program Selection β¨
The -format string and -form formatfile specify a format string or file to read. A format string, if given, must be a single argument to the -format switch. If a format file name is passed to the -form switch, the file is searched for using the normal nmh rules: absolute pathnames are accessed directly, tilde expansion is done on usernames, and files are searched for in the user's Mail directory as specified in their profile. If it's not found there, the directory β/etc/nmhβ is checked. π¦
π¦ Mode Selection and Component Specification π¦
fmttest has four operating modes β address, raw, date, and message β which are selected by the -address, -raw, -date, and -message switches, respectively.
Address mode treats every argument as an email address to be processed by nmh's email parser using the specified format program. The parsed address is made available as a special %{text} component escape, and the output from the program is printed on standard output. If there was an error parsing the email address, the error message is stored in the %{error} component escape. If no format program is given on the command line, the following default program is used:
%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>
Address mode is equivalent to ap(8). π
In raw mode, no processing of the specified arguments is done. Each argument is run against the specified format program with the argument text available in the %{text} component. You must specify a format with -form or -format when using raw mode. π¨
Date mode is identical to raw mode, with one exception: if no format is specified, the following format string is used:
%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>
Date mode is equivalent to dp(8). π
In message mode the arguments to fmttest are interpreted as an optional folder and messages. fmttest will read each specified message and make all of the components in the message available to the format program. Also, the appropriate information for the %(msg), %(cur), %(unseen), and %(size) function escapes will be made available for each message. If the -file switch is given, the arguments are interpreted as filenames instead of message numbers, but otherwise the behavior is the same (except that the %(msg), %(cur), and %(unseen) function escapes will not provide any useful information). π
The default format used in address mode is the default format used by scan. The following command can replicate the functionality of the repl command.
fmttest -nodupaddrs -form replcomps -outsize max [+folder] message
Regardless of the mode, other components can be provided to the format program by the use of the --component switch. For example, the following program will test the use of the βencryptedβ component:
fmttest --encrypted yes -message cur
In message mode, components supplied on the command line will override components from messages. β¨
π Additional Switches π
-dupaddrsand-nodupaddrsβ control whether duplicate addresses are allowed or suppressed by theFORMATADDRinstruction, which is used by the%(formataddr)function escape. In normal operation duplicate addresses are only suppressed byrepl.-ccmeand-noccmeβ control whether or not to count the user's local mailbox as a duplicate address. This replicates the behavior of the-cc meswitch torepl, and only applies if-nodupaddrsis in effect.-outsizeβ controls the maximum number of printable characters that the format engine will produce. Characters marked as non-printing by the format engine with%(zputlit), characters with zero width, and extra bytes that are part of a multibyte character are not counted against this total. Two special values are supported: βmaxβ, which means as many characters as the format engine can produce (limited by internal buffers), and βwidthβ, which will set the value to the width of the terminal. In message mode it defaults to βwidthβ, otherwise the default is βmaxβ. π-widthβ controls the column width which is used by the%(width)function escape. It defaults to the terminal width.-msgnum,-msgcur,-msgsize, and-unseenβ all control the values used, respectively, by the following function escapes:%(num),%(cur),%(size), and%(unseen). If none are supplied, these values are taken from the message in message mode; in all other modes the default values are 0.
π₯ Compiling and Tracing Format Programs π₯
-dumpβ outputs the complete set of format instructions for the specified format program.-traceβ will output each format instruction as it is being executed, and show the values of thenumandstrregisters if they have changed from the previous instruction. The output buffer is also printed if it has changed from the previous instruction. π
π Format Instructions π
It should be noted that there is not a one-to-one correspondence between format escapes and format instructions; many instructions have side effects. Instructions prefixed with βLVβ generally return a integer into the num (value) register; instructions prefixed with a βLSβ return a string into the str register. π§
COMPβ Output componentCOMPFβ Formatted output componentLITβ Output literal textCHARβ Output single characterNUMβ Output the num registerNUMFβ Formatted output of the num registerSTRβ Output the str registerSTRFβ Formatted output of the str registerSTRFWβ Not usedPUTADDRβ Output address list in str registerSTRLITβ Output str, no space compressionSTRLITZβ LikeSTRLIT, but not counted against widthLS_COMPβ Write component to str registerLS_LITβ Write literal to str registerLS_GETENVβ Write environment var to str registerLS_DECODECOMPβ Decode RFC 2047 encoded component to str registerLS_DECODEβ Decode RFC 2047 encoded string to str registerLS_TRIMβ Trim trailing whitespace from str registerLV_COMPβ Convert component to integer, store in num registerLV_COMPFLAGβ Set num to 1 if TRUE set in componentLV_LITβ Load literal value into num registerLV_DATβ Load value from dat array into num register (see note)LV_STRLENβ Set num to the length of strLV_PLUS_Lβ Add value to num registerLV_MINUS_Lβ Subtract value from num registerLV_DIVIDE_Lβ Divide num register by valueLV_MODULO_Lβ num modulo valueLV_CHAR_LEFTβ Store remaining number of printable chars in numLS_MONTHβ Write short name of month to str from date componentLS_LMONTHβ Write long name of month to str from date componentLS_ZONEβ Write time zone offset to str from date componentLS_DAYβ Write short name of day of week to str from date componentLS_WEEKDAYβ Write long name of day of week to str from date componentLS_822DATEβ Write RFC 822 compatible date to str from date componentLS_PRETTYβ Write date with βprettyβ timezone to strLV_SECβ Write date component seconds to numLV_MINβ Write date component minutes to numLV_HOURβ Write date component hour to numLV_MONβ Write date component numeric month to num (start at 1)LV_YEARβ Write date component year to numLV_YDAYβ Write date component Julian day to numLV_WDAYβ Write date component day of week to num (0 == Sunday)LV_ZONEβ Write date component time zone offset to numLV_CLOCKβ Write date component in Unix epoch time to numLV_RCLOCKβ Write offset of date component from current time to numLV_DAYFβ Write 1 to num if day of week is explicitLV_DSTβ Write 1 to num if DST is in effect for date componentLV_ZONEFβ Write 1 to num if timezone is explicitLS_ADDRβ Write email address of addr component to strLS_PERSβ Write personal name of addr component to strLS_MBOXβ Write mailbox (username) of addr component to strLS_HOSTβ Write host of addr component to strLS_PATHβ Write host route of addr component to strLS_GNAMEβ Write group name of addr component to strLS_NOTEβ Write note portion of addr component to strLS_822ADDRβ Write βproperβ RFC 822 version of addr component to strLS_FRIENDLYβ Write friendly (name or note) of address component to strLS_UNQUOTEβ Remove RFC 2822 quotes from stringLV_HOSTTYPEβ Set num to type of host (0=local, 1=network)LV_INGRPFβ Set num to 1 if address was inside of groupLV_NOHOSTFβ Set num to 1 of no host was present in address componentLOCALDATEβ Convert date component to local timezoneGMTDATEβ Convert date component to GMTPARSEDATEβ Parse date componentPARSEADDRβ Parse address componentFORMATADDRβ Add address component to list in strCONCATADDRβ LikeFORMATADDR, but will not suppress duplicatesMYMBOXβ Set num if address component is a local addressSAVESTRβ Save str register temporarilyDONEβ End programNOPβ No operationGOTOβ Jump to new instructionIF_S_NULLβ Branch if str is NULLIF_Sβ Branch if str is not NULLIF_V_EQβ Branch if num is equal to valueIF_V_NEβ Branch if num is not equal to valueIF_V_GTβ Branch if num is greater than valueIF_MATCHβ Branch if str contains stringIF_AMATCHβ Branch if str starts with stringS_NULLβ Set num to 1 if str is NULLS_NONNULLβ Set num to 1 if str is not NULLV_EQβ Set num to 1 if num equals valueV_NEβ Set num to 1 if num does not equal valueV_GTβ Set num to 1 if num is greater than valueV_MATCHβ Set num to 1 if str contains stringV_AMATCHβ Set num to 1 if str starts with string
The LV_DAT instruction is a bit special. Callers of the format library pass in an array of integers that are used by certain format escapes. The current list of format escapes and the indexes they use are:
dat[0] %(num)
dat[1] %(cur)
dat[2] %(size)
dat[3] %(width)
dat[4] %(unseen)
π SEE ALSO π
mh-format(5), repl(1), ap(8), dp(8), fmtdump(8)
π DEFAULTS π
-message-nofile-dupaddrs
π«Ά CONTEXT π«Ά
If a folder is given, it will become the current folder.
π BUGS π
okay so bestie, there's literally only one thing on the bug list and it's giving self-aware:
- it shouldn't require as much code from other programs as it does π
that's it. that's the whole complaint. our girl is highkey dragging herself for being too needy with other programs' code, and honestly? relatable. we've all been there. β¨
ngl it's not a broken bug, it's more of a "she's doing the most and she knows it" bug. still counts, still documented, no cap. π
and that's the whole page, bestie, we ate πβ¨ go forth and fmttest responsibly, you absolute icon π
with so much love from the nmh-1.8 era, dated 2014-08-31 π (yes she's vintage, yes she still slays) π¦π
π¦ where this page comes from
- alpine 3.24: nmh-doc 1.8-r3 Β· BSD-3-Clause
- epel 10: nmh 1.8-3.el10_1 Β· BSD
- epel 9: nmh 1.8-1.el9 Β· BSD
- fedora 43: nmh 1.8-9.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: nmh 1.8-10.fc44 Β· LicenseRef-Callaway-BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms