msolve icon indicating copy to clipboard operation
msolve copied to clipboard

Detect sed variant at runtime

Open wegank opened this issue 1 year ago • 0 comments

The comment in interfaces/msolve-to-maple-file-interface.mpl

https://github.com/algebraic-solving/msolve/blob/07c7cb2c0eaa7dba7c54dc1e64178fea58e40d6a/interfaces/msolve-to-maple-file-interface.mpl#L21-L24

is not accurate, as the sed command does work for macOS users with GNU sed, which is common for Nix users in a build environment:

$ sed --version
sed: illegal option -- -
usage: sed script [-Ealnru] [-i extension] [file ...]
	sed [-Ealnu] [-i extension] [-e script] ... [-f script_file] ... [file ...]

$ nix develop github:NixOS/nixpkgs/nixos-unstable#hello
$ sed --version
sed (GNU sed) 4.9
Copyright (C) 2022 Free Software Foundation, Inc.

Instead, it would be nice to detect if sed is BSD or GNU at runtime, for example

# BSD sed
> ssystem("sed --version");
[1, ""]

# GNU sed
> ssystem("sed --version");
[0, "sed (GNU sed) 4.9
    Copyright (C) 2022 Free Software Foundation, Inc.
     ..."]

A natural extension would be to combine interfaces/msolve-to-maple-file-interface-macos.mpl into interfaces/msolve-to-maple-file-interface.mpl, since their logic differs little.

wegank avatar May 02 '24 13:05 wegank