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']
}
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.exeparses and completely ignores anything with[macos]or[linux]on itThis simplifies things overall and implements multiple tickets:
set windows-shell :=can be deprecated, replaced by[windows] ; set shell :=windows-script-interpreterfor free, can close Add windows-script-interpreter setting #2944Design challenges
Requires OS-specific attribute on both windows and unix setting/variable declarations:
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.