Skip to content

OS-specific attributes on all top-level declarations #2955

@cspotcode

Description

@cspotcode

Is it intuitive to support OS-specific attributes on all top-level declarations in a justfile, not just recipes?

The OS is hardcoded into the executable, so the logic is straightforward:

E.g just.exe parses and completely ignores anything with [macos] or [linux] on it

This simplifies things overall and implements multiple tickets:

Design challenges

Requires OS-specific attribute on both windows and unix setting/variable declarations:

[unix] # <-- if you omit this, error "Setting redefined"
set shell := ['bash', '-euc']

[windows]
set shell := ['busybox', 'bash', '-euc']

We should raise the "redefinition" error on Unix, too. Even though we're ignoring the second declaration on Unix, the error warns us that this justfile will fail on Windows.

Alternatively, could allow redefinition if second one has OS attribute. The un-attributed declaration becomes automatically [not-windows].

Limitations

Falls short of enabling if {} else {} logic in settings. But that's currently impossible anyway.

# If anyone has been wanting to do this, they still won't be able to
if which('sh') {
    set shell := ['sh', '-euc']
} else {
    set shell := ['somethingelse', '-euc']
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions