Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept true as truthy value in environment vars #645

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Improved

- Boot is officially Maven Central compatible. Make sure the `sources` and `javadoc` artifacts are on the fileset and `:classifier` is correctly set.
- Environment variables BOOT_AS_ROOT, BOOT_WATCHERS_DISABLE und BOOT_COLOR accept `true` as a truthy value beside `1` and `yes` [#631][631]

#### Fixed

Expand All @@ -15,6 +16,7 @@
[598]: https://github.com/boot-clj/boot/pull/598
[625]: https://github.com/boot-clj/boot/pull/625
[629]: https://github.com/boot-clj/boot/pull/629
[631]: https://github.com/boot-clj/boot/issues/631

## 2.7.2

Expand Down
3 changes: 2 additions & 1 deletion boot/base/src/main/java/boot/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,9 @@ public class App {

public static void
main(String[] args) throws Exception {
String asroot = config("BOOT_AS_ROOT", "no");
if (System.getProperty("user.name").equals("root")
&& ! config("BOOT_AS_ROOT", "no").equals("yes"))
&& ! (asroot.equals("yes") || asroot.equals("1") || asroot.equals("true")))
throw new Exception("refusing to run as root (set BOOT_AS_ROOT=yes to force)");

// BOOT_VERSION is decided by the loader; it will respect the
Expand Down
10 changes: 5 additions & 5 deletions boot/pod/src/boot/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
system. Constrained environments like clould build containers limit
the number of inotify handles, and watchers are only necessary for
interactive dev, not one-shot jobs. environment variable or
configuration option BOOT_WATCHERS_DISABLE to either '1' or 'yes' to
disable inotify; any other value keeps normal behavior."
configuration option BOOT_WATCHERS_DISABLE to either '1' or 'yes' or
'true' to disable inotify; any other value keeps normal behavior."
[]
(let [value (boot.App/config "BOOT_WATCHERS_DISABLE")]
(if (string/blank? value)
true
(not (#{"1" "yes"}
(not (#{"1" "yes" "true"}
(string/lower-case value))))))

(defn colorize?-system-default
Expand All @@ -37,12 +37,12 @@
output is disabled on Windows by default, but enabled by default
on other platforms. The default can be overriden by setting the
environment variable or configuration option BOOT_COLOR to
either '1' or 'yes' to enable it; any other value disables
either '1' or 'yes' or 'true' to enable it; any other value disables
colorization."
[]
(let [value (boot.App/config "BOOT_COLOR")]
(if-not (string/blank? value)
(#{"1" "yes"} (string/lower-case value))
(#{"1" "yes" "true"} (string/lower-case value))
(not (boot.App/isWindows)))))

(def ^:dynamic *verbosity*
Expand Down
4 changes: 2 additions & 2 deletions doc/boot.util.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Return whether we should colorize output on this system. This is
true, unless we're on Windows, where this is false. The default
console on Windows does not interprete ansi escape codes. The
default can be overriden by setting the environment variable
BOOT_COLOR=1 or BOOT_COLOR=yes to turn it on or any other value to
turn it off.
BOOT_COLOR=1 or BOOT_COLOR=yes or BOOT_COLOR=true to turn it on
or any other value to turn it off.
```

<hr>
Expand Down