Skip to content

Commit

Permalink
is_command stdlib function bug fix (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
CymDeveloppement authored Jul 2, 2024
1 parent f2d47a4 commit 69c518e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/std/main.ab
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ pub fun includes(arr, value) {
}

pub fun is_command(command: Text): Bool {
if (unsafe $command -v "{command}" > /dev/null$) {
return true
$[ -x "\$(command -v {command})" ]$ failed {
return false
}
return false
return true
}

pub fun create_symbolic_link(origin: Text, destination: Text): Bool {
Expand Down
8 changes: 6 additions & 2 deletions src/tests/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,15 @@ fn is_command() {
import { is_command } from \"std\"
main {
if is_command(\"cat\") {
echo \"exist\"
echo \"exist-cat\"
}
if is_command(\"this_is_not_command_amber\") {
echo \"exist-error\"
}
}
";
test_amber!(code, "exist")
test_amber!(code, "exist-cat")
}

#[test]
Expand Down

0 comments on commit 69c518e

Please sign in to comment.