Skip to content

Consider alternatives get macOS properties os.name and os.version #2329

Open
@ekrich

Description

@ekrich
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G9028
struct utsname name;
    if (uname(&name) == 0) {
        printf("os.name=%s\n",name.sysname);
        printf("os.version=%s\n",name.release);
    }
// os.name=Darwin
// os.version=18.7.0

Seems no way to map Darwin version to Mac OS X version.

/usr/libexec/PlistBuddy -c "Print:ProductName" \
                        -c "Print:ProductVersion" \
                        -c "Print:ProductBuildVersion" /System/Library/CoreServices/SystemVersion.plist
Mac OS X
10.12.6
16G2128

That is an XML file but it may be best to just read that file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions