diff --git a/assets/disk0/tvdos/bin/hexdump.js b/assets/disk0/tvdos/bin/hexdump.js index 2e81064..c19eead 100644 --- a/assets/disk0/tvdos/bin/hexdump.js +++ b/assets/disk0/tvdos/bin/hexdump.js @@ -1,14 +1,27 @@ -if (exec_args[1] === undefined) { - printerrln("Usage: hexdump ") - return 1; +let filename = exec_args[1] +let fileContent = undefined +if (filename === undefined && _G.shell.hasPipe()) { + fileContent = _G.shell.getPipe() +} +else if (filename === undefined) { + println('Missing filename ("hexdump -?" for help)'); + return 0; +} +else { + if (filename.startsWith("-?")) { + println("hexdump "); + return 0; + } + + let file = files.open(`${_G.shell.getCurrentDrive()}:/${_G.shell.resolvePathInput(filename).string}`) + if (!file.exists) { + printerrln(_G.shell.resolvePathInput(filename).string+": cannot open"); + return 1; + } + + fileContent = file.sread() } -let file = files.open(`${_G.shell.getCurrentDrive()}:/${_G.shell.resolvePathInput(exec_args[1]).string}`) -if (!file.exists) { - printerrln(_G.shell.resolvePathInput(exec_args[1]).string+": cannot open"); - return 1; -} -let fileContent = file.sread() for (let k = 0; k < fileContent.length; k += 16) { for (let i = 0; i < 16; i++) { diff --git a/doc/implementation.tex b/doc/implementation.tex index 0a39b55..2813f62 100644 --- a/doc/implementation.tex +++ b/doc/implementation.tex @@ -25,6 +25,7 @@ Your Javascript program is stored into the Program Memory, and since its capacit \1\inlinesynopsis[Array]{init}{}{returns the subarray that omits the \emph{last} element.} \1\inlinesynopsis[Array]{sum}{selector}{returns the sum of the elements of the array. Selector is optionally defined to indicate how the value must be transformed to obtain the sum.} \1\inlinesynopsis[Array]{max}{selector}{returns the maximum among the elements of the array. Selector is optionally defined to indicate how the value must be transformed to obtain the max.} +\1\inlinesynopsis[String]{trimNull}{}{trims null characters at the \emph{end} of the string.} \end{outline} diff --git a/doc/tsvmman.idx b/doc/tsvmman.idx index 918904d..0526528 100644 --- a/doc/tsvmman.idx +++ b/doc/tsvmman.idx @@ -18,11 +18,11 @@ \indexentry{graphics (library)|hyperpage}{26} \indexentry{MMIO-graphics|hyperpage}{26} \indexentry{boot process|hyperpage}{29} -\indexentry{commands (DOS)|hyperpage}{30} \indexentry{coreutils (DOS)|hyperpage}{30} -\indexentry{pipe (DOS)|hyperpage}{32} -\indexentry{filesystem (DOS)|hyperpage}{34} -\indexentry{file descriptor (DOS)|hyperpage}{34} -\indexentry{device file|hyperpage}{36} -\indexentry{input (DOS)|hyperpage}{38} -\indexentry{gl (DOS)|hyperpage}{39} +\indexentry{applications (DOS)|hyperpage}{31} +\indexentry{pipe (DOS)|hyperpage}{33} +\indexentry{filesystem (DOS)|hyperpage}{35} +\indexentry{file descriptor (DOS)|hyperpage}{35} +\indexentry{device file|hyperpage}{37} +\indexentry{input (DOS)|hyperpage}{39} +\indexentry{gl (DOS)|hyperpage}{40} diff --git a/doc/tsvmman.ilg b/doc/tsvmman.ilg index 236050f..30850bc 100644 --- a/doc/tsvmman.ilg +++ b/doc/tsvmman.ilg @@ -1,6 +1,6 @@ This is makeindex, version 2.16 [TeX Live 2022] (kpathsea + Thai support). Scanning input file tsvmman.idx....done (28 entries accepted, 0 rejected). -Sorting entries....done (138 comparisons). -Generating output file tsvmman.ind....done (58 lines written, 0 warnings). +Sorting entries....done (137 comparisons). +Generating output file tsvmman.ind....done (61 lines written, 0 warnings). Output written in tsvmman.ind. Transcript written in tsvmman.ilg. diff --git a/doc/tsvmman.ind b/doc/tsvmman.ind index e88fcbe..e700d6f 100644 --- a/doc/tsvmman.ind +++ b/doc/tsvmman.ind @@ -1,5 +1,9 @@ \begin{theindex} + \item applications (DOS), \hyperpage{31} + + \indexspace + \item base64 (library), \hyperpage{13} \item block communication, \hyperpage{16} \item boot process, \hyperpage{29} @@ -9,29 +13,28 @@ \item code page, \hyperpage{22} \item colour palette, \hyperpage{24} \item com (library), \hyperpage{16} - \item commands (DOS), \hyperpage{30} \item con (library), \hyperpage{9} \item console (library), \hyperpage{9} \item coreutils (DOS), \hyperpage{30} \indexspace - \item device file, \hyperpage{36} + \item device file, \hyperpage{37} \indexspace - \item file descriptor (DOS), \hyperpage{34} - \item filesystem (DOS), \hyperpage{34} + \item file descriptor (DOS), \hyperpage{35} + \item filesystem (DOS), \hyperpage{35} \indexspace - \item gl (DOS), \hyperpage{39} + \item gl (DOS), \hyperpage{40} \item graphics (library), \hyperpage{26} \item gzip (library), \hyperpage{12} \indexspace - \item input (DOS), \hyperpage{38} + \item input (DOS), \hyperpage{39} \indexspace @@ -48,7 +51,7 @@ \indexspace - \item pipe (DOS), \hyperpage{32} + \item pipe (DOS), \hyperpage{33} \indexspace diff --git a/doc/tvdos.tex b/doc/tvdos.tex index f957582..30b229e 100644 --- a/doc/tvdos.tex +++ b/doc/tvdos.tex @@ -30,9 +30,9 @@ Variables can be set or changed using \textbf{SET} commands. -\chapter{DOS Commands} +\chapter{Coreutils} -\index{commands (DOS)}\index{coreutils (DOS)}DOS commands are only valid under the DOS environment. +\index{coreutils (DOS)}Coreutils are the core ``commands'' of \thedos. \begin{outline} \1\dossynopsis{cat}{file}{Reads a file and pipes its contents to the pipe, or to the console if no pipes are specified.} @@ -52,7 +52,28 @@ Variables can be set or changed using \textbf{SET} commands. -\chapter{Using DOS Utils on JS} +\chapter{Applications} + +\index{applications (DOS)}Applications are the programs shiped with the standard distribution of \thedos\ that is written for users' convenience. + +This chapter will only briefly list and describe the applications. + +\begin{outline} +\1\dossynopsis{basica}{Invokens a BASIC interpreter stored in the ROM. If no BASIC rom is present, nothing will be done.} +\1\dossynopsis{color}{Changes the background and the foreground of the active session.} +\1\dossynopsis{command}{The default text-based DOS shell. Call with \code{command /fancy} for more \ae sthetically pleasing looks.} +\1\dossynopsis{edit}{path}{The interactive full-screen text editor.} +\1\dossynopsis{false}{Returns errorlevel 1 upon execution.} +\1\dossynopsis{hexdump}{path}{Prints out the contents of a file in hexadecimal view. Supports pipe.} +\1\dossynopsis{less}{path}{Allows user to read the long text, even if they are wider and/or taller than the screen. Supports pipe.} +\1\dossynopsis{printfile}{path}{Prints out the contents of a textfile with line numbers. Useful for making descriptive screenshots.} +\1\dossynopsis{touch}{path}{Updates a file's modification date. New file will be created if the specified file does not exist.} +\1\dossynopsis{true}{Returns errorlevel 0 upon execution.} +\end{outline} + + + +\chapter{Invoking Coreutils on JS} DOS coreutils and some of the internal functions can be used on Javascript program.