Ruud H.G. van Tol on Tue, 24 Sep 2024 16:12:44 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: my attempt to find operating system



On 2024-09-24 13:33, Jean-Luc Arnaud wrote:
Thanks for your help, American Citizen.

Below is a script working either on Mac OS, Windows or Linux, whatever is the name and the content of the log.
I'm quiet sure it could be simplified, maybe using 'select' function.

    |f=default(logfile);
    \v
    k=readstr(f);

    for(i=1, +oo, iferr(b=strsplit(k[i]," ");
    if(setsearch(b,"darwin")>0, print("MacOS"); return,
    if(setsearch(b,"mingw")>0,  print("Windows");return,
    if(setsearch(b,"linux")>0, print("Linux"); return))), E, print("OS
    non déterminé"); return));

    default(log,0);|

Bill, could you create a new function called, let say, 'OSType' and returning "MacOS", "Linux" or "Windows" as string?

In addition, is there a corresponding function for \v, as there is defaut(log,x) for \l? With \v, there is an annoying display of the returned information, like with \l, but no display with "default(log,x);".😉

For splitting up non-Windows, see also config/arch-osname in the repo.
https://pari.math.u-bordeaux.fr/cgi-bin/sgitweb.cgi?p=pari.git;a=blob;f=config/arch-osname

-- Ruud