From 8a6e6bb619e3fe15efa0bb59a146b9308045411c Mon Sep 17 00:00:00 2001 From: Lisa Milne Date: Thu, 14 Dec 2023 15:20:33 +1000 Subject: [PATCH] add head function --- clite/commands.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/clite/commands.js b/clite/commands.js index 7802dcb..24043c7 100644 --- a/clite/commands.js +++ b/clite/commands.js @@ -1293,6 +1293,90 @@ Options: return main(args); }); +clite.commands.load('head',function(args,env,io) { + var stdio = io.include('stdio'); + var clite = io.include('clite'); + var lines = 10; + + function help() { + stdio.printf(` +head - copy the first part of files +Usage: head [OPTION] + +Options: +-n the number of lines to print (default 10) +-? Print this help information + `); + } + + function writeFile(fd) { + if (!fd) { + stdio.fprintf(io.stderr,'could not open file\n'); + io.exit(1); + return; + } + + var l; + for (var i=0; i