diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ecca5dbec..4593c6c87 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -110,6 +110,7 @@ Scripting improvements - Universal variables can now store strings containing invalid Unicode codepoints (:issue:`10313`). - A new ``path basename -E`` option that causes it to return the basename ("filename" with the directory prefix removed) with the final extension (if any) also removed. This is a shorter version of ``path change-extension "" (path basename $foo)`` (:issue:`10521`). - A new ``math --scale-mode`` option to select ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish; the default value is ``truncate``. (:issue:`9117`). +- ``random`` is now less strict about its arguments, allowing a start larger or equal to the end. (:issue:`10879`) Interactive improvements ------------------------ diff --git a/src/builtins/random.rs b/src/builtins/random.rs index f854aef62..5d5c70bdd 100644 --- a/src/builtins/random.rs +++ b/src/builtins/random.rs @@ -135,22 +135,14 @@ fn parse_ull(streams: &mut IoStreams, cmd: &wstr, num: &wstr) -> Result&2 + status print-stack-trace return 1 end end @@ -55,6 +48,7 @@ function check_contains printf "Unexpected: %s not among possibilities" $argv[1] >&2 printf " %s" $argv[2..-1] >&2 printf "\n" >&2 + status print-stack-trace return 1 end end @@ -73,6 +67,7 @@ for i in (seq 10) test_range 0 10 test_range -10 -1 test_range -10 10 + test_range 5 5 test_range 0 $max test_range $min -1 @@ -89,6 +84,7 @@ for i in (seq 10) check_contains (random -- $min $close_max 0) $min -1 check_contains (random -- $min $max $max) $min 0 $max check_contains (random -- $min $diff_max $max) $min $max + check_contains (random -- 5 0) 0 1 2 3 4 5 test_step 0 $i 10 test_step -5 $i 5