Comments (2)
wow, nice bug.
my guess error is false and it should go to else as default behavior.
the exit on err is default false since it is similar behavior in sh scripts.
you do a cd to nowhere and do rm and it will delete the wrong thing. although the cd did exit with 1.
its also very helpful when you run duck without args and use it interactive mode. you dont want it to die in the middle due to spelling.
as for silent, you can change it because its possible to have custom behavior on error
from duckscript.
@rustonaut ok, i looked at the code and things came back to me.
so if does one of the following (from https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__flowcontrol__If):
- A command with optional arguments and invokes it
- A single value which doesn't match any known command
- A condition statement
the first arg you gave is not a known command, so it is considered as a value.
however, you gave 2 args, so it doesn't match bullet 2 or 3 (condition statement is values with and/or....).
so the if fails as its just invalid input.
since errors by default do not break, it continues to next line, prints yes.
it than goes to the 'else'. however the else is also a command on its own and it sees its not invoked as part of an if/else block (because if failed to execute), so again, it just continues on.
so far the 'if' handling seems right to be, but the 'else' is something i need to think about.
reason is, that you can also goto directly into the else block and it would be ok, and when you hit an 'end' command, it will also ignore it. it makes sense since you can move to whereever at any point in the script.
it definitely feels strange and hard to debug at first, but it is due to the face that there are no real blocks in duckscript.
as for errors being silent, i actually put an example in the examples directory to make it echo
https://github.com/sagiegurari/duckscript/blob/master/examples/on_error_2.ds
so you can try that. but you can do even more smarter things if you really want.
i'm closing it for now, because although its confusing at first, you need to remember that if doesn't know how to differentiate between a command with spelling mistake and an actual text.
from duckscript.
Related Issues (20)
- Feature Request - echo Colored Text HOT 6
- Command to get file size HOT 1
- Zip/unzip command HOT 6
- --recursive flag for some `fs` commands HOT 8
- Using multiple backslashes results in only a single one HOT 4
- Embed Examples HOT 2
- Run commands in exec/Get stdout from eval/Add some form of command substitution HOT 5
- Passing stdin with exec HOT 4
- Upgrade regex package versions to >=1.5.5 (security vulnerabilities) HOT 1
- Newline Escapes HOT 3
- AUR package for duckscript HOT 2
- glob follows symlinks recursively HOT 3
- mv file.rs new_file.rs does not work HOT 5
- Confusion about condition statement HOT 6
- public new release after security fix from ftp crate
- Support array spread in exec HOT 7
- How to change a directory's name HOT 4
- `replace` can not accept a unicode character like \u{FEFF} HOT 1
- `if eq` does not support empty strings HOT 2
- WebAssembly HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckscript.