From 3b9fe3fd6b0b491b0fab6a3627c0f46c7cabbe8b Mon Sep 17 00:00:00 2001 From: Lisa Milne Date: Fri, 24 Nov 2023 16:08:39 +1000 Subject: [PATCH] add uname() to stdlib, and add uname command --- clite/commands.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++ clite/core.js | 19 ++++++++--- readme.txt | 18 ++++++++-- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/clite/commands.js b/clite/commands.js index f3c2975..c07417f 100644 --- a/clite/commands.js +++ b/clite/commands.js @@ -555,5 +555,89 @@ Options: return 0; }); +clite.commands.load('uname',function(args,env,io) { + var stdlib = io.include('stdlib'); + var sysname = false; + var nodename = false; + var release = false; + var version = false; + var machine = false; + + function help() { + io.write(` +uname - print system information + +Options: +-a All, equivalent to -mnrsv +-m Print the hardware info (User Agent) +-n Print the network name +-r Print the operating system release +-s Print the operating system name +-v Print the operating system version +-? Print this help information + `); + } + + for (var i=1; i ['ls','-l','var'] + uname() + returns an object containing system information: + { + sysname:'CLIte', // system name, always 'CLIte' + nodename:'localhost', // network hostname, currently always 'localhost' + release:'0.1...', // contains the current CLIte version as stored in clite.state.version + version:'0.1...', // same as release + machine:navigator.userAgent // contains the browser user agent string + } + fork(env,io,call) Creates a new process, with environment and io data passed to it. Returns the pid of the new process, or 0 on failure.