From ce16ee8a6530f4a7b78a4bb01638d6b7d50acb0b Mon Sep 17 00:00:00 2001 From: Huw Walters Date: Sun, 6 Oct 2024 16:10:18 +0100 Subject: [PATCH 1/4] Reinstate command to remove /tmp directory. --- src/tests/stdlib/create_symbolic_link.ab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/stdlib/create_symbolic_link.ab b/src/tests/stdlib/create_symbolic_link.ab index 5835f6e1..dcc7c56f 100644 --- a/src/tests/stdlib/create_symbolic_link.ab +++ b/src/tests/stdlib/create_symbolic_link.ab @@ -7,5 +7,5 @@ main { } else { echo "failed" } - trust $rm {tmpdir}$ + trust $rm -fr {tmpdir}$ } From d9569afc3da5c71aa3018e7f5b237eb266994379 Mon Sep 17 00:00:00 2001 From: Huw Walters Date: Sun, 15 Sep 2024 09:52:09 +0100 Subject: [PATCH 2/4] Add glob functions to standard library. --- src/std/fs.ab | 35 ++++++++++++++-- .../stdlib/glob_absolute_missing_file.ab | 26 ++++++++++++ .../stdlib/glob_absolute_multiple_globs.ab | 41 ++++++++++++++++++ src/tests/stdlib/glob_absolute_wild_char.ab | 41 ++++++++++++++++++ src/tests/stdlib/glob_absolute_wild_star.ab | 41 ++++++++++++++++++ src/tests/stdlib/glob_absolute_with_spaces.ab | 41 ++++++++++++++++++ src/tests/stdlib/glob_injection_attack.ab | 25 +++++++++++ .../stdlib/glob_relative_missing_file.ab | 27 ++++++++++++ .../stdlib/glob_relative_multiple_globs.ab | 42 +++++++++++++++++++ src/tests/stdlib/glob_relative_wild_char.ab | 42 +++++++++++++++++++ src/tests/stdlib/glob_relative_wild_star.ab | 42 +++++++++++++++++++ src/tests/stdlib/glob_relative_with_spaces.ab | 42 +++++++++++++++++++ 12 files changed, 442 insertions(+), 3 deletions(-) create mode 100644 src/tests/stdlib/glob_absolute_missing_file.ab create mode 100644 src/tests/stdlib/glob_absolute_multiple_globs.ab create mode 100644 src/tests/stdlib/glob_absolute_wild_char.ab create mode 100644 src/tests/stdlib/glob_absolute_wild_star.ab create mode 100644 src/tests/stdlib/glob_absolute_with_spaces.ab create mode 100644 src/tests/stdlib/glob_injection_attack.ab create mode 100644 src/tests/stdlib/glob_relative_missing_file.ab create mode 100644 src/tests/stdlib/glob_relative_multiple_globs.ab create mode 100644 src/tests/stdlib/glob_relative_wild_char.ab create mode 100644 src/tests/stdlib/glob_relative_wild_star.ab create mode 100644 src/tests/stdlib/glob_relative_with_spaces.ab diff --git a/src/std/fs.ab b/src/std/fs.ab index 560ffaca..f46a0b85 100644 --- a/src/std/fs.ab +++ b/src/std/fs.ab @@ -1,3 +1,5 @@ +import { join, len, replace_regex, split } from "std/text" + /// Checks if a directory exists. pub fun dir_exist(path) { $[ -d "{path}" ]$ failed { @@ -40,7 +42,6 @@ pub fun create_symbolic_link(origin: Text, destination: Text): Bool { trust $ln -s "{origin}" "{destination}"$ return true } - echo "The file {origin} doesn't exist!" return false } @@ -60,7 +61,6 @@ pub fun make_executable(path: Text): Bool { trust $chmod +x "{path}"$ return true } - echo "The file {path} doesn't exist!" return false } @@ -73,6 +73,35 @@ pub fun change_owner(user: Text, path: Text): Bool { trust $chown -R "{user}" "{path}"$ return true } - return false } + +/// Escapes all characters in the passed-in glob except "*", "?" and "/", +/// to prevent injection attacks. +fun escape_non_glob_chars(path: Text): Text { + return replace_regex(path, "\([^*?/]\)", "\\\\\1") +} + +/// Finds all files or directories matching multiple file globs. When +/// we have union types, this functionality can be merged into the main +/// `glob` function. +pub fun glob_multiple(paths: [Text]): [Text]? { + let combined = "" + if len(paths) == 1 { + combined = escape_non_glob_chars(paths[0]) + } else { + let items = [Text] + loop item in paths { + item = escape_non_glob_chars(item) + items += [item] + } + combined = join(items, " ") + } + let files = $eval "for file in {combined}; do [ -e \\\"\\\$file\\\" ] && echo \\\"\\\$file\\\"; done"$? + return split(files, "\n") +} + +/// Finds all files or directories matching a file glob. +pub fun glob(path: Text): [Text]? { + return glob_multiple([path])? +} diff --git a/src/tests/stdlib/glob_absolute_missing_file.ab b/src/tests/stdlib/glob_absolute_missing_file.ab new file mode 100644 index 00000000..983fdd6a --- /dev/null +++ b/src/tests/stdlib/glob_absolute_missing_file.ab @@ -0,0 +1,26 @@ +import * from "std/fs" + +// Output +// FAILED + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + + let files = glob("{tmpdir}/missing*") failed { + echo "FAILED" + } + loop file in files { + echo "[{file}]" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_absolute_multiple_globs.ab b/src/tests/stdlib/glob_absolute_multiple_globs.ab new file mode 100644 index 00000000..6e6830a2 --- /dev/null +++ b/src/tests/stdlib/glob_absolute_multiple_globs.ab @@ -0,0 +1,41 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + + let expected = ["{tmpdir}/file.txt", "{tmpdir}/file1.txt", "{tmpdir}/file2.txt", "{tmpdir}/file99.txt", "{tmpdir}/other.csv"] + let actual = glob_multiple(["{tmpdir}/missing*", "{tmpdir}/file*.txt", "{tmpdir}/other*.csv"]) failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_absolute_wild_char.ab b/src/tests/stdlib/glob_absolute_wild_char.ab new file mode 100644 index 00000000..667b7153 --- /dev/null +++ b/src/tests/stdlib/glob_absolute_wild_char.ab @@ -0,0 +1,41 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + + let expected = ["{tmpdir}/file1.txt", "{tmpdir}/file2.txt"] + let actual = glob("{tmpdir}/file?.txt") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_absolute_wild_star.ab b/src/tests/stdlib/glob_absolute_wild_star.ab new file mode 100644 index 00000000..ffc5ef90 --- /dev/null +++ b/src/tests/stdlib/glob_absolute_wild_star.ab @@ -0,0 +1,41 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + + let expected = ["{tmpdir}/file.txt", "{tmpdir}/file1.txt", "{tmpdir}/file2.txt", "{tmpdir}/file99.txt"] + let actual = glob("{tmpdir}/file*.txt") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_absolute_with_spaces.ab b/src/tests/stdlib/glob_absolute_with_spaces.ab new file mode 100644 index 00000000..c3605fc7 --- /dev/null +++ b/src/tests/stdlib/glob_absolute_with_spaces.ab @@ -0,0 +1,41 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + + let expected = ["{tmpdir}/1st file with spaces.txt", "{tmpdir}/2nd file with spaces.txt"] + let actual = glob("{tmpdir}/*with spaces*") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_injection_attack.ab b/src/tests/stdlib/glob_injection_attack.ab new file mode 100644 index 00000000..85e1826d --- /dev/null +++ b/src/tests/stdlib/glob_injection_attack.ab @@ -0,0 +1,25 @@ +import * from "std/fs" + +// Output +// [xxx; do echo HACKED; done; for file in] + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch "{tmpdir}/xxx; do echo HACKED; done; for file in" $ + } + cd tmpdir + + // The glob function escapes all characters in the passed-in glob + // apart from "*", "?" and "/", to prevent injection attacks. If we + // didn't do this, the following code would output "[HACKED]" instead + // of the filename. + let files = glob("xxx; do echo HACKED; done; for file in") failed { + echo "FAILED" + } + loop file in files { + echo "[{file}]" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_relative_missing_file.ab b/src/tests/stdlib/glob_relative_missing_file.ab new file mode 100644 index 00000000..34f9c34e --- /dev/null +++ b/src/tests/stdlib/glob_relative_missing_file.ab @@ -0,0 +1,27 @@ +import * from "std/fs" + +// Output +// FAILED + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + cd tmpdir + + let files = glob("missing*") failed { + echo "FAILED" + } + loop file in files { + echo "[{file}]" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_relative_multiple_globs.ab b/src/tests/stdlib/glob_relative_multiple_globs.ab new file mode 100644 index 00000000..9142ffaf --- /dev/null +++ b/src/tests/stdlib/glob_relative_multiple_globs.ab @@ -0,0 +1,42 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + cd tmpdir + + let expected = ["file.txt", "file1.txt", "file2.txt", "file99.txt", "other.csv"] + let actual = glob_multiple(["missing*", "file*.txt", "other*.csv"]) failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_relative_wild_char.ab b/src/tests/stdlib/glob_relative_wild_char.ab new file mode 100644 index 00000000..007bbe54 --- /dev/null +++ b/src/tests/stdlib/glob_relative_wild_char.ab @@ -0,0 +1,42 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + cd tmpdir + + let expected = ["file1.txt", "file2.txt"] + let actual = glob("file?.txt") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_relative_wild_star.ab b/src/tests/stdlib/glob_relative_wild_star.ab new file mode 100644 index 00000000..d85c567d --- /dev/null +++ b/src/tests/stdlib/glob_relative_wild_star.ab @@ -0,0 +1,42 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + cd tmpdir + + let expected = ["file.txt", "file1.txt", "file2.txt", "file99.txt"] + let actual = glob("file*.txt") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} diff --git a/src/tests/stdlib/glob_relative_with_spaces.ab b/src/tests/stdlib/glob_relative_with_spaces.ab new file mode 100644 index 00000000..cc0a8ffd --- /dev/null +++ b/src/tests/stdlib/glob_relative_with_spaces.ab @@ -0,0 +1,42 @@ +import * from "std/array" +import * from "std/fs" +import * from "std/text" + +fun compare(actual: [Text], expected: [Text]): Bool { + if len(actual) != len(expected) { + return false + } + loop file in expected { + if not includes(actual, file) { + return false + } + } + return true +} + +main { + let tmpdir = trust $ mktemp -d $ + trust { + $ touch {tmpdir}/1st\ file\ with\ spaces.txt $ + $ touch {tmpdir}/2nd\ file\ with\ spaces.txt $ + $ touch {tmpdir}/file.txt $ + $ touch {tmpdir}/file1.txt $ + $ touch {tmpdir}/file2.txt $ + $ touch {tmpdir}/file99.txt $ + $ touch {tmpdir}/other.csv $ + } + cd tmpdir + + let expected = ["1st file with spaces.txt", "2nd file with spaces.txt"] + let actual = glob("*with spaces*") failed { + echo "FAILED" + } + if compare(actual, expected) { + echo "Succeded" + } else { + echo "Expected: {expected}" + echo "Actual: {actual}" + } + + trust $ rm -rf {tmpdir} $ +} From 984e7fe1f12098aa3b5d522187eab6ab50431435 Mon Sep 17 00:00:00 2001 From: Huw Walters Date: Sat, 19 Oct 2024 07:37:41 +0100 Subject: [PATCH 3/4] Whitespace changes. --- src/tests/stdlib/glob_absolute_multiple_globs.ab | 8 +++++++- src/tests/stdlib/glob_absolute_wild_char.ab | 5 ++++- src/tests/stdlib/glob_absolute_wild_star.ab | 7 ++++++- src/tests/stdlib/glob_absolute_with_spaces.ab | 5 ++++- src/tests/stdlib/glob_relative_multiple_globs.ab | 8 +++++++- src/tests/stdlib/glob_relative_wild_char.ab | 5 ++++- src/tests/stdlib/glob_relative_wild_star.ab | 7 ++++++- src/tests/stdlib/glob_relative_with_spaces.ab | 5 ++++- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/tests/stdlib/glob_absolute_multiple_globs.ab b/src/tests/stdlib/glob_absolute_multiple_globs.ab index 6e6830a2..7cc9ea11 100644 --- a/src/tests/stdlib/glob_absolute_multiple_globs.ab +++ b/src/tests/stdlib/glob_absolute_multiple_globs.ab @@ -26,7 +26,13 @@ main { $ touch {tmpdir}/other.csv $ } - let expected = ["{tmpdir}/file.txt", "{tmpdir}/file1.txt", "{tmpdir}/file2.txt", "{tmpdir}/file99.txt", "{tmpdir}/other.csv"] + let expected = [ + "{tmpdir}/file.txt", + "{tmpdir}/file1.txt", + "{tmpdir}/file2.txt", + "{tmpdir}/file99.txt", + "{tmpdir}/other.csv", + ] let actual = glob_multiple(["{tmpdir}/missing*", "{tmpdir}/file*.txt", "{tmpdir}/other*.csv"]) failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_absolute_wild_char.ab b/src/tests/stdlib/glob_absolute_wild_char.ab index 667b7153..2debfacd 100644 --- a/src/tests/stdlib/glob_absolute_wild_char.ab +++ b/src/tests/stdlib/glob_absolute_wild_char.ab @@ -26,7 +26,10 @@ main { $ touch {tmpdir}/other.csv $ } - let expected = ["{tmpdir}/file1.txt", "{tmpdir}/file2.txt"] + let expected = [ + "{tmpdir}/file1.txt", + "{tmpdir}/file2.txt", + ] let actual = glob("{tmpdir}/file?.txt") failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_absolute_wild_star.ab b/src/tests/stdlib/glob_absolute_wild_star.ab index ffc5ef90..d5ebeda8 100644 --- a/src/tests/stdlib/glob_absolute_wild_star.ab +++ b/src/tests/stdlib/glob_absolute_wild_star.ab @@ -26,7 +26,12 @@ main { $ touch {tmpdir}/other.csv $ } - let expected = ["{tmpdir}/file.txt", "{tmpdir}/file1.txt", "{tmpdir}/file2.txt", "{tmpdir}/file99.txt"] + let expected = [ + "{tmpdir}/file.txt", + "{tmpdir}/file1.txt", + "{tmpdir}/file2.txt", + "{tmpdir}/file99.txt", + ] let actual = glob("{tmpdir}/file*.txt") failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_absolute_with_spaces.ab b/src/tests/stdlib/glob_absolute_with_spaces.ab index c3605fc7..f284f7bd 100644 --- a/src/tests/stdlib/glob_absolute_with_spaces.ab +++ b/src/tests/stdlib/glob_absolute_with_spaces.ab @@ -26,7 +26,10 @@ main { $ touch {tmpdir}/other.csv $ } - let expected = ["{tmpdir}/1st file with spaces.txt", "{tmpdir}/2nd file with spaces.txt"] + let expected = [ + "{tmpdir}/1st file with spaces.txt", + "{tmpdir}/2nd file with spaces.txt", + ] let actual = glob("{tmpdir}/*with spaces*") failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_relative_multiple_globs.ab b/src/tests/stdlib/glob_relative_multiple_globs.ab index 9142ffaf..0cb872c2 100644 --- a/src/tests/stdlib/glob_relative_multiple_globs.ab +++ b/src/tests/stdlib/glob_relative_multiple_globs.ab @@ -27,7 +27,13 @@ main { } cd tmpdir - let expected = ["file.txt", "file1.txt", "file2.txt", "file99.txt", "other.csv"] + let expected = [ + "file.txt", + "file1.txt", + "file2.txt", + "file99.txt", + "other.csv", + ] let actual = glob_multiple(["missing*", "file*.txt", "other*.csv"]) failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_relative_wild_char.ab b/src/tests/stdlib/glob_relative_wild_char.ab index 007bbe54..05d62cc4 100644 --- a/src/tests/stdlib/glob_relative_wild_char.ab +++ b/src/tests/stdlib/glob_relative_wild_char.ab @@ -27,7 +27,10 @@ main { } cd tmpdir - let expected = ["file1.txt", "file2.txt"] + let expected = [ + "file1.txt", + "file2.txt", + ] let actual = glob("file?.txt") failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_relative_wild_star.ab b/src/tests/stdlib/glob_relative_wild_star.ab index d85c567d..4851b709 100644 --- a/src/tests/stdlib/glob_relative_wild_star.ab +++ b/src/tests/stdlib/glob_relative_wild_star.ab @@ -27,7 +27,12 @@ main { } cd tmpdir - let expected = ["file.txt", "file1.txt", "file2.txt", "file99.txt"] + let expected = [ + "file.txt", + "file1.txt", + "file2.txt", + "file99.txt", + ] let actual = glob("file*.txt") failed { echo "FAILED" } diff --git a/src/tests/stdlib/glob_relative_with_spaces.ab b/src/tests/stdlib/glob_relative_with_spaces.ab index cc0a8ffd..6c64c461 100644 --- a/src/tests/stdlib/glob_relative_with_spaces.ab +++ b/src/tests/stdlib/glob_relative_with_spaces.ab @@ -27,7 +27,10 @@ main { } cd tmpdir - let expected = ["1st file with spaces.txt", "2nd file with spaces.txt"] + let expected = [ + "1st file with spaces.txt", + "2nd file with spaces.txt", + ] let actual = glob("*with spaces*") failed { echo "FAILED" } From 54b2bcb7b4912361f59228673d28ddcbc51324b9 Mon Sep 17 00:00:00 2001 From: Huw Walters Date: Mon, 21 Oct 2024 21:07:30 +0100 Subject: [PATCH 4/4] Reinstate removed blank lines. --- src/std/fs.ab | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/std/fs.ab b/src/std/fs.ab index f46a0b85..5c5dbe65 100644 --- a/src/std/fs.ab +++ b/src/std/fs.ab @@ -42,6 +42,7 @@ pub fun create_symbolic_link(origin: Text, destination: Text): Bool { trust $ln -s "{origin}" "{destination}"$ return true } + echo "The file {origin} doesn't exist!" return false } @@ -61,6 +62,7 @@ pub fun make_executable(path: Text): Bool { trust $chmod +x "{path}"$ return true } + echo "The file {path} doesn't exist!" return false } @@ -73,6 +75,7 @@ pub fun change_owner(user: Text, path: Text): Bool { trust $chown -R "{user}" "{path}"$ return true } + return false }