From 1ac4393eb762226e4833f6049a5c163ffc8735eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladimir=20T=C3=A1mara=20Pati=C3=B1o?= Date: Sun, 1 Dec 2024 18:56:56 -0500 Subject: [PATCH 1/5] Add initial support for OpenBSD with attribute openbsd. Closes #2496 --- README.md | 15 ++++++++------- crates-io-readme.md | 2 +- src/attribute.rs | 4 ++++ src/recipe.rs | 4 +++- tests/attributes.rs | 9 +++++---- tests/os_attributes.rs | 10 ++++++++++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 27e3307a50..315fa405ec 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Yay, all your tests passed! [`make`'s complexity and idiosyncrasies](#what-are-the-idiosyncrasies-of-make-that-just-avoids). No need for `.PHONY` recipes! -- Linux, MacOS, and Windows are supported with no additional dependencies. +- Linux, MacOS, OpenBSD and Windows are supported with no additional dependencies. (Although if your system doesn't have an `sh`, you'll need to [choose a different shell](#shell).) @@ -1986,6 +1986,7 @@ change their behavior. | `[no-cd]`1.9.0 | recipe | Don't change directory before executing recipe. | | `[no-exit-message]`1.7.0 | recipe | Don't print an error message if recipe fails. | | `[no-quiet]`1.23.0 | recipe | Override globally quiet recipes and always echo out the recipe. | +| `[openbsd]`1.x.0 | recipe | Enable recipe on OpenBSD. | | `[positional-arguments]`1.29.0 | recipe | Turn on [positional arguments](#positional-arguments) for this recipe. | | `[private]`1.10.0 | alias, recipe | Make recipe, alias, or variable private. See [Private Recipes](#private-recipes). | | `[script]`1.33.0 | recipe | Execute recipe as script. See [script recipes](#script-recipes) for more details. | @@ -2762,12 +2763,12 @@ Hola from a nushell script! Hello from ruby! ``` -On Unix-like operating systems, including Linux and MacOS, shebang recipes are -executed by saving the recipe body to a file in a temporary directory, marking -the file as executable, and executing it. The OS then parses the shebang line -into a command line and invokes it, including the path to the file. For -example, if a recipe starts with `#!/usr/bin/env bash`, the final command that -the OS runs will be something like `/usr/bin/env bash +On Unix-like operating systems, including Linux, MacOS and OpenBSD, shebang +recipes are executed by saving the recipe body to a file in a temporary +directory, marking the file as executable, and executing it. The OS then +parses the shebang line into a command line and invokes it, including the +path to the file. For example, if a recipe starts with `#!/usr/bin/env bash`, +the final command that the OS runs will be something like `/usr/bin/env bash /tmp/PATH_TO_SAVED_RECIPE_BODY`. Shebang line splitting is operating system dependent. When passing a command diff --git a/crates-io-readme.md b/crates-io-readme.md index c05ac0a639..81fef59ec2 100644 --- a/crates-io-readme.md +++ b/crates-io-readme.md @@ -17,6 +17,6 @@ test TEST: build `just` produces detailed error messages and avoids `make`'s idiosyncrasies, so debugging a justfile is easier and less surprising than debugging a makefile. -It works on Linux, MacOS, and Windows. +It works on Linux, MacOS, OpenBSD and Windows. Read more on [GitHub](https://github.com/casey/just). diff --git a/src/attribute.rs b/src/attribute.rs index 39a0a80060..4ec813f076 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -18,6 +18,7 @@ pub(crate) enum Attribute<'src> { NoCd, NoExitMessage, NoQuiet, + Openbsd, PositionalArguments, Private, Script(Option>), @@ -36,6 +37,7 @@ impl AttributeDiscriminant { | Self::NoCd | Self::NoExitMessage | Self::NoQuiet + | Self::Openbsd | Self::PositionalArguments | Self::Private | Self::Unix @@ -83,6 +85,7 @@ impl<'src> Attribute<'src> { AttributeDiscriminant::NoCd => Self::NoCd, AttributeDiscriminant::NoExitMessage => Self::NoExitMessage, AttributeDiscriminant::NoQuiet => Self::NoQuiet, + AttributeDiscriminant::Openbsd => Self::Openbsd, AttributeDiscriminant::PositionalArguments => Self::PositionalArguments, AttributeDiscriminant::Private => Self::Private, AttributeDiscriminant::Script => Self::Script({ @@ -131,6 +134,7 @@ impl Display for Attribute<'_> { | Self::NoCd | Self::NoExitMessage | Self::NoQuiet + | Self::Openbsd | Self::PositionalArguments | Self::Private | Self::Script(None) diff --git a/src/recipe.rs b/src/recipe.rs index 81fbc7ac2f..4a2d465f21 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -116,12 +116,14 @@ impl<'src, D> Recipe<'src, D> { let windows = self.attributes.contains(&Attribute::Windows); let linux = self.attributes.contains(&Attribute::Linux); let macos = self.attributes.contains(&Attribute::Macos); + let openbsd = self.attributes.contains(&Attribute::Openbsd); let unix = self.attributes.contains(&Attribute::Unix); - (!windows && !linux && !macos && !unix) + (!windows && !linux && !macos && !openbsd && !unix) || (cfg!(target_os = "windows") && windows) || (cfg!(target_os = "linux") && (linux || unix)) || (cfg!(target_os = "macos") && (macos || unix)) + || (cfg!(target_os = "openbsd") && (openbsd || unix)) || (cfg!(windows) && windows) || (cfg!(unix) && unix) } diff --git a/tests/attributes.rs b/tests/attributes.rs index 9f022025de..41e205a27f 100644 --- a/tests/attributes.rs +++ b/tests/attributes.rs @@ -8,6 +8,7 @@ fn all() { [macos] [windows] [linux] + [openbsd] [unix] [no-exit-message] foo: @@ -48,7 +49,7 @@ fn multiple_attributes_one_line() { Test::new() .justfile( " - [macos, windows,linux] + [macos, windows,linux,openbsd] [no-exit-message] foo: exit 1 @@ -64,7 +65,7 @@ fn multiple_attributes_one_line_error_message() { Test::new() .justfile( " - [macos, windows linux] + [macos, windows linux,openbsd] [no-exit-message] foo: exit 1 @@ -75,7 +76,7 @@ fn multiple_attributes_one_line_error_message() { error: Expected ']', ':', ',', or '(', but found identifier ——▶ justfile:1:17 │ - 1 │ [macos, windows linux] + 1 │ [macos, windows linux,openbsd] │ ^^^^^ ", ) @@ -88,7 +89,7 @@ fn multiple_attributes_one_line_duplicate_check() { Test::new() .justfile( " - [macos, windows, linux] + [macos, windows, linux, openbsd] [linux] foo: exit 1 diff --git a/tests/os_attributes.rs b/tests/os_attributes.rs index 81729850f7..eecd6515b1 100644 --- a/tests/os_attributes.rs +++ b/tests/os_attributes.rs @@ -47,6 +47,11 @@ fn os() { [linux] foo: echo quxx + + [openbsd] + foo: + echo openbsd + ", ) .stdout(if cfg!(target_os = "macos") { @@ -55,6 +60,8 @@ fn os() { "baz\n" } else if cfg!(target_os = "linux") { "quxx\n" + } else if cfg!(target_os = "openbsd") { + "openbsd\n" } else { panic!("unexpected os family") }) @@ -64,6 +71,8 @@ fn os() { "echo baz\n" } else if cfg!(target_os = "linux") { "echo quxx\n" + } else if cfg!(target_os = "openbsd") { + "echo openbsd\n" } else { panic!("unexpected os family") }) @@ -78,6 +87,7 @@ fn all() { [macos] [windows] [linux] + [openbsd] [unix] foo: echo bar From 87214ef21ebb5b8820ba0dffc7c6375e533af81f Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 1 Dec 2024 16:53:43 -0800 Subject: [PATCH 2/5] Revise readme --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 315fa405ec..ee2993775e 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Yay, all your tests passed! [`make`'s complexity and idiosyncrasies](#what-are-the-idiosyncrasies-of-make-that-just-avoids). No need for `.PHONY` recipes! -- Linux, MacOS, OpenBSD and Windows are supported with no additional dependencies. - (Although if your system doesn't have an `sh`, you'll need to +- Linux, MacOS, Windows, and reasonable unices are supported with no additional + dependencies. (Although if your system doesn't have an `sh`, you'll need to [choose a different shell](#shell).) - Errors are specific and informative, and syntax errors are reported along @@ -1986,7 +1986,7 @@ change their behavior. | `[no-cd]`1.9.0 | recipe | Don't change directory before executing recipe. | | `[no-exit-message]`1.7.0 | recipe | Don't print an error message if recipe fails. | | `[no-quiet]`1.23.0 | recipe | Override globally quiet recipes and always echo out the recipe. | -| `[openbsd]`1.x.0 | recipe | Enable recipe on OpenBSD. | +| `[openbsd]`master | recipe | Enable recipe on OpenBSD. | | `[positional-arguments]`1.29.0 | recipe | Turn on [positional arguments](#positional-arguments) for this recipe. | | `[private]`1.10.0 | alias, recipe | Make recipe, alias, or variable private. See [Private Recipes](#private-recipes). | | `[script]`1.33.0 | recipe | Execute recipe as script. See [script recipes](#script-recipes) for more details. | @@ -2763,12 +2763,12 @@ Hola from a nushell script! Hello from ruby! ``` -On Unix-like operating systems, including Linux, MacOS and OpenBSD, shebang -recipes are executed by saving the recipe body to a file in a temporary -directory, marking the file as executable, and executing it. The OS then -parses the shebang line into a command line and invokes it, including the -path to the file. For example, if a recipe starts with `#!/usr/bin/env bash`, -the final command that the OS runs will be something like `/usr/bin/env bash +On Unix-like operating systems, including Linux and MacOS, shebang recipes are +executed by saving the recipe body to a file in a temporary directory, marking +the file as executable, and executing it. The OS then parses the shebang line +into a command line and invokes it, including the path to the file. For +example, if a recipe starts with `#!/usr/bin/env bash`, the final command that +the OS runs will be something like `/usr/bin/env bash /tmp/PATH_TO_SAVED_RECIPE_BODY`. Shebang line splitting is operating system dependent. When passing a command From fc21485bfbeec471c0a427add8155269f35e1e52 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 1 Dec 2024 16:54:43 -0800 Subject: [PATCH 3/5] Revise crates.io readme --- crates-io-readme.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates-io-readme.md b/crates-io-readme.md index 81fef59ec2..63c900f2b6 100644 --- a/crates-io-readme.md +++ b/crates-io-readme.md @@ -1,6 +1,7 @@ `just` is a handy way to save and run project-specific commands. -Commands are stored in a file called `justfile` or `Justfile` with syntax inspired by `make`: +Commands are stored in a file called `justfile` or `Justfile` with syntax +inspired by `make`: ```make build: @@ -15,8 +16,9 @@ test TEST: build ./test --test {{TEST}} ``` -`just` produces detailed error messages and avoids `make`'s idiosyncrasies, so debugging a justfile is easier and less surprising than debugging a makefile. +`just` produces detailed error messages and avoids `make`'s idiosyncrasies, so +debugging a justfile is easier and less surprising than debugging a makefile. -It works on Linux, MacOS, OpenBSD and Windows. +It works on all operating systems supported by Rust. Read more on [GitHub](https://github.com/casey/just). From 4e3b8043ec5d4a79eac56cb91bdf6540aebd052b Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 1 Dec 2024 16:57:28 -0800 Subject: [PATCH 4/5] Revise --- src/recipe.rs | 6 +++--- tests/attributes.rs | 12 ++++++------ tests/os_attributes.rs | 11 +++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/recipe.rs b/src/recipe.rs index 4a2d465f21..ac7fdd6596 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -113,19 +113,19 @@ impl<'src, D> Recipe<'src, D> { } pub(crate) fn enabled(&self) -> bool { - let windows = self.attributes.contains(&Attribute::Windows); let linux = self.attributes.contains(&Attribute::Linux); let macos = self.attributes.contains(&Attribute::Macos); let openbsd = self.attributes.contains(&Attribute::Openbsd); let unix = self.attributes.contains(&Attribute::Unix); + let windows = self.attributes.contains(&Attribute::Windows); (!windows && !linux && !macos && !openbsd && !unix) - || (cfg!(target_os = "windows") && windows) || (cfg!(target_os = "linux") && (linux || unix)) || (cfg!(target_os = "macos") && (macos || unix)) || (cfg!(target_os = "openbsd") && (openbsd || unix)) - || (cfg!(windows) && windows) + || (cfg!(target_os = "windows") && windows) || (cfg!(unix) && unix) + || (cfg!(windows) && windows) } fn print_exit_message(&self) -> bool { diff --git a/tests/attributes.rs b/tests/attributes.rs index 41e205a27f..80393f1aa2 100644 --- a/tests/attributes.rs +++ b/tests/attributes.rs @@ -6,10 +6,10 @@ fn all() { .justfile( " [macos] - [windows] [linux] [openbsd] [unix] + [windows] [no-exit-message] foo: exit 1 @@ -49,7 +49,7 @@ fn multiple_attributes_one_line() { Test::new() .justfile( " - [macos, windows,linux,openbsd] + [macos,windows,linux,openbsd] [no-exit-message] foo: exit 1 @@ -65,7 +65,7 @@ fn multiple_attributes_one_line_error_message() { Test::new() .justfile( " - [macos, windows linux,openbsd] + [macos,windows linux,openbsd] [no-exit-message] foo: exit 1 @@ -74,10 +74,10 @@ fn multiple_attributes_one_line_error_message() { .stderr( " error: Expected ']', ':', ',', or '(', but found identifier - ——▶ justfile:1:17 + ——▶ justfile:1:16 │ - 1 │ [macos, windows linux,openbsd] - │ ^^^^^ + 1 │ [macos,windows linux,openbsd] + │ ^^^^^ ", ) .status(1) diff --git a/tests/os_attributes.rs b/tests/os_attributes.rs index eecd6515b1..de74058043 100644 --- a/tests/os_attributes.rs +++ b/tests/os_attributes.rs @@ -50,8 +50,7 @@ fn os() { [openbsd] foo: - echo openbsd - + echo bob ", ) .stdout(if cfg!(target_os = "macos") { @@ -61,7 +60,7 @@ fn os() { } else if cfg!(target_os = "linux") { "quxx\n" } else if cfg!(target_os = "openbsd") { - "openbsd\n" + "bob\n" } else { panic!("unexpected os family") }) @@ -72,7 +71,7 @@ fn os() { } else if cfg!(target_os = "linux") { "echo quxx\n" } else if cfg!(target_os = "openbsd") { - "echo openbsd\n" + "echo bob\n" } else { panic!("unexpected os family") }) @@ -84,11 +83,11 @@ fn all() { Test::new() .justfile( " - [macos] - [windows] [linux] + [macos] [openbsd] [unix] + [windows] foo: echo bar ", From 1443b903f586b7f02bd0ac3ec1b790a638f82813 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 1 Dec 2024 16:59:41 -0800 Subject: [PATCH 5/5] Revise readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee2993775e..976892075a 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,9 @@ Yay, all your tests passed! [`make`'s complexity and idiosyncrasies](#what-are-the-idiosyncrasies-of-make-that-just-avoids). No need for `.PHONY` recipes! -- Linux, MacOS, Windows, and reasonable unices are supported with no additional - dependencies. (Although if your system doesn't have an `sh`, you'll need to - [choose a different shell](#shell).) +- Linux, MacOS, Windows, and other reasonable unices are supported with no + additional dependencies. (Although if your system doesn't have an `sh`, + you'll need to [choose a different shell](#shell).) - Errors are specific and informative, and syntax errors are reported along with their source context.